Placing block reference using current block reference points in Civil 3D using Dynamo and python

Hi @tpitera,

I went ahead and put something together for you without seeing the video. This script will create a TIN surface from the contours, and then it will insert the test_block at the corners of the panel block references. I also put in an option to scale the test_block if you want (it looked really big).

A couple notes:

  • You’ll need to first create an empty TIN surface in the drawing before running the script (Dynamo needs a surface to add the breaklines to). The input name is set to “Surface - (1)”, but you can name it whatever you want and just change the input string.

  • You’ll need to change the file path input node for the block insertion so that it points to the testBlockRef.dwg file on your system.

  • I edited the test_block so that the insertion point was at the lower left corner of the rectangle. This made it easier to insert.

I’ve annotated everything pretty heavily so that you know what is going on, but let me know if you have questions.

This isn’t intended to be the final solution for you, put hopefully it gives you a starting point.

mytestscript_mzjensen.dyn (467.4 KB)

I will try to get you the video today since you seem to be the only person willing to help me :frowning:
Thank you for your help thus far
I checked your insertion points, looks fine
I got some errors when running your dynamo
image image
Also keep in mind i do need the surface and the test block ref to show up in my civil dwg
Due to errors i cant confirm the surface or if test block references placed well

Please try to upload the images again, they are so small that it’s impossible to tell what the errors are. There is an upload button when composing a post.

I don’t think willingness is the issue - there are a lot of people on here that want to help with Dynamo. If fact, I would say that it’s out of sheer willingness that most people are here. Hardly anyone is getting paid to help out.

I think you will get more hits if you break the problem down into bite-sized posts, like “Import Block to New DWG” or “Add Breaklines to TIN Surface”. Right now this post is focused on the entire workflow, which is pretty big for anyone to tackle.

here you go, is that better?
Error1 Error2

Much better! The surface error is probably either that you don’t have a surface in the drawing, or it isn’t getting the contours correctly. Did you do this step?

Not sure on the second error. There is probably an upstream node that is returning nulls. Find which node that is first.

lets just focus on block reference placement.
regarding my block placement lets try a new procedure
this is considered a row of reference blocks. i removed all other lines and pretty much made it a square

i think we get the left and right corner of each block from BoundingBox.MaxPoint and BoundingBox.MinPoint then measure the total length of the row

block import from another dwg (getting errors when trying this) image

Place block at left most point of the row image

the next block is exactly .5 ft from the other yellow block

place until best fit to given row
sometimes the given row (blue) will be off like this, we want best fit therefore if more than half of our yellow block is extended past, add a yellow block
Any thoughts on this? its a bit different than our previous approach that i thought may make it easier

This sounds good.

Please show the error so it can be diagnosed.

Get the coordinate system of the first block reference in the row. Since you know the length of the yellow block, then it’s just a math exercise to generate a sequence of insertion points along the coordinate system’s X axis (i.e. length of blue block + 0.5 feet).

alright I am almost there! Im struggling on the creating lists based off the math exercise
i am doing math comparing a left bottom point of one block ref to the next left bottom point of the next block. I perform the following tests:
check if same height, check if the x point of the next block reference in the same row
I tied these into a bool (true = same row, false = new row)
i put that into an if block. When true, I want to save the x, then run the test on the next point
if true, repeat, if false, get x of this point + a value (width)
so for ex: point (0,0) at position 0 in list and (1,0) at position 1 in list are compared, bool test = false (not same row), therefore output (0,0) as point 1 and (0 + width,0) as point 2 in format
0 List
0: 0,0
1: 0+width, 0
In the other case: point (0,0) and point (2,0), bool test = pass (same row)
point (2,0) and point (3,0), bool test fail, therefore output (0,0) as point 1 and (2+width, 0) and it now adds to list like so
0 List
0: 0,0
1: 0+width, 0
1 List
0: 0,0
1: 2+width, 0

I believe doing it this way will then allow me to take the distance between the two x points no matter how long the row. Any help would be appreciated