Author Topic: selecting xrefs in paper space  (Read 2753 times)

0 Members and 1 Guest are viewing this topic.

Robert_s

  • Guest
selecting xrefs in paper space
« 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?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: selecting xrefs in paper space
« Reply #1 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.
« Last Edit: January 02, 2009, 01:53:04 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Robert_s

  • Guest
Re: selecting xrefs in paper space
« Reply #2 on: January 02, 2009, 01:40:32 PM »
Ronjonp,

It gave me this error message....


 error: bad argument type: consp
"<NOT"

ronjonp

  • Needs a day job
  • Posts: 7531
Re: selecting xrefs in paper space
« Reply #3 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)
)
« Last Edit: January 02, 2009, 06:30:13 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Robert_s

  • Guest
Re: selecting xrefs in paper space
« Reply #4 on: January 02, 2009, 01:55:31 PM »
Ronjonp,

Still not working, its prompting me..

Select objects:

Robert_s

  • Guest
Re: selecting xrefs in paper space
« Reply #5 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

Andrea

  • Water Moccasin
  • Posts: 2372
Re: selecting xrefs in paper space
« Reply #6 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
« Last Edit: January 02, 2009, 03:12:31 PM by Andrea »
Keep smile...

Robert_s

  • Guest
Re: selecting xrefs in paper space
« Reply #7 on: January 02, 2009, 03:23:43 PM »
Thanks Andrea,

I can use & learn from this too.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: selecting xrefs in paper space
« Reply #8 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: selecting xrefs in paper space
« Reply #9 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
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: selecting xrefs in paper space
« Reply #10 on: January 05, 2009, 05:36:46 PM »
maybe HERE
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: selecting xrefs in paper space
« Reply #11 on: January 05, 2009, 05:59:17 PM »
No that wasn't the source. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.