Change ucs in Modelspace from Paperspace via LISP

Change ucs in Modelspace from Paperspace via LISP

andkal
Collaborator Collaborator
829 Views
11 Replies
Message 1 of 12

Change ucs in Modelspace from Paperspace via LISP

andkal
Collaborator
Collaborator

Hello,
Is there a way to change UCS in Modelspaec via Lisp while being in Paperspace?
I have a saved Modelspace UCS and I want to restore it being in Paperspace but not having to go back to Modelspace.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
830 Views
11 Replies
Replies (11)
Message 2 of 12

paullimapa
Mentor
Mentor

I assume you are referring to restoring a ucs in Mspace of a vport?  Then while inside the vport just enter UCS command Restore and enter name of saved UCS to set current 

https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-0BE49DA1-B323-4758-B49B-4C497D194C7A


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 12

andkal
Collaborator
Collaborator

Hi,
Not really in the Viewport, I meant in Modelspace itself, so that when I go back later to Modelspace, the UCS is  restored.
When I restore/change UCS in the viewport and go back to Modelspace, the UCS is not resotred/changed.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 4 of 12

paullimapa
Mentor
Mentor

Since there’s possibly of multiple pspace vports and each can have a different ucs, which of the vports ucs would then be the one to set current in model tab? 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 12

andkal
Collaborator
Collaborator

I meant "Model tab", sorry for not being precise, you named it better.
Viewports don't matter here, there also can be a paperspace with no created viewports.
Anyway, If I vlax-dump the Modelspace I see no ActiveUCS property, so probably it is not possible at all to do what I want.
I posted this question in case some other user met the problem and maybe know the solution.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 6 of 12

Sea-Haven
Mentor
Mentor

UCS S "name" should do what you want, you save the current UCs setting so we had "Road1", "Road2" etc to change the UCS to required one, just UCS R "Road1" and so on, this is the way we set our viewports UCS, making the UCS in MODEL then setting them in the layout viewport. 

 

If you look at this image the red rectangles are the desired twisted Viewports which are auto made in a new layout, appearing horizontal. Is this what your trying to achieve ?

 

0 Likes
Message 7 of 12

paullimapa
Mentor
Mentor

Ok, so if you mean that you have named UCSs saved when you were in Model tab but now you're in Layout (but not inside a vport) and you want to restore one of the named UCSs to the current Layout that you had saved in Model then you can use AutoCAD's built-in commands to Restore it:

Command line version:

UCS Restore <name of ucs>

Dialog version:

DDUCSP > Named UCSs tab > select saved UCS names from list to set current

paullimapa_0-1739146954418.png

If you want a lisp version check out the code called c:q already written by @komondormrex in this link:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/control-my-ucs/m-p/11899780/highligh...

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 12

andkal
Collaborator
Collaborator

Hello,
Thank you for your posts and sorry for the delay in answering, Im a little bit busy lately.
I would like to modify UCS in Model-tab (in my particulart case- restore) while being in an empty Layout without any  created viewports and without entering Model tab to do it. But I still think it may be not achievable.
If I used (vl-cmdf "_UCS" "_NAmed" "_Restore"....) I would modyfy UCS in Layout instead.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 9 of 12

paullimapa
Mentor
Mentor

I'm not aware of a way using lisp to set a UCS current in Model tab while in Layout without first going to Model.

Now the lisp routine can automate the process by saving the current Layout, change to Model, set the saved UCS current, then return back to the saved Layout. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 10 of 12

Sea-Haven
Mentor
Mentor

Agree with @paullimapa but don't forget when you use UCS R name you also need to do PLAN Enter, to set the view to that UCS. 

0 Likes
Message 11 of 12

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

... when you use UCS R name you also need to do PLAN Enter, to set the view to that UCS. 


... unless you have the UCSFOLLOW System Variable set to 1, to make that happen automatically.  It's saved separately for each Viewport, so it would need to be set that way in Model space in the situation described -- the setting wouldn't matter in the Paper space starting point.

Kent Cooper, AIA
0 Likes
Message 12 of 12

jmusy
Participant
Participant

First in your model tilemode 0 -> name a UCS command line -ucs "NAME" "SAV" "TEST"

then by lisp modify TEST props from paper space layouts.

To modify recorded ucs origin is something like 

(vl-load-com)
(vlax-for u (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object))))(if (= "TEST" (vla-get-name u))(setq myUcs u))
(vla-put-origin mysaveducs (vlax-3d-point '(1.0 1.0 1.0))) ;here adjust coordinates values

then when you go back to model space ucs origin is set to 1.0,1.0,1.0

0 Likes