I have files that look like the image below, cogo points within polyline rectangles. The rectangles will be in different layers (represented by the different colors here), and I want the cogo points within each rectangle to share the same layer. This example is small but the files will be much larger, too large to do manually. Is this something that can be done in Dynamo? Any help appreciated.
Hi @V0rticity,
The key part of this problem is figuring out how to identify which polyline a point is contained within. There’s a couple of ways you can do it, and here’s a few ideas that utilize Dynamo geometry:
- Create Dynamo surfaces from the polyline curve geometry and then check every point against every surface to see if they intersect. If there’s an intersection, then you know that point is “inside” the polyline.
- Create Dynamo polygons from the polyline curve geometry and use the
Polygon.ContainmentTest
node to check every point and see if it is contained within the polygon.
Once you have that info, then the problem is basically solved and you can get the layers of the containing polylines and then set the layer for each point accordingly.
Here’s an example that illustrates #1. This is my preferred approach because it will work with any closed polyline, even if it contains arc segments. Approach #2 is somewhat limiting in that Dynamo polygons can only be composed of line segments.
Also, pay attention to the @L1 and @L2 list level settings on some of the nodes (highlighted). If this is a new concept, consider taking a look at the Dynamo Primer.
Hope it helps!
Looks like a good approach, but I have set up the script exactly and it is throwing some errors and does not run.
The first two Object.Geometry blocks give the error “Dereferencing a non-pointer”
surface.ByPatch gives “Object reference not set to instance of an object”
Geometry.DoesIntersect gives “Dereferencing a non-pointer”
List.GetItemAtIndex gives “Object reference not set to instance of an object”
The last two Object.Layer blocks give “Dereferencing a non-pointer”
What is your input?
I can’t see that you have added any point and polylines to your selection?
When I changed the first two blocks to user selection, everything works perfectly, but I think the issue is in how points and polylines are being called? Is it valid to just feed a code block into an object?
Zach probably used the code block to visualize the input for polylines and CoGopoint and then he wrote the description above the variabel.
I use code block a lot as a breakpoint when I forward result or inputs from one part of the graph in to next. Before 2023 this was a must have because we couldn’t create breakpoint on the spagetti that easy just nu hover over them.
If you create a code block and insert for example letter a you will se that it add a as a input the same way as it did when you wrote points.
Correct. Those are just visual placeholders because you can do the selection of objects in lots of different ways depending on your requirements. For example, you could get all the Cogo Points in a point group, or you could explicitly select specific points, or you could get the points in multiple groups and merge the list together. It all depends on your setup, but whatever the case, you still end up with a list of points that is used downstream in the graph.
Same thing for the polylines. You might select them by layer, or select specific objects. Whatever you choose, you still end up with a list of polylines.
What is a good way to automatically select all polyines and COGO points without having to select them manually? Those should be the only items in the files I am using
The same way as I did in your other thread.
Select by Object type or by Layer. Then filter by boolean mask if you have to.
Got it! putting it all together now. I still get this error on the last block but the output is correct.
What are the inputs to the node, and what are the results? Post a screenshot showing the previews of both.
I think it just might have been an error with the drawing I had, I cannot recreate it and it runs with no errors now. Output remains correct. Thanks
@patrick.ericson Trying to combine these two scripts into one, for some reason the second part is not working. I think maybe because the points on C-Node do not exist while the second operation is happening. Is there a way to add a time delay or dependency (do not start this second operation until the first completes)? I have attached my script and test file.
Point_Rectangle_test_Blocks.dwg (976.7 KB)
Blocks To COGO With Description and Poly Layer.dyn (194.3 KB)
I fixed an incorrect thread and added a pause but I still cannot get it to work. Looks like the all objects on layer “C-NODE” list is null.
Blocks To COGO With Description and Poly Layer_rev2.dyn (197.3 KB)
I also tried linking the points directly from the output of the cogopoints in the first script, this runs but the output is incorrect, all points are placed on the same layer.
Blocks To COGO With Description and Poly Layer_direct.dyn (191.6 KB)
Good work with the Graph!!
I did some investigation and actually only changed this node from Document.Blocks to Document.Modelspace
When it asks for block, normally it is the node Document.Modelspace that is the correct one
A tip is to select all nodes by click Cttl + A and then click Ctrl + L to make the graph clean
Also create Groups as in my example but you can also set different colors and add description
Blocks To COGO With Description and Poly Layer_direct (1).dyn (181.4 KB)
You’re a miracle worker. Thank you I thought I was close, and visually laying it out like that in groupings does help.
Glad to help, yes… miracle, no
But thanks for those words
One last thing I want to do to finish out this script is assign a unique number to each surface (starting at one and incrementing upwards), then also pass this info on to the COGO point. Since I already used description and layer, maybe I can just add this to the end of the description (so maybe the description would be " RE- North, 1 for a point in the first rectangle). I can’t think of another way to pass on this data, maybe a user defined property but I cant imagine that would be easy to implement. Probably would also like to plot this surface number in C3D model next to the rectangles so I can see which number is associated with what rectangle, but I suppose that is not as important because I can set the points to display that information.