Setting ByLayer/ByBlock to blocks/blockrefs
For people interested in setting all blocks to ByLayer and all blockrefs to ByLayer at once I scripted as below with the help of PyRx.
import traceback
from pyrx_imp import Ap, Db print("added command = blockref2byblock") @Ap.Command()
def blockref2byblock():
try:
db = Db.curDb()
clr = Db.Color() # Setting blocks to ByBlock clr.setColorIndex(0) bt = Db.BlockTable(db.blockTableId()) for btrid in bt.toDict().values(): btr = Db.BlockTableRecord(btrid) if btr.isLayout() or btr.isFromExternalReference(): continue for id in btr.objectIds(): Db.Entity(id, Db.OpenMode.kForWrite).setColor(clr) print("Set block colors to isByBlock", clr.isByBlock()) # Setting blockrefs to ByLayer clr.setColorIndex(256) for id in db.objectIds(Db.BlockReference.desc()): Db.Entity(id, Db.OpenMode.kForWrite).setColor(clr) print("Set blockref colors to isByLayer", clr.isByLayer()) except Exception as err: traceback.print_exception(err)
1
Comments
-
A good idea providing Python functions maybe do a word Doc with descriptions of your Python functions and save those into a ZIP file. I have a word doc for some of my lisps, no code just a description.
Cadtutor has a section called downloads so can save files there for downloading would be good here also.
0 -
Another is this for lisp CAD ←→ Excel which has many functions in it, a Python version would be good.
0