Jump to content

Recommended Posts

Posted

I think : )

 

Perfect for people that are more familiar with the ActiveX side of things, or don’t want to worry about open close state.
One difference between PyRx and VBA is that Points and Vectors evaluate to AcGePoint3d, AcGeVector3d, AcGeMatrix3d etc.

 

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


@command
def doitx1():
    axApp = Ap.Application.acadApplication()
    axDoc = axApp.activeDocument()
    axUtil = axDoc.utility()
    print(axUtil.getSubEntity("\nPick: "))


@command
def doitx2():
    axApp = Ap.Application.acadApplication()
    axDoc = axApp.activeDocument()
    for axEnt in axDoc.modelSpace():
        axEnt.setLayer("0")


@command
def doitx3():
    axApp = Ap.Application.acadApplication()
    axDoc = axApp.activeDocument()
    axModel = axDoc.modelSpace()
    axCircle = axModel.addCircle(Ge.Point3d(0, 0, 0), 10)
    axCircle.setTrueColor(Ax.AcadAcCmColor(255, 0, 0))


@command
def doitx4():
    try:
        axApp = Ap.Application.acadApplication()
        acDoc = axApp.activeDocument()
        axSets = acDoc.selectionSets()
        axSet = axSets.add("PYRX")
        axSet.selectOnScreen([(0, "INSERT")])

        for axEnt in axSet:
            axRef = Ax.AcadBlockReference.cast(axEnt)
            if axRef.isDynamicBlock():
                for prop in axRef.dynamicBlockProperties():
                    print(prop.value(), prop.propertyName(), prop.allowedValues())
    finally:
        axSet.delete()


# batch
@command
def doitx5():
    paths = [
        "M:\\Dev\\Projects\\PyRxGit\\unitTests\\testmedia\\06457.dwg",
        "M:\\Dev\\Projects\\PyRxGit\\unitTests\\testmedia\\dynamicBlock.dwg",
    ]

    for path in paths:
        databaseOper(path, doSomething)


# scope
def databaseOper(path, func):
    sideDb = Db.Database(False, True)
    sideDb.readDwgFile(path)
    sideDb.closeInput(True)
    func(sideDb)
    # sideDb.saveAs(path)


def doSomething(sideDb: Db.Database):
    allEntNames = set()
    axDb = sideDb.acadDatabase()
    for axEnt in axDb.modelSpace():
        allEntNames.add(axEnt.entityName())
    print(allEntNames)

 

Posted

Oh selection set filters, result buffers, xdata etc, are a collection of tuples

the same as the ARX side

 

        ((0, "INSERT"))  # tuple of tuples int dxf , value
        [(0, "INSERT")]  # list of tuples  int dxf , value
        [(Db.DxfCode.kDxfStart, "INSERT")]  # list of tuples DxfCode , value

 

 

 

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