Hello all.
I wonder if I have to check if the "ssget" is empty.
I have a lisp to zoom extents in visible objects on the screen.
My interest is to filter before applying:If I have selected objects, it zooms in these objects. If I'm not have selected objects, continue as it is today, applying a zoom in the visible scene.
The result would be similar to a zoom of "3dsmax" (press the Z key)
The atual code
(defun c:ZOBJECTS(/ selectprev) (SETQ selectprev (SSGET "_P")) (command "._UCS" "View") (command "._zoom" "extents") (command ".__zoom" "object" "cross" "-1e99,-1e99" "1e99,1e99" "") (command "._UCS" "previous") (command "._select" selectprev "") )
TIA
Gustavo_Bernardi,
if I understood correctly
(defun c:ZOBJECTS (/ selectprev) (if (setq selectprev (ssget "_P")) (progn ( );If you have selected objects ( );put here what you need to do ( );zoom wcs ... ); end of progn (progn ( );If you dont have selected objects ( );put here what you need to do ( ); zooms wcs ... ); end of progn ); end of if );end of ZOBJECTS
hope that helps
Henrique
Not exactly.
The selectprev is just for safety. I capture the current "previous selection" to return it to autocad after the end of the command.
I'll just put a piece of code that would change:
(defun c:ZOBJECTS() ( (if i have object selected);;here is my problem true:
(command "._zoom" "O" ) false (progn (command "._UCS" "View") (command "._zoom" "extents") (command "._zoom" "object" "cross" "-1e99,-1e99" "1e99,1e99" "") (command "._UCS" "previous") ) ) )
thanks
(defun c:ZOBJECTS (/ selectprev) (if (setq selectprev (ssget "_P")) (command "._zoom" "O" selectprev "") (progn (command "._UCS" "View") (command "._zoom" "extents") (command "._zoom" "object" "cross" "-1e99,-1e99" "1e99,1e99" "") (command "._UCS" "previous") ); end of progn ); end of if );end of ZOBJECTS
Henrique
Gustavo_Bernardi,
with "ssget" and "_P", will select the previous selection set.
The previous selection set, only becomes empty when, at least, one of the selected elements is removed from the drawing, for example, with erase, pedit, or when one object is erased.
If you use a command that is necessary select an object, such as rotate or move, these objects become the last selected objects, and when you use your code will be made a zoom to these objects.
When you have written "if i have object selected" did you mean, objects selected and gripped, if so try this code
(defun c:test (/ ss) (if (setq ss (car (cdr (ssgetfirst)))) (command "._zoom" "O" ss "") (progn (command "._UCS" "View") (command "._zoom" "extents") (command "._zoom" "object" "cross" "-1e99,-1e99" "1e99,1e99" "") (command "._UCS" "previous") );; progn );; if )
hope that helps
Henrique
(defun c:zobjects (/ ss) (if (setq ss (car (cdr (ssgetfirst)))) (command "._zoom" "O" ss "") (progn (SETQ selectprev (SSGET "_P"));;I capture the actual previous (command "._UCS" "View") (command "._zoom" "extents") (command "._zoom" "object" "cross" "-1e99,-1e99" "1e99,1e99" "");;this is the actual previous selection (and I do not want it) (command "._UCS" "previous") (command "._select" selectprev "");;I return the objects to the selection previous );; progn );; if )
Henrique, thanks for your help!
Now works fine...
but still kept the selectprev, see his function described in the code.