I've the following AutoLISP code
(defun graph ( pts sls tls )
( (lambda ( l )
(foreach x l (text (cdr x) (itoa (car x)) 0.0 1))
(mapcar
'(lambda ( a b / p q r )
(setq p (cdr (assoc a l))
q (cdr (assoc b l))
r (angle p q)
)
(entmake (list '(0 . "LINE") (cons 10 p) (cons 11 q) '(62 . 8)))
(text
(mapcar '(lambda ( x y ) (/ (+ x y) 2.0)) p q)
(rtos (distance p q) 2)
(if (and (< (* pi 0.5) r) (<= r (* pi 1.5))) (+ r pi) r)
2
)
)
sls tls
)
)
(mapcar 'cons (vl-sort (append sls tls) '<) pts)
)
)
(defun text ( p s a c )
(entmake
(list
'(0 . "TEXT")
(cons 10 p)
(cons 11 p)
(cons 50 a)
(cons 01 s)
(cons 62 c)
'(40 . 2)
'(72 . 1)
'(73 . 2)
)
)
)
and the input is
(graph
'((75 25) (115 45) (90 60) (10 5) (45 0) (45 55) (0 25))
'(1 1 1 1 2 2 3 4 4 5 6)
'(2 3 4 5 3 6 6 5 7 7 7)
)
The 2D geometry created from the above is exported as a dxf file from AutoCAD.
The actual input is generated in Python
pts = [(75, 25), (115, 45), (90, 60), (10, 5), (45, 0), (45, 55), (0, 25)]
sls = [1 1 1 1 2 2 3 4 4 5 6]
tls = [2 3 4 5 3 6 6 5 7 7 7]
I would like to know how to use the python data types as input and directly interface with AutoCAD from Python, save the AutoCAD output as a dxf file.
EDIT: I've installed pyautocad in Python and did
from pyautocad import Autocad, APoint
Now I am not sure how to evaluate these AutoCAD expressions in Python. For instance, the inputs are Python tuples
Should I convert each tuple to AutoCAD point using
p = APoint(x, y)
And I am not sure how to proceed from here after generating the input data as autocad points. It's not clear to me how the commands in function
defun graph ( pts sls tls )
Any suggestions will be greatly useful