Hi, I am new to Lisp. That's why I met a lot of struggle doing very simple tasks. So please forgive my dummy questions.
Im trying to create a lisp, that do several executions (in a loop) like these things below:
1. Select an area in the drawings. (always select this area in any turn of the loop)
2. Make a copy of the area in the certain position (this position every loop) . Select the copy.
3. Adjust the copy with datas (datas are different each loop) (the reason I have to do stage 1 because the copy is changed and is unadjustable after edited)
4. Save dwg file with another name.
5. Delete the copy. End a turn. Come back to 1.
Thanks to google, I have dealed with 3 and 4 though it takes me a lot of time. But I still struggled with 1 and 2 and 5. So if you have any idea to do that, please give me a hand. Thanks a lot.
Solved! Go to Solution.
Solved by stevor. Go to Solution.
Solved by hmsilva. Go to Solution.
Hi Huy_Cao
as a starting point
1 - Creates a selection set by window, giving two points...
(setq ss (ssget "_W" '(0.0 0.0 0.0) '(100.0 100.0 0.0)))
2 - starts a new selection set (empty) and set the last object to the variable obj, copy the select objects and add the new objects to the previously empty selection set
(setq ss1 (ssadd) obj (entlast) ) (command "_.copy" ss "" '(0.0 0.0 0.0) '(200.0 0.0 0.0)) (while (setq obj (entnext obj)) (ssadd obj ss1) )
5. Delete the copy
(command "_.erase" ss1 "")
To create the loop, you can use a 'repeat' or a 'while' function...
HTH
Henrique
This is a function I use on a daily basis; it should get you the information you need...
(defun c:CTC (/ ss) ;; Copy selected object(s) to current layer ;; Alan J. Thompson (if (setq ss (ssget "_:L")) ((lambda (layer) (vlax-for x (setq ss (vla-get-activeselectionset (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object) ) ) ) ) ) ) (vla-put-layer (vla-copy x) layer) ) (vla-delete ss) ) (getvar 'clayer) ) ) (princ) )
(vl-load-com)
(princ)
And, before you change anything,
you might use the command UNDO MARK,
to set the begining of the undo seseries.
And after the changes made and the dwg saved to a filename,
use UNDO BACK, to return to that dwg state.