Jump to content

Recommended Posts

Posted

im a lisp noob to start, what i have is a lisp where i have to select lines 1 at a time, and it sounds like i can use ssget to make the selection a lot easier. My friend helped me put this together and was unsure about how to use ssget. Any help would be much appreciated! Thanks

 

 
(defun c:DVD (/ ssete CNT)
 (command "_.undo" "_begin")
 ;;- Pick an existing line
 (setq CNT T);Simple on/off toggle for while loop
 (while CNT
   (if (setq PICKLINE (entsel "\nSelect Lines To Divide"))
     (COND ((not ssete);List does not already exist, create new lists.
             (setq ssete (cons (car PICKLINE) ssete))
           );end cond
         ((and ssete (not (member (car PICKLINE) ssete)));Lists exists, check if object already exists in the entity list
           (setq ssete (cons (car PICKLINE) ssete));add entity name to entity list
         );end cond
        (t (princ "\nObject previously selected."));If object already exists in the list,
     );end COND~
    ;|else|;(if (= (strcase (getstring "Selection Complete?. Exit? (Y/N) <N>:")) "Y")
       ;|then|;(setq CNT nil);No object selected, set CNT=nil to drop out of while
     );end if
   );if
 );while
(setq ssete (reverse ssete))

(setq SSLEN (length ssete));how many in the list?
(setq CNT 0);set initial counter value
(while (/= (setq PICKEDLINE (nth CNT ssete)) nil)
  (command "Divide" PICKEDLINE "10")
    (command "Erase" PICKEDLINE "")

   (setq CNT (1+ CNT))
);end while
 (command "_.undo" "_end")
 (princ)
 );end defun 3P

Posted

Try this:

 

(defun c:dvd (/ e n ss)
 (setq n -1)
 (if (setq ss (ssget ":L" '((0 . "LINE"))))
   (while (setq e (ssname ss (setq n (1+ n))))
     (command "_Divide" e "10")
     (entdel e)
   )
 )
 (princ)
)

Posted

Well, I already coded it, so I'll post it anyway. :)

 

(defun c:DVD (/ SS Index Ent)
 (cond
   ((setq SS (ssget "_:L" '((0 . "LINE,LWPOLYLINE,ARC,CIRCLE"))))
    (command "_.undo" "_begin")
    (setq Index -1)
    (while (setq Ent (ssname SS (setq Index (1+ Index))))
      (command "_.divide" Ent 10)
      (entdel Ent)
    ) ;_ while
    (command "_.undo" "_end")
   )
 ) ;_ cond
 (princ)
) ;_ defun

Posted

LoL

We wrote them virtually the same way.

Posted
LoL

We wrote them virtually the same way.

 

8) Good you put the undo points in there :)

Posted
8) Good you put the undo points in there :)

:)

I actually stole this method from you a while back:

(while (setq Ent (ssname SS (setq Index (1+ Index))))

Posted
:)

I actually stole this method from you a while back:

(while (setq Ent (ssname SS (setq Index (1+ Index))))

 

Thief!!!! :D j/k...I've stolen\borrowed my fair share too.o:)

Posted

wow that sure shortens the code up a lot lol, thanks a lot guys !!

Posted
Thief!!!! :D j/k...I've stolen\borrowed my fair share too.o:)

:) What better way to advance yourself. LoL

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...