I am trying to place objects automatically along a corridor, which I have completed. I am also trying to number each object by giving it a name (1,2,3,4,5…). I’ve looked online but I can’t find anything that can help me. I am using Civil3D 2020.
What would be the best way to number the objects? How are the objects placed during the script? Can I give the object a name immediately after it is created?
It depends on the type of object. Is it an object that natively has a name property (e.g. pipe, structure, COGO point)? Or are you using something else to hold a name value, such as a block attribute or property set?
I’m currently using a block reference which does have a name but I don’t think I can change it.
I’ve seen a tutorial on using object data tables using the Civil3DToolkit package: Dynamo for Civil 3D creating Object Data Tables - YouTube. However, When I try to install the package on Civil3D 2020 I get an error where it failed to load the library. I am not sure if this is the best way to go about doing this.
You can, but I wouldn’t recommend going that route since block names have to be unique.
Since it’s not a Civil 3D object with a name property, your first step is to decide on a strategy for holding the name value. There are several options, but three commons ones are:
Block attribute
Property set
Object data
Since you are dealing with block references, my recommendation would be to create a ‘name’ attribute for the block and then assign a value to the attribute for each block reference.
That’s what I thought. Would it be better if I exploded the block and used the 3d solid instead? I was originally trying to use object data, but since I cannot get the Civil3DToolkit to work on this version of Civil3D, I will try using Property sets. Do you have any resources that would explain how to do this?
I may not be understanding your end goal properly, but this seems counterproductive. Are you using Dynamo to place the block references along the alignment? Some screenshots of your graph would be helpful.
Yes its placing a block reference. I guess I’m not understanding the difference between a dynamo object and a block reference. Is the block reference considered an object in dynamo? If it is then I should be able to give the whole block reference a data set.
The output from BlockReference.ByCoordinateSystem will be a list of Block References that have been added to model space. If the ‘Concrete Rail Tie’ source block has an attribute for the name, then you can set the attribute value in Dynamo like this:
That looks like it makes sense. Just a couple of questions:
I would have to set the attribute in my source block before running the dynamo script. I wouldn’t use dynamo to create the attribute.
Since my script is using the length of the alignment to decide how many blocks to place, is there a quick way to create a list entry for each block that was placed? Or would I have to write a code that creates one for each block and assigns a name?
Thanks for helping me out! It’s almost working! I just ran into an issue where my List.Count code block is eating up my whole list and just spitting out 1. I’ve attached a screenshot below. Other than that its been working great!
Ok That worked. Can you explain what flattening the list does?
For some reason my blocks are only getting placed with the name of the first item. Could this be because dynamo is placing all the blocks at the same time and just taking the first block name?
I can now upload my script if that helps troubleshoot it.