Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to select multiple objects in a lisp script?

1 REPLY 1
Reply
Message 1 of 2
edushka228
131 Views, 1 Reply

How to select multiple objects in a lisp script?

(defun C:HHB (/ hatch pieces); = Hatch with Hatch Boundaries
  (setq hatch (car (entsel "\nSelect Hatch to use as Hatch bounaries: ")))
  (command
    "_.copy" hatch "" "0,0" "@"
    "_.explode" "_last"
  )
  (setq pieces (ssget "_P"))
  (initdia)
  (command-s "_.hatch"); allow completion of command, then:
  (command "_.erase" pieces "")
)

 

How can I modify the code so that I can select multiple hatches, apply the EXPLODE command to them to add a new hatch so that its islands are elements of those multiple hatches?

1 REPLY 1
Message 2 of 2
ec-cad
in reply to: edushka228

Sample of looping through a selection set. Untested., but may get you a little further.

(setq hatches (ssget "X" (list (cons 2 "HATCH"))))
; Returns something like: <Selection set: 3ad>
;
(sslength hatches)
; returns 3 for 3 hatches on this drawing

; and to loop through those hatches..

(if hatches
(progn
(setq c 0); first one in selection set
(repeat (sslength hatches)
(setq hatch (ssname hatches C)); single hatch from selection set
(command "_.copy" hatch "" "0,0" "@")
(command "_.explode" hatch)
(setq pieces (ssget "_P"))
(initdia)
(command-s "_.hatch"); allow completion of command, then:
(command "_.erase" pieces "")
(setq C (+ C 1)); increment index to selection set
); repeat
); progn
); if

 

ECCAD

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost