Author Topic: NEED Help Automating  (Read 1432 times)

0 Members and 1 Guest are viewing this topic.

lispman21

  • Guest
NEED Help Automating
« on: August 01, 2006, 02:25:08 PM »
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: [Select]
(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)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: NEED Help Automating
« Reply #1 on: August 01, 2006, 02:39:34 PM »
ssget returns a selection set not a list.

Code: [Select]
(if (setq lstSelection (ssget "X" '((0 . "ELLIPSE"))))
   (progn
        (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (el2p ename)
       )
    )
 )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

lispman21

  • Guest
Re: NEED Help Automating
« Reply #2 on: August 01, 2006, 02:49:19 PM »
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

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: NEED Help Automating
« Reply #3 on: August 01, 2006, 06:07:18 PM »
Yes, I didn't test it.
And you are welcome.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.