TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Robert_s on January 02, 2009, 11:12:26 AM

Title: selecting xrefs in paper space
Post 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?
Title: Re: selecting xrefs in paper space
Post by: ronjonp on January 02, 2009, 11:55:05 AM
This will grab the block not in model space:

Code: [Select]
(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.
Title: Re: selecting xrefs in paper space
Post by: Robert_s on January 02, 2009, 01:40:32 PM
Ronjonp,

It gave me this error message....


 error: bad argument type: consp
"<NOT"
Title: Re: selecting xrefs in paper space
Post by: ronjonp on January 02, 2009, 01:47:02 PM
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.

Code: [Select]
(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)
)
Title: Re: selecting xrefs in paper space
Post by: Robert_s on January 02, 2009, 01:55:31 PM
Ronjonp,

Still not working, its prompting me..

Select objects:
Title: Re: selecting xrefs in paper space
Post by: Robert_s on January 02, 2009, 02:13:38 PM
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
Title: Re: selecting xrefs in paper space
Post by: Andrea on January 02, 2009, 03:01:34 PM
it work fine for me..

there is another way...

Code: [Select]
(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
Title: Re: selecting xrefs in paper space
Post by: Robert_s on January 02, 2009, 03:23:43 PM
Thanks Andrea,

I can use & learn from this too.
Title: Re: selecting xrefs in paper space
Post by: ronjonp on January 02, 2009, 06:29:57 PM
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.
Title: Re: selecting xrefs in paper space
Post by: CAB on January 05, 2009, 02:23:00 PM
Not sure where I got this:

Code: [Select]
(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
  )
)
Title: Re: selecting xrefs in paper space
Post by: Andrea on January 05, 2009, 05:36:46 PM
maybe HERE (http://www.theswamp.org/index.php?topic=22861.0)
Title: Re: selecting xrefs in paper space
Post by: CAB on January 05, 2009, 05:59:17 PM
No that wasn't the source. :)