# Change line color to "by layer" in block in Civil 3D

**URL:** <https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780>\
**Category:** Civil 3D\
**Tags:** dynamo\
**Created:** [November 25, 2021, 9:03pm UTC](https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780 "2021-11-25T21:03:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drbohlav](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/drbohlav/32/113004_2.png) [@Drbohlav](https://forum.dynamobim.com/u/Drbohlav)\
**Post date:** [November 25, 2021, 9:03pm UTC](https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780/1 "2021-11-25T21:03:22Z")

</div>

Hi all, is it possible to change line color in all blocks so all block references in model space have this setting? I can’t see any node for this. Can anyone help with this?

---

<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:** [November 28, 2021, 6:17am UTC](https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780/2 "2021-11-28T06:17:07Z")

</div>

Hi  
attach Autocad drawing

---

<div class="post-metadata">

**Author:** ![Drbohlav](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/drbohlav/32/113004_2.png) [@Drbohlav](https://forum.dynamobim.com/u/Drbohlav)\
**Post date:** [November 29, 2021, 7:37am UTC](https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780/3 "2021-11-29T07:37:58Z")

</div>

Hi, here is DWG, thank you.

[TestBlockObjectsByLayer.dwg](https://forum.dynamobim.com/uploads/short-url/nKP3MOUfmfXjFaVCShCBb0pvbO0.dwg) (1.9 MB)

---

<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:** [November 29, 2021, 11:21am UTC](https://forum.dynamobim.com/t/change-line-color-to-by-layer-in-block-in-civil-3d/70780/4 "2021-11-29T11:21:02Z")

</div>

HI  
your blocks  
Does not contain lines  
They are all POLYLINES

TRY

```auto

import clr

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')

# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.GraphicsInterface import TextStyle

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor

# Example function
def set_ColorIndex(btrB):
	"""
	Sets the object color to ByLayer
	:returns: The list of objects in the drawing
	"""
	global adoc
	output = []
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
				btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
				for oid in btrB:
					obj = t.GetObject(oid.InternalObjectId, OpenMode.ForWrite)
					obj.ColorIndex = 256
					output.append("GOOD")
				t.Commit()
	return output

	
	
OUT = set_ColorIndex(IN[0])

```

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/6/76fcf7cb69c4b116506876137f2a4ca77b30a38b.jpeg)
