Saturday, February 24, 2024

How to make a Revcloud in Python for AutoCAD

 

There isn’t a “revcloud” entity type in Autocad, but you can make one with a polyline and enlisting the help of send command.  Here’s the sample code

 

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


@Ap.Command()
def myrevcloud() -> None:
    try:
        axApp = Ap.Application.acadApplication()
        doc = axApp.activeDocument()
        ms = doc.modelSpace()

        # coords for the cloud and create a polyline
        coords = [
            Ge.Point3d(0, 0, 0),
            Ge.Point3d(0, 1000, 0),
            Ge.Point3d(1000, 1000, 0),
            Ge.Point3d(1000, 0, 0),
            Ge.Point3d(0, 0, 0),
        ]
        pl = ms.addPolyline(coords)

        # use send command to create the revcloud, note the (A)arc length
        handle = '(handent "{}")'.format(pl.handle())
        doc.sendCommand("revcloud A {} Object {} Y ".format(200, handle))
    except Exception as err:
        traceback.print_exception(err)


 

And the result:

 


TraceBoundary sample in Python for AutoCAD

    import traceback from pyrx import Ap , Db , Ed , Ge , Gi @ Ap . Command () def TB () -> None :     try :         db = Db . curD...