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?
Hi
attach Autocad drawing
Hi, here is DWG, thank you.
TestBlockObjectsByLayer.dwg (1.9 MB)
HI
your blocks
Does not contain lines
They are all POLYLINES
TRY
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])
1 Like