pyautocad inserting block and rotation

pyautocad inserting block and rotation

john_stimacH3EQQ
Enthusiast Enthusiast
575 Views
2 Replies
Message 1 of 3

pyautocad inserting block and rotation

john_stimacH3EQQ
Enthusiast
Enthusiast

I'm having some issues writing a script that inserts a block at a specific point and then rotates the block based on a reference angle captured earlier in the python script. Everything works pretty well, but the issue is that the blocks are coming in with additional rotation added to it. The python debug files do not show this behavior. The script is using the pyautocad InsertBlock function. Is there any significant differences between that function and the vla-InsertBlock AutoCAD ActiveX/COM interface command that could possibly be causing this? 


0 Likes
Accepted solutions (1)
576 Views
2 Replies
Replies (2)
Message 2 of 3

daniel_cadext
Advisor
Advisor
Accepted solution

model.InsertBlock and vla-InsertBlock should be the same, rotation is in radians

I’m currently not setup with pyautocad, using my wrappers which also use win32com, InsertBlock works as advertised

 

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

# creates a new command xdoit
def PyRxCmd_xdoit():
    try:
        axApp = Ax.getApp()
        path = "M:\\Dev\\Projects\\PyRxGit\\PySamples\\dwg\\18X36RP.dwg"
        
        x : Ge.Vector3d= Ge.Vector3d.kXAxis
        y : Ge.Vector3d= Ge.Vector3d.kYAxis
        z : Ge.Vector3d= Ge.Vector3d.kZAxis
        ref = axApp.ActiveDocument.ModelSpace.InsertBlock((0, 0, 0), path, 1, 1, 1,  x.angleTo(y,z))
    
    except Exception as err:
        traceback.print_exception(err)

 

com.png

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 3

john_stimacH3EQQ
Enthusiast
Enthusiast

knowing that they both insert in radians helped. Thanks

0 Likes