MJLM Posted March 15, 2018 Share Posted March 15, 2018 Trying to switch from one ucs to an other and then switch back to the first I realized there is something wrong with the routine below. By the way, I found it somewhere on the net. For saving the UCS (defun saveactiveUCS (/ acadObj doc UCSs) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq UCSs (vla-get-UserCoordinateSystems doc)) (if (= (vlax-variant-value (vla-GetVariable doc "UCSNAME")) "") ; if the active UCS is not saved (returns empty string "")... (progn (setq utility (vla-get-Utility doc)) (setq currUCS (vla-Add UCSs (vla-GetVariable doc "UCSORG") (vla-TranslateCoordinates utility (vla-GetVariable doc "UCSXDIR") acUCS acWorld :vlax-false) (vla-TranslateCoordinates utility (vla-GetVariable doc "UCSYDIR") acUCS acWorld :vlax-false) "OriginalUCS" ) ) ) (setq currUCS (vla-get-ActiveUCS doc)) ;; else, the UCS is saved and we just store it in memory. current UCS is saved ) ) For restoring the UCS (defun restoreUCS (currUCS / acadObj doc UCSs currUCS) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq UCSs (vla-get-UserCoordinateSystems doc)) (vla-put-ActiveUCS doc currUCS) ) Apparently, when the initial ucs is not saved in the databse rather just active, it is not working well. The ucs comes to the original location alright but the axes are messed up. Does this happen to you too? If so, what is the problem with the code? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted March 15, 2018 Share Posted March 15, 2018 (edited) When adding an UCS the X and Y axis should be defined by a point on the axis, not by a vector as in your code. See: http://www.theswamp.org/index.php?topic=53988.0. The X and Y vectors used in the code are wrong as well. Edited March 15, 2018 by Roy_043 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.