Author Topic: Select each viewport on each layout tab (if there is a viewport)  (Read 4872 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Select each viewport on each layout tab (if there is a viewport)
« on: September 18, 2007, 10:16:13 AM »
I've got some drawings that I'm trying to update with a little proggy.  The proggy will cycle through each layout tab, unlock any viewports it finds, then (and this is where I'm having a problem) jump inside of each viewport and then turn off/on/thaw/freeze some specific layers.

A little guidance please??

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #1 on: September 18, 2007, 11:04:32 AM »
See this thread.

But if you are going into each layout, then you can just filter out the viewport with the id of 0   1, that is the paper space viewport.

Edit: Change what is stricken out and what is red.
« Last Edit: September 18, 2007, 11:26:42 AM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Guest

  • Guest
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #2 on: September 18, 2007, 11:11:10 AM »
Cool... Next question.  Once I've got the list of viewports, how can I get into it?  MSPACE appears to only work on the last active viewport?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #3 on: September 18, 2007, 11:17:56 AM »
Cool... Next question.  Once I've got the list of viewports, how can I get into it?  MSPACE appears to only work on the last active viewport?
Each viewport Id will correspond to the value of the 'cvport' system variable.  So if the viewport has an id of 5, then change the variable 'cvport' to 5, and you should be in the viewport you want.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Marco Jacinto

  • Newt
  • Posts: 47
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #4 on: September 18, 2007, 11:21:26 AM »
You can use the Cvport system variable or the vla-get-ActivePViewport property of the Document object, just issue MSpace command or property before.

Try this:
Code: [Select]
(SETQ ssvp (SSGET "_X"
  '((0 . "VIEWPORT") (-4 . ">") (69 . 1))
   )
)
(REPEAT (SETQ ct (SSLENGTH ssvp))
  (SETQ ct (1- ct)
ename (SSNAME ssvp ct)
entData (ENTGET ename)
Layout (CDR (ASSOC 410 entData))
  )
  (SETVAR "ctab" Layout)
  (VL-CMDF "MsPace")
  (SETVAR "cvport" (CDR (ASSOC 69 entData)))
  (ALERT
    (STRCAT "Viewport number "
    (ITOA (CDR (ASSOC 69 entData)))
    " is now current"
    )
  )
)

Saludos
Marco Jacinto

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #5 on: September 18, 2007, 11:25:02 AM »
Marco is right with his code.  I gave you bad info in my first post.  The paper space viewport's id is 1, so filter out 1 and you should get all the viewports within the paper space.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Guest

  • Guest
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #6 on: September 18, 2007, 11:35:35 AM »
Marco is right with his code.  I gave you bad info in my first post.  The paper space viewport's id is 1, so filter out 1 and you should get all the viewports within the paper space.

All respect I had for you just went right out the window!   :wink:

Thanks guys!  Much appreciated!!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #7 on: September 18, 2007, 11:42:20 AM »
Marco is right with his code.  I gave you bad info in my first post.  The paper space viewport's id is 1, so filter out 1 and you should get all the viewports within the paper space.

All respect I had for you just went right out the window!   :wink:

Thanks guys!  Much appreciated!!
I blame it on the first post in the morning...... Yea that will work.   :angel:
Glad you got what you wanted.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Marco Jacinto

  • Newt
  • Posts: 47
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #8 on: September 18, 2007, 12:14:54 PM »
Glad it wors

Saludos
Marco Jacinto

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #9 on: September 18, 2007, 12:17:53 PM »
You could also pull all the necessary info from the viewports and combine them into a list to manipulate.

Code: [Select]
(foreach l (layoutlist)
  (setvar 'ctab l)
)
(setq ss (ssget "x" '((0 . "VIEWPORT") (-4 . ">") (69 . 1))))
(if ss
  (progn
    (setq ss (mapcar 'cadr (ssnamex ss)))
    (mapcar
      '(lambda (x)
(setq lst (cons (list x
       (cdr (assoc 410 (entget x)))
       (cdr (assoc 69 (entget x)))
)
lst
   )
)
       )
      ss
    )
    (foreach vp lst
      (setvar 'ctab (nth 1 vp))
      (command "._mspace")
      (setvar 'cvport (nth 2 vp))
      (command "._pspace")
    )
  )
)

Where lst would hold info something like this:


 [1] (<Entity name: 7efec0f8> "Layout2" 3)
 [2] (<Entity name: 7efec118> "Layout2" 4)
 [3] (<Entity name: 7efec138> "Layout2" 5)
 [4] (<Entity name: 7efec1d8> "Layout2" 6)
 [5] (<Entity name: 7efec1f8> "Layout2" 7)


« Last Edit: September 18, 2007, 12:46:18 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #10 on: September 18, 2007, 12:26:43 PM »
Doing it that way Ron you would not get all the correct (non-paper space viewports) viewports.  Read the other thread that I posted a link to and you will see why.  To long to explain here. :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Select each viewport on each layout tab (if there is a viewport)
« Reply #11 on: September 18, 2007, 12:42:49 PM »
That's right...I guess the only way my code would get a correct list is to cycle through the tabs prior to collecting. (or use CABS code)  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC