# Set ACAD Object Color to ByLayer

**URL:** <https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916>\
**Category:** Civil 3D\
**Created:** [February 3, 2022, 3:57am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916 "2022-02-03T03:57:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPhil](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JPhil](https://forum.dynamobim.com/u/JPhil)\
**Post date:** [February 3, 2022, 3:57am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/1 "2022-02-03T03:57:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hosneyalaa](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/hosneyalaa/32/100865_2.png) [@hosneyalaa](https://forum.dynamobim.com/u/hosneyalaa)\
**Post date:** [February 3, 2022, 6:20am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/2 "2022-02-03T06:20:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JPhil](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JPhil](https://forum.dynamobim.com/u/JPhil)\
**Post date:** [February 3, 2022, 6:00pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/3 "2022-02-03T18:00:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hosneyalaa](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/hosneyalaa/32/100865_2.png) [@hosneyalaa](https://forum.dynamobim.com/u/hosneyalaa)\
**Post date:** [February 3, 2022, 6:19pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/4 "2022-02-03T18:19:44Z")

</div>

Try this  
It’s working

> [@CAD Linetype & color by layer](https://forum.dynamobim.com/t/cad-linetype-color-by-layer/43664/5):
>
> @csanchez you need to set the ColorIndex property to 256 and Linetype to ‘ByLayer’ for all the entities

---

<div class="post-metadata">

**Author:** ![KirkWM](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kirkwm/32/104406_2.png) [@KirkWM](https://forum.dynamobim.com/u/KirkWM)\
**Post date:** [February 3, 2022, 6:33pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/5 "2022-02-03T18:33:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JPhil](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JPhil](https://forum.dynamobim.com/u/JPhil)\
**Post date:** [February 7, 2022, 10:04pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/6 "2022-02-07T22:04:24Z")

</div>

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 @zachri.jensen for the Camber nodes and all the posts!

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

 ![ObjectByLayer](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/7/270314786068ff87fb46513f1a5e718e6828e78c.png)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [February 7, 2022, 10:32pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/7 "2022-02-07T22:32:27Z")

</div>

Nice work @JPhil! 👏

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:

 ![ByLayer](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/230d8da33f9009e8361d9931e6d724ade424d7e6.png)

---

<div class="post-metadata">

**Author:** ![KirkWM](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kirkwm/32/104406_2.png) [@KirkWM](https://forum.dynamobim.com/u/KirkWM)\
**Post date:** [February 7, 2022, 11:01pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/8 "2022-02-07T23:01:58Z")

</div>

Oh nice! I totally forgot that present from Camber!

---

<div class="post-metadata">

**Author:** ![JPhil](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JPhil](https://forum.dynamobim.com/u/JPhil)\
**Post date:** [February 8, 2022, 3:16am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/9 "2022-02-08T03:16:08Z")

</div>

@zachri.jensen, 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.

 ![ObjectByLayer02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4b1c312cf021c068deee32fcce0ef983c93a1662.png)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [February 8, 2022, 3:54am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/10 "2022-02-08T03:54:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JPhil](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JPhil](https://forum.dynamobim.com/u/JPhil)\
**Post date:** [February 8, 2022, 4:16am UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/11 "2022-02-08T04:16:35Z")

</div>

I’ll take what I can get.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [April 19, 2022, 3:32pm UTC](https://forum.dynamobim.com/t/set-acad-object-color-to-bylayer/72916/12 "2022-04-19T15:32:39Z")

</div>

FYI there is a dedicated node for this in Camber [v3.0.0](https://github.com/mzjensen/Camber/releases/tag/v3.0.0).

 ![objectSetColor](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/7/77f1151c0fd2b6f460de4c7162b1517c103c1e91.png)
