I need some help from someone who can write GC script functions. I am looking to create a point array. I have consolidated several different series functions to get an X spacing value that I want along the bottom line/curve which is at a constant elevation.
I have then found points along a polyline at their respective YZ plane intersect with the non-uniform polyline directly above – these 2 lines represent the top and bottom of a retaining wall. These intercept points serve as the maximum elevation of a point in the Y direction that I want. My problem is, I can’t get the elevations of the points to be inserted into the appropriate index of the series I have for the Y spacing. See screen shots below:
This is the Y (elevation) series that I want to be at each X spaced point along the bottom of wall polyline. Essentially, what I want to do is tack on the top of wall Y value at each respective X spacing location so that it falls within the appropriate index in this list. I have tried the operation node with Interleave, but I’m not having success inserting at the appropriate level:
My Y spacing is a 1.25’ increment and I want to add in the last elevation based on the other list I have of the values from the intersection points along the non-uniform polyline. So, the first row would read: {{0, 1.25, 2.5, 3.75, 5, 6.25, 7.5, 8.098}}, the next would be {{0, 1.25, 2.5, 3.75, 5, 6.25, 7.5, 8.122}} … etc.
Any input would be greatly appreciated.
GCHelp.zip
So rather than messing with indices, it looks like the issue I have could be solved if the series function would include the limit input. Does anyone know how to adjust the series function to include the limit point? I am not having success with creating a function with 'if' or 'for' statements:
function(int Start, double Increment, double MaxElevation) { double ElevationList = {}, Elevation = -1.25; for (int i = 0; i < MaxElevation; ++i) { Elevation = Elevation + Increment; ElevationList.Add(Elevation); } if (Elevation > MaxElevation) { Elevation = MaxElevation; ElevationList.Append(Elevation); } return ElevationList; }
Again, I have little to no script writing experience, so I'm sure this is an issue on my end. I'm not able to use a list as the limit like I am with a series function. This kind of works, but it isn't following the increment for the i value, it looks like I don't get control of that in anyway. Definitely need some guidance on this.
Hi Justin,
I tried to have a look at the file you uploaded but i had a few errors so I thought I could help with the function.
here is an updated version.
function(int Start, double Increment, int MaxElevation) { double ElevationList = {}; double Elevation = -1.25; for (int i = 0; i < MaxElevation; ++i) { Elevation = Elevation + Increment; ElevationList.Add(Elevation); } if (Elevation > MaxElevation) { Elevation = MaxElevation; ElevationList.Append(Elevation); } return ElevationList; }
The main points where I think you had an issue were, you needed to define what type the "Elevation" was, assume it is going to be a double.
with the for loop the issue is you were looking to pass a double into the for loop where it was looking for an int.
The way I have updated the code is probably not the way you were intending it to work. if I was looking to use a loop to find new height values for a series of say x values (a list of x values) i would define an input at the top called say object xlist, or double xlist for a list of double x values. the data is not important it is the count of the list.
then in the for statement use:
for (int i = 0; i < xlist.Count; ++i)
this will then loop through the number of the count. just be aware that the count returns the count of that index. so if you want to loop through a list of lists(sort of array) you will need a second loop or you will need to flatten the array.
Hope that helps.
Wayne
Thanks Wayne - this makes sense, I just don't know how to do it. Would you be able to walk me through adding in this second loop? I am confused how this will get inserted. If I start with the for statement counting the count in the loop, I am guessing I need to have several iterations of this loop for the various "limits" in the elevation list? I want to avoid flattening the list, because each count is giving me the sequence of elevations for the points I want to create later.
For example, the first 12 lists from the XSpacingList count have elevations 0 through 7.5 but will all have different append values to tack on. Will these need to be if statements? Here was my initial try:
function(int Start, double Increment, object MaxElevationList, object XSpacingList) { double ElevationList = {}; double Elevation = -1.25; for (int i = 0; i < XSpacingList.Count; ++i) { if (XSpacingList.Count <= 8 && XSpacingList.Count > 7) { Elevation = Elevation + Increment + MaxElevationList.Value(i); ElevationList.Add(Elevation); } if (XSpacingList.Count <= 9 && XSpacingList.Count > 8) { Elevation = Elevation + Increment + MaxElevationList.Value(i); ElevationList.Add(Elevation); } } return ElevationList; }
I did a quick check using the operation node to count each list I have for the MaxElevationList and the XSpacingList - both have a count of 244. I want to tack on the MaxElevationList value at the same location in the XSpacingList.
So, at count 1 in the XSpacingList it reads {0, 1.25, 2.5, 3.75, 5, 6.25, 7.5}. At count 1 for the MaxElevationList it reads {8.098}. I want the end product "ElevationList" to be {0, 1.25, 2.5, 3.75, 5, 6.25, 7.5, 8.098}
I've also tried:
function(int Start, double Increment, object MaxElevationList, object XSpacingList) { double ElevationList = {}; double Elevation = -1.25; for (int i = 0; i < XSpacingList.Count; ++i) { for (int j = 0; j <= 7; ++j) { Elevation = Elevation + Increment + MaxElevationList(j); ElevationList.Add(Elevation); } } return ElevationList; }
I just don't know how to get the 2nd loop to look at the values of the first loop count. I thought indroducing the j variable would be the values of the first count, but was wrong.
For the files I attached in the ZIP, I am using GC with OpenRoads. I included the GCT file hoping that if you had the references, it would be able to recreate the script. Let me know if there are other files I should provide if that helps.
it looks like you are on the right path with the i and j loops. there might be a better way to do though if you are just trying to append the max elevation to each of the elevation lists.
one thing that comes to mind is if your maxelevation list has only one value at each index you could read it by just using the i value. when you are referencing a index directly with GCscript you can use the [] brackets.
I would use MaxElevationList[i]
I will give the attached files a try again, unfortunately I am using OpenBuildings. i might be able to install OpenRoads.
sorry about all the typing errors, i have broken my collarbone and limited to one hand :)
makes work a lot harder and slower!
Thanks
I hope you have a speedy recovery! I appreciate all the guidance you've provided so far.
Your comment about the MaxElevationList[i] sounds exactly like what I am trying to do. I just can't figure it out. I keep finding myself asking why I am trying to recreate the list values (the XSpacingList) in this function, when I should be able to just read the values of XSpacingList, put them into a new list (ElevationList in this case) and append that list. I feel like I am going in circles...
EDIT: I found it:
function(int Start, double Increment, object XSpacingList, object MaxElevationList) { double ElevationList = {}; double Elevation = 0; for (int i = 0; i < XSpacingList.Count; ++i) { Elevation = (XSpacingList[i]); ElevationList.Add(Elevation); ElevationList[i].Add(MaxElevationList[i]); } return ElevationList; }
Resulting Point Array on Retaining Wall: