Author Topic: Trivial question - variable paper space / model  (Read 3144 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Trivial question - variable paper space / model
« on: April 16, 2012, 05:22:45 AM »
Hello everyone,
how do I know if the pointer is:
- In paper space
- In a paper space viewport (model space so)

I tried with CTAB, but it always returns the name of the layout even if the pointer is in window.
Even TILEMODE not good.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Trivial question - variable paper space / model
« Reply #1 on: April 16, 2012, 06:32:22 AM »
Several ways, but for me the easiest is to check TileMode. If 0 then on a PS tab. Then if CVport > 1 you know you're inside a viewport, since VP# 1 is the paper space itself.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Trivial question - variable paper space / model
« Reply #2 on: April 16, 2012, 07:07:24 AM »
I just use CVPORT  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Trivial question - variable paper space / model
« Reply #3 on: April 16, 2012, 07:53:24 AM »
The problem with only CVport is it equals 2 while on the Model tab (i.e. when TileMode=1), don't know why - I'd have imagined 0 would be more useful. Though if you have tiled viewports on the model tab I could possibly understand. But a CVPort=2 thus might mean you're inside the 1st viewport on paper space, or it might mean you're on the Model tab.

Edit: Actually, I understand what you're saying Lee. If all you really need to know is which space is active, then CVPort>1 means Model Space is active, CVPort=1 means Paper Space.
« Last Edit: April 16, 2012, 07:57:04 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Trivial question - variable paper space / model
« Reply #4 on: April 16, 2012, 07:59:35 AM »
Edit: Actually, I understand what you're saying Lee. If all you really need to know is which space is active, then CVPort>1 means Model Space is active, CVPort=1 means Paper Space.

Exactly - when creating objects, for most cases this is all you need to know  :-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Trivial question - variable paper space / model
« Reply #5 on: April 16, 2012, 08:08:05 AM »
Precisely how we get away with the following...

Code: [Select]
(vlax-get (vla-get-activedocument (vlax-get-acad-object))
          (if (eq (getvar 'CVPORT) 1)
            'Paperspace
            'Modelspace
          )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Trivial question - variable paper space / model
« Reply #6 on: April 16, 2012, 10:28:34 AM »
Exactly. It's just that from the OP I understood that he wanted to know if he was inside a viewport or on paperspace. Perhaps for something like applying VP overrides or such. In such case you need to compare TileMode as well.

Anyhow, now all is shown  :laugh:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

BlackBox

  • King Gator
  • Posts: 3770
Re: Trivial question - variable paper space / model
« Reply #7 on: April 16, 2012, 12:16:42 PM »
Anyhow, now all is shown  :laugh:

Irneb's rocking out with his CVPORT out  :lol:
"How we think determines what we do, and what we do determines what we get."

Lupo76

  • Bull Frog
  • Posts: 343
Re: Trivial question - variable paper space / model
« Reply #8 on: April 16, 2012, 01:22:08 PM »
I can not leave you alone for 5 minutes  :-D

Thanks to all!

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Trivial question - variable paper space / model
« Reply #9 on: April 16, 2012, 03:07:23 PM »
Irneb's rocking out with his CVPORT out  :D
:lmao: :lmao:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

hermanm

  • Guest
Re: Trivial question - variable paper space / model
« Reply #10 on: April 16, 2012, 03:33:13 PM »
Code - Auto/Visual Lisp: [Select]
  1. ;;--------------------- tktn_getscl--------------------------------------
  2. ;;      Purpose: calculate scale factor
  3. ;;      Uses:    nothing
  4. ;;      Returns: sf
  5. ;;      Method due to Ian Bryant
  6. ;;-----------------------------------------------------------------
  7. (defun tktn_getscl( )
  8.   (cond ((= 1 (getvar "TILEMODE")) (getvar "DIMSCALE"));tiled space
  9.         ((= 1 (getvar "CVPORT")) 1.0);in paper space
  10.      ;; in a viewport
  11.         (T
  12.           (last (trans '(0 0 1.0) 3 2));calc scale factor
  13.         )
  14.   );cond
  15. )
  16.  

nivuahc

  • Guest
Re: Trivial question - variable paper space / model
« Reply #11 on: April 16, 2012, 04:20:25 PM »
I've been using the following, by Jeff Mishler (as part of the routine found here), with great success for some time now.

Code - Auto/Visual Lisp: [Select]
  1. (defun get_space ()
  2.     (if (= 1 (vla-get-activespace *doc*))
  3.       (vla-get-modelspace *doc*)        ;we're in modelspace
  4.       (if (= (vla-get-mspace *doc*) :vlax-true)
  5.         (vla-get-modelspace *doc*)      ;we're in modelspace
  6.                                         ;thru paperspace VPort
  7.         (vla-get-paperspace *doc*)      ;we're in paperspace
  8.       )
  9.     )
  10.   )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Trivial question - variable paper space / model
« Reply #12 on: April 17, 2012, 09:23:42 AM »
The one I use:
Code: [Select]
(defun activespace (doc)
  (if (or (= acmodelspace (vla-get-activespace doc))
          (= :vlax-true (vla-get-mspace doc)))
      (vla-get-modelspace doc)
      (vla-get-paperspace doc)
  )
)
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.