Centre point of rectangular set of polylines in C3D

I have a set of “areas” in C3D where I want to place objects (this will be a second step). To be able to do that, I need to know a point of reference in these areas and am trying to export the coordinates of their centres (x,y,z or latidute, longitude, elevation) to an Excel file.

Any suggestions on how to get this done? I am totally new in Dynamo and have looked at dozens of tutorials but nobody seems to address this.

Many thanks in advance!

Object.Geometry > Polycurve.ByJoinedCurves (if needed) > Surface.ByPatch > Surface.PointAtParameter with parameter values of 0.5,0.5.

You could also pull the points themselves and take the average, but that wouldn’t necessarily equate the ‘middle’ of an asymmetrical polygon.


Thank you very much, @jacob.small!

However… I might be newer to Dynamo than expected…

The error message says:

Warning: Your inputs lie outside of the allowable modeling range, consider choosing the Large setting with a modeling range between 0.01 and 1,000,000 from the “Settings => Geometry Working Range” dialog

Many thanks!

You can ignore that warning - it’s letting you know that the geometry Dynamo is calculating is greater than it was configured for.

If you really want to avoid the warnings you can shift everything closer to your internal origin point (either in AutoCAD or in Dynamo by using vectors and inverting). Alternatively you could combine all of these items into a single function (remove all the inputs other than the 0.5 values you have in the code block and wire them into a Function.Compose node in a matching sequence), and then send that into use a Function.Apply node as the function, and the list of objects as the object.

Both of these solutions are more advanced than ignoring the warning for now, and may introduce other issues which wouldn’t be seen (ie: passing the Function would suppress any issues with pulling the geometry of the object, building the polycurve, making the surface, or pulling the point…).

1 Like

Many thanks again, @jacob.small! It is a big leap moving from Fortran thinking to Dynamo thinking but I’ll get there.

I’ll remember the KISS principle and will keep it simple for now.

Many thanks once more! It is really appreciated!

1 Like

Going a step further, if you wanted to say place a block at that location… there is a BlockReference.ByCoordinateSystem node, which means you may want to use a Surface.CoordinateSystemAtParamter node instead of a Surface.PointAtParameter node.

Don’t forget to mark solutions so the next person with a question like yours can find good info faster!

I believe I ran into a problem - please see the messages I got from your solution that led to a “null” output fromt he last block (I am sure it is me, not you!):

  1. Warning: PolyCurve.ByJoinedCurves operation failed.
    Curve join produced more than one WIRE in PolyCurve

  2. Warning: Surface.ByPatch operation failed.
    Object reference not set to an instance of an object.

  3. Warning: Internal error, please report: Dereferencing a non-pointer.

I’ll post what I was trying to do below because I cannot post 2 screenshots.

The “error” in the Data.Exported block is:

Warning: Data.ExportExcel expects argument type(s) (string, string, int, int, var, bool), but was called with (System.IO.FileInfo, string, int, int, Autodesk.DesignScript.Geometry.Curve, bool).

Can you post the DWG with just those few rectangles as well? I’ll pop into this later tonight as it may require the translation thing I mentioned before.

Please find the file attached.

Please notice that what I am trying to achieve is a 2-step automation of a process.

1st: I want to extract coordinates from 2D/3D (x,y,z) from DWGs and save them in XLS (they migh be useful in this format); and

2nd: I want to read those coordinates and replace them by blocks (I already managed to find a solution for this step).

In the present case, a “planner” gave me the places where cable reels will be provisionally stored and I wish to place the 3D models there using Dynamo so I don’t have to move them every time the reels move place.

I hope this makes sense.

Reels Test.dwg (531.0 KB)

1 Like

You are feeding a File instead of a FilePath.
The node expects a string (FilePath) but got a File.

You don’t need the File from Path node.

Indeed! Thank you!

It worked but not exactly what I was hoping for though:

Each cell has the content below “type”:

Curve(StartPoint = Point(X = 270300.877, Y = 293282.151, Z = 0.000), EndPoint = Point(X = 270300.576, Y = 293283.312, Z = 0.000))

Which I reckon is sort of obvious, considering what I asked the script to do, but I really want the values in the cells.

The spreadsheet has the start and end points of each of the 4 lines that make the 80 rectangles (4 columns by 80 rows).

I believe the solution from @jacob.small will suit my needs better than mine…

If you want the X,Y and Z-Values of those start- and endpoints you’ll have to extract them by using the StartPoint/ EndPoint nodes together with the Point.X, Point.Y and Point.Z nodes.

1 Like

Thank you, @Daan!

I’ll look into it.