[SOLVED] How to name objects that have been automatically created

Hi,

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?

Thanks for the help.

Hi @_Jacob,

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?

1 Like

Hi,

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.

Thanks

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:

  1. Block attribute
  2. Property set
  3. 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.

1 Like

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.

1 Like

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.

Great, thanks. This is what I was thinking:

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:


2 Likes

That looks like it makes sense. Just a couple of questions:

  1. 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.

  2. 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?

Correct. Just open up the Block Editor and create the attribute.

Sure. Something like this?

2 Likes

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!

Thank you for all your help!

You can either flatten the list before using List.Count or change the level on the input. Here’s an example:

1 Like

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.

Placing Objects (Normal and Perp) with range.dyn (355.6 KB)

I figured it out. I still had my unflattened list connected to my SetAttributeByTag so it was only setting the first list item - MAIN-001.

Thanks for all your help!

Great!

This should help.
https://primer.dynamobim.org/06_Designing-with-Lists/6-3_lists-of-lists.html

Thanks again!

I’ll review that link you sent me