Jump to content

Recommended Posts

Posted

did not want to infect the lisp thread 😄

 

from pyrx import Rx, Ge, Gi, Db, Ap, Ed, Ax
import traceback


def exploder(btrid: Db.ObjectId):
    btr = Db.BlockTableRecord(btrid, Db.OpenMode.kForWrite)
    for _id in btr.objectIds():
        dbent = Db.Entity(_id, Db.OpenMode.kForWrite)
        try:
            btr.appendAcDbEntities(dbent.explode())
            dbent.erase()
        except:
            pass  # eNotApplicable for explode


def purge(db: Db.Database, ids):
    for _id in db.purge(ids):
        dbo = Db.DbObject(_id, Db.OpenMode.kForWrite)
        dbo.erase()


def setProps(db: Db.Database, btrids: list[Db.ObjectId]):
    for btrid in btrids:
        btr = Db.BlockTableRecord(btrid)
        for _id in btr.objectIds():
            dbent = Db.Entity(_id, Db.OpenMode.kForWrite)
            dbent.setColorIndex(0)
            dbent.setLinetype("Continuous")
            if _id.isDerivedFrom(Db.Text.desc()):
                dbt = Db.Text.cast(dbent)
                dbt.setTextStyle(db.textstyle())
            if _id.isDerivedFrom(Db.MText.desc()):
                dbmt = Db.MText.cast(dbent)
                dbmt.setTextStyle(db.textstyle())


@Ap.Command()
def doit():
    try:
        btrids = []
        db = Db.curDb()
        bt = Db.BlockTable(db.blockTableId())
        for _name, _id in bt.toDict().items():
            btrids.append(_id)
            if "*" in _name:
                continue
            exploder(_id)

        setProps(db, btrids)
        purge(db, btrids)
        db.saveAs("E:\\temp\\mrclean.dwg")

    except Exception as err:
        traceback.print_exception(err)

 

mrclean.dwg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...