Still need to work on installation and usage documentation.
There’s a small install readme on github, it’s a slight pain to install currently, you must install Python and wxPython yourself before installing the bundle. I hope to make it an all in one.
currently, it’s for more experienced users, or at least slightly familiar with. ARX and .NET APIs. Though you can run pyautoacad, but there’s no main, so you would need to run the code from a command context
using a sample from pyautoacad, PyRxCmd_ defines a command, similar to what ‘defun c:pyautoacad’ would do.
PyRxCmd_pyrx is more verbose, more like what you would find in ARX or .NET. I.e. having to open objects for read/write
Running pyautoacad from a command context is orders or magnitude faster because I’ve embedded CPython into an ARX module.
import PyRx as Rx
import PyGe as Ge
import PyGi as Gi
import PyDb as Db
import PyAp as Ap
import PyEd as Ed
import traceback
from pyautocad import Autocad, APoint
#pyautoacad from a command context
def PyRxCmd_pyautoacad():
try:
acad = Autocad()
acad.prompt("Hello, Autocad from Python\n")
print(acad.doc.Name)
p1 = APoint(0, 0)
p2 = APoint(50, 25)
for i in range(5):
text = acad.model.AddText('Hi %s!' % i, p1, 2.5)
acad.model.AddLine(p1, p2)
acad.model.AddCircle(p1, 10)
p1.y += 10
except Exception as err:
traceback.print_exception(err)
def PyRxCmd_pyrx():
try:
#calls acutPrintf
print("Hello, Autocad from Python\n")
#db = Db.curDb() or
db = Db.HostApplicationServices().workingDatabase()
model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
p1 = Ge.Point3d(0,0,0)
p2 = Ge.Point3d(50,25,0)
#move to the right so we don't overlap pyautoacad
p1 += (Ge.Vector3d.kXAxis * 100)
p2 += (Ge.Vector3d.kXAxis * 100)
for i in range(5):
mt = Db.MText()
mt.setLocation(p1)
mt.setContents('PyHi %s!' % i)
mt.setTextHeight(2.5)
model.appendAcDbEntity(mt)
line = Db.Line(p1, p2)
model.appendAcDbEntity(line)
circle = Db.Circle(p1,Ge.Vector3d.kZAxis, 10)
model.appendAcDbEntity(circle)
p1.y += 10
except Exception as err:
traceback.print_exception(err)
.

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx