Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get current space?

10 REPLIES 10
Reply
Message 1 of 11
JeffPaulsen
1017 Views, 10 Replies

How to get current space?

I am working on a lisp routine and want to make an IF statement based on whether the user is in paper space or model space.

 

How do I determine the current space?

 

This seems like a basic request and I assume this information is stored in a system variable but a 10 minute search has come up empty.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
10 REPLIES 10
Message 2 of 11
~Opie
in reply to: JeffPaulsen

You might try this routine.  It is the one I use.

Message 3 of 11
paullimapa
in reply to: JeffPaulsen

(if(and(zerop(getvar"tilemode"))(= 1 (getvar"cvport")))(princ"\nPspace")(princ"\nMspace"))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 11
JeffPaulsen
in reply to: paullimapa

Thanks guys.

 

I never have much time to work on lisp so I ended up making two routines for now, one for PS and one for MS.

 

I will take a cloder look at your suggestions when I have more time. I did test Paul's code at the command line and it was able to acuratley determine what space was current. I will probably look at this option first.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
Message 5 of 11
scot-65
in reply to: JeffPaulsen

Yes, both TILEMODE and CVPORT must be investigated
to determine what space is current.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 6 of 11
Lee_Mac
in reply to: JeffPaulsen

Only the CVPORT system variable need be tested:

 

(if (= 1 (getvar 'cvport))
    < user is in paperspace >
    < user is in modelspace >
)

 

Message 7 of 11
paullimapa
in reply to: Lee_Mac

Nice one Lee_Mac

 

 

 

AOL @ Exchange App Store         DDSetup @ Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 8 of 11
Lee_Mac
in reply to: paullimapa

Message 9 of 11
Jason.Piercey
in reply to: Lee_Mac


@Lee_Mac wrote:

Only the CVPORT system variable need be tested:

 

(if (= 1 (getvar 'cvport))
    < user is in paperspace >
    < user is in modelspace >
)

 


Depending on program intent it can be handy to know if you are in floating modelspace.  Determining that requires more than testing only CVPORT.

Message 10 of 11
Lee_Mac
in reply to: Jason.Piercey

Jason.Piercey wrote:
Lee_Mac wrote:

Only the CVPORT system variable need be tested:

 

(if (= 1 (getvar 'cvport))
    < user is in paperspace >
    < user is in modelspace >
)

 

Depending on program intent it can be handy to know if you are in floating modelspace.  Determining that requires more than testing only CVPORT.

 

Correct - TILEMODE must also be tested if it is necessary to differentiate between the Model layout & viewing Modelspace through a Paperspace Viewport, but I believe my above suggestion is the most succinct way to determine the current space, as the OP requested.

Message 11 of 11
Jason.Piercey
in reply to: Lee_Mac


@Lee_Mac wrote:

Correct - TILEMODE must also be tested if it is necessary to differentiate between the Model layout & viewing Modelspace through a Paperspace Viewport. 


I suppose it doesn't have to be TILEMODE.  One could also use CTAB, since you can't rename the model layout.  Same difference in the end.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost