pythonautocad

Using pyautocad, how do i change mesh properties(color)


In pyautocad, I created a cube using a 3d mesh and matrix but I can't figure out how to change the mesh's color.

manually changing mesh color(https://i.sstatic.net/xRoyH.png)

Tried looking for module methods to change color but couldn't find anything.


Solution

  • Normally you would want to assign the object to a layer, Then set the layer to a color But you can set the color directly to the entity Not pyautocad per se, this is using win32com

    import traceback
    from pyrx_impx import Rx, Ge, Gi, Db, Ap, Ed, Ax
    
    def PyRxCmd_doit() -> None:
        try:
            axApp = Ax.getApp()
            axDoc = axApp.ActiveDocument
            Ax.IAcadEntity
        
            # (IAcadEntity, Point)
            axEntRes = axDoc.Utility.GetEntity("Pick an it")
            axEnt: Ax.IAcadEntity= axEntRes[0]
        
            # color index red
            axEnt.color = 1
        
            # TrueColor green
            acColor = Ax.AcadAcCmColor()
            acColor.SetRGB(34,139,34)
            axEnt.TrueColor = acColor
        
        except Exception as err:
            traceback.print_exception(err)