TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Robert_s on January 02, 2009, 11:12:26 AM
-
Hello,
The guys at the office are too lazy to switch back to paper space
and do a zoom extent before they end the drawing they just worked
on.
I am trying to write a program using reactors to switch back to paper space
& do a zoom extend and then end/close the drawing.
The program will first check paper space (tilemode=0) for xreference
drawing/s. It usually would be the title block, and we normally only have
one layout tab. If the program finds xreference drawings it will do a zoom
extents and maybe ask if you want to save the drawing then end. But if
it dosent find any xref drawings in paper space do nothing.
This is how I will select/find blocks in paper space.
(setq ss (ssget "x" (list (cons 410 (getvar "ctab"))(cons 0 "insert"))))
My question:
Is there a way to select the xrefs in paper space without switching
tilemode 0?
-
This will grab the block not in model space:
(setq ss (ssget "x" (list '(0 . "INSERT")
;;'(2 . "title1,title2")
'(-4 . "<NOT")
'(410 . "Model")
'(-4 . "NOT>")
)
)
)
You could add assoc 2 to the list to grab specific block names as well.
-
Ronjonp,
It gave me this error message....
error: bad argument type: consp
"<NOT"
-
Oops...give it a try now (was missing a quote)
Here is something to look at....be aware if the a pspace vport is active, it will zoom extents that viewport unless locked.
(defun c:zoomtabs (/ ss n e)
(vl-load-com)
(setq n -1)
(if (setq ss (ssget "x"
(list '(0 . "INSERT")
'(-4 . "<NOT")
'(410 . "Model")
'(-4 . "NOT>")
)
)
)
(progn
;zoom the tab(s)
(while (setq e (ssname ss (setq n (1+ n))))
(setvar 'ctab (cdr (assoc 410 (entget e))))
(vla-zoomextents (vlax-get-acad-object))
)
(setvar 'ctab "Model") ;back to model space we go
)
)
(princ)
)
-
Ronjonp,
Still not working, its prompting me..
Select objects:
-
Ronjonp,
Thanks. This example will get me started.
BTW..If I load it into a drawing with no xrefs in paper space it gives me this error message..
error: bad argument type: lselsetp nil
-
it work fine for me..
there is another way...
(defun checkxrefblock (xrefname / XREFFOUND)
(setq XREFFOUND NIL)
(vl-load-com)
(vlax-for n (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(if
(and
(eq (vla-get-name n) xrefname)
(eq :vlax-false (vla-get-IsLayout n))
(eq :vlax-true (vla-get-IsXref n))
)
(setq XREFFOUND T)
)
)
XREFFOUND
)
(checkxrefblock "YourXrefName")
this will help you to know if an Xref is inserted in Paper space
-
Thanks Andrea,
I can use & learn from this too.
-
Ronjonp,
Thanks. This example will get me started.
BTW..If I load it into a drawing with no xrefs in paper space it gives me this error message..
error: bad argument type: lselsetp nil
I updated the code above.
-
Not sure where I got this:
(defun zoom_all_layouts (/ lay layouts *acad* *doc* )
(vl-load-com)
(setq *acad* (vlax-get-acad-object)
*doc* (vla-get-activedocument *acad*)
layouts (vla-get-layouts *doc*)
)
(vlax-for lay layouts ; step through layouts
(vla-put-activelayout *doc* lay) ; activate layout
(if (= (vla-get-activespace *doc*) 0) ; If in paperspace
(if (= (vla-get-mspace *doc*) :vlax-true); in mspace viewport
(vla-put-mspace *doc* :vlax-false) ; inactivate vp
) ; endif
) ; endif
(vla-zoomextents *acad*)
; (vl-cmdf "_.zoom" ".95x") ; to create a margin
)
)
-
maybe HERE (http://www.theswamp.org/index.php?topic=22861.0)
-
No that wasn't the source. :)