Code Red > AutoLISP (Vanilla / Visual)

NEED Help Automating

(1/1)

lispman21:
Trying to get this code to automate the selection of all ellipses instead of user secting ellipses.  The program isn't selecting ellipses it says ther eis an error in the selection set.


Here's the code:

--- Code: ---(defun e2p ()
 (if (setq lstSelection (ssget "X" '((0 . "ELLIPSE"))))
  (el2p (car lstSelection))
 )
 (princ)
)
(defun El2p (objEllipse)
 (if (= (type objEllipse) 'ENAME)
  (setq objEllipse (vlax-ename->vla-object objEllipse)))
 (setq sngIncrement (/ (vlax-curve-getdistatparam objEllipse (vlax-curve-getendparam objEllipse)) 100.0)
       sngPosition 0.0
 )
 (command "ortho" "off" "pline")
 (repeat 101
  (command (vlax-curve-getpointatdist objEllipse sngPosition))
  (setq sngPosition (+ sngPosition sngIncrement))
 )
 (command "")
 (vla-delete objEllipse)
 (princ)
)
--- End code ---

CAB:
ssget returns a selection set not a list.


--- Code: --- (if (setq lstSelection (ssget "X" '((0 . "ELLIPSE"))))
   (progn
        (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (el2p ename)
       )
    )
 )
--- End code ---

lispman21:
Had to make a change but after the change it works perfect.


(if (setq lstSelection (ssget "X" '((0 . "ELLIPSE"))))
   (progn
        (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (el2p ename)
       )
    )
 )


Changed the highlighted section to lstselection

CAB:
Yes, I didn't test it.
And you are welcome.

Navigation

[0] Message Index

Go to full version