Set ACAD Object Color to ByLayer

Newest of new users.

Trying to set an individual selected AutoCad object colour to ‘ByLayer’ but I can’t seem to find the right combination of nodes. I’ve been able to select a specific set of objects, extract their colour index using the Camber ‘Object.ColorIndex’ node, but that’s about it.

I’ve also been able to hard code specific colours to the object(s) using the OTB ‘Object.SetColor’ node, but no apparent option for ‘ByLayer’ or colour index ‘256’ that I can find.

I also found a post from 2019 in which a Python code was presented to select all objects and set their colour to ByLayer, but that code is Python2 and the new engine is Python3, so I’m not sure how to use it or if it can be used anymore…and it’s not quite what I’m looking to do in my case with selected objects.

I’ve downloaded the Camber and Civil3DToolKit packages, I’m on the latest Civil 3D 2022.

Any help would be appreciated…even if it’s just telling me that it’s not possible…or at least not possible without Python (of which I know nothing).

Hi
any example
For a sketch and a dynamo file
Let’s try your idea

Too new a user. Don’t have the rights to post things yet. Regardless, I’m not sure I have much to post. My goal is to execute a two step process: select object, change object(s) colour to ‘ByLayer.’ I’ve tried a number of ideas and nodes, just can’t seem to find a way to do it.

Try this
It’s working

1 Like

Wow nice find, I forgot about the 256 color. I think you’re right that python is the only option at the moment for changing object color property.

With the help of many, many, many posts on the Dynamo Forum, I think I’ve been able to crack it.

Using two Camber nodes, Document.SendCommand and Object.Select I realised I could access the CHPROP command in ACAD. Then I could use the WaitFor/PassThrough code found in another post, to sequence the actions to:

  1. Set selected objects layer,
  2. Select objects within ACAD,
  3. Set selected objects colour property to ByLayer.

The final String node executes the CHPROP AutoCad command and then walks through the options as if you were typing in the command line. To exit the command requires an extra space at the end.

This seems to work, although it may not be the most elegant. Unless someone can spot any obvious flaw, I’ll mark this as Solved. This would also seem to allow other general object properties to be set, not just colour.

Special thanks to @mzjensen for the Camber nodes and all the posts!

(There should be a graph below with the node combination I used)

2 Likes

Nice work @JPhil! :clap:

One thought that might make it a little more simple. It seems like the “Select [Object] within ACAD” and the first passthrough code block may not be necessary? The Object.SetLayer node will return the objects passed into it (in this case, the list of Polylines), which can then be plugged in to the Object.Select node. So basically like this:

1 Like

Oh nice! I totally forgot that present from Camber!

@mzjensen, Interestingly, the set up you propose seems to prevent the objects from having their layers set.

It creates the new layer, sets object colours to ByLayer, but doesn’t set the objects to the new layer…even though that should happen before the object colours are set to ByLayer.

Graph below. I’ve left everything the same, but changed the connections and froze the un-used nodes.

I’m still super new, so maybe I’m missing some nuance, but I think I have to keep the layer operation completely separate from the object selection operation.

Interesting! Then I guess you were good to go the first time :wink:

I’ll take what I can get.

Thanks for the help!

FYI there is a dedicated node for this in Camber v3.0.0.

objectSetColor