I want to draw about 1000 shapes of two circles with tangents using this lisp file, which draws one shape a time.
I wrote a script to draw all shapes (see below), however it waits after the first argument for the next argument although it is there in the script.
Could you please guide me how to fix my script or how to edit the lisp file so that I can draw all shapes without interactive input?
Here is my current Script:
ctan
0,0,0
5
0,10,0
10
The issue is that evaluation of both the Script & AutoLISP function occurs in the same processor thread, and therefore when you evaluate the AutoLISP function from within the Script file, the AutoLISP function takes focus away from the Script, and the remainder of the Script file will be evaluated after the AutoLISP function has completed its evaluation.
To solve this, I would suggest defining a separate AutoLISP function which accepts four arguments corresponding to the centers & radii of each circle, and which constructs the 2D LWPolyline in the same manner as that of my Circle Tangents application.
You can then either evaluate such function from your Script file (perhaps on multiple drawings if required), or evaluate the function from within another AutoLISP program.
Such a function might be:
(defun ctan ( c1 r1 c2 r2 / d1 d2 a1 a2 zv )
(if (< (abs (setq d1 (- r1 r2))) (setq d2 (distance c1 c2)))
(progn
(setq a1 (atan (sqrt (- (* d2 d2) (* d1 d1))) d1)
a2 (angle c1 c2)
zv (trans '(0.0 0.0 1.0) 1 0 t)
)
(entmake
(list
'(000 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(090 . 04)
'(070 . 01)
(cons 010 (trans (polar c1 (+ a1 a2) r1) 1 zv))
(cons 042 (/ (sin (/ (- pi a1) 2.0)) (cos (/ (- pi a1) 2.0))))
(cons 010 (trans (polar c1 (- a2 a1) r1) 1 zv))
(cons 010 (trans (polar c2 (- a2 a1) r2) 1 zv))
(cons 042 (/ (sin (/ a1 2.0)) (cos (/ a1 2.0))))
(cons 010 (trans (polar c2 (+ a1 a2) r2) 1 zv))
(cons 210 zv)
)
)
)
)
)
Which, when loaded, you could call from your Script or another AutoLISP program using:
(ctan '(0 0 0) 5 '(0 10 0) 10)