ActiveUCS 属性 (ActiveX)
指定图形的活动 UCS。 支持的平台:仅限 Windows 言论只有在将 UCS 重置为活动 UCS 后,对当前活动 UCS 所做的更改才会可见。 如果在当前 UCS 未保存时尝试获取活动 UCS 值,则会发生错误。建议您在获取活动 UCS 值之前确认 UCSNAME 系统变量的值不为空。或者,您可以添加新的 UCS 对象并将其设置为活动状态,然后再获取活动 UCS 值。 例子VBA: Sub Example_ActiveUCS() ' This example returns the current saved UCS (or saves a new one dynamically) ' and then sets a new UCS. ' Finally, it returns the UCS to the previous setting. Dim newUCS As AcadUCS Dim currUCS As AcadUCS Dim origin(0 To 2) As Double Dim xAxis(0 To 2) As Double Dim yAxis(0 To 2) As Double ' Get the current saved UCS of the active document. If the current UCS is ' not saved, then add a new UCS to the UserCoordinateSystems collection If ThisDrawing.GetVariable("UCSNAME") = "" Then ' Current UCS is not saved so get the data and save it With ThisDrawing Set currUCS = .UserCoordinateSystems.Add( _ .GetVariable("UCSORG"), _ .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _ .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _ "OriginalUCS") End With Else Set currUCS = ThisDrawing.ActiveUCS 'current UCS is saved End If MsgBox "The current UCS is " & currUCS.name, vbInformation, "ActiveUCS Example" ' Create a UCS and make it current origin(0) = 0: origin(1) = 0: origin(2) = 0 xAxis(0) = 1: xAxis(1) = 1: xAxis(2) = 0 yAxis(0) = -1: yAxis(1) = 1: yAxis(2) = 0 Set newUCS = ThisDrawing.UserCoordinateSystems.Add(origin, xAxis, yAxis, "TestUCS") ThisDrawing.ActiveUCS = newUCS MsgBox "The new UCS is " & newUCS.name, vbInformation, "ActiveUCS Example" ' Reset the UCS to its previous setting ThisDrawing.ActiveUCS = currUCS MsgBox "The UCS is reset to " & currUCS.name, vbInformation, "ActiveUCS Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_ActiveUCS() ;; This example returns the current saved UCS (or saves a new one dynamically) ;; and then sets a new UCS. ;; Finally, it returns the UCS to the previous setting. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq UCSs (vla-get-UserCoordinateSystems doc)) ;; Get the current saved UCS of the active document. If the current UCS is ;; not saved, then add a new UCS to the UserCoordinateSystems collection (if (= (vlax-variant-value (vla-GetVariable doc "UCSNAME")) "") (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)) ;; current UCS is saved ) (alert (strcat "The current UCS is " (vla-get-Name currUCS))) ;; Create a UCS and make it current (setq origin (vlax-3d-point 0 0 0) xAxis (vlax-3d-point 1 1 0) yAxis (vlax-3d-point -1 1 0)) (setq newUCS (vla-Add UCSs origin xAxis yAxis "TestUCS")) (vla-put-ActiveUCS doc newUCS) (alert (strcat "The new UCS is " (vla-get-Name newUCS))) ;; Restore the previous UCS (vla-put-ActiveUCS doc currUCS) (alert (strcat "The UCS is restored to " (vla-get-Name currUCS))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 22:05
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.