enocheasty 发表于 2007-10-18 21:41:00

[求助]关于VBA控制UCS的问题

<p>问题多多啊,望高人们帮助。</p><p>1,我们平常绘图的时候会转变WCS到自定义坐标系统,但这个坐标系统在UCS里面是未命名的,在我的绘图模型空间视口看到坐标图标已经变成用户坐标,所以我想问,要怎么样才能在我的程序启动的时候探测到目前视口的坐标系统已经不是WCS坐标系了!(我用thisdrawing.usercoordinatesystem.count 属性探测了一下发现数目是0,如果我在CAD里面把那个未命名UCS取个名字,再探测count就是1了!)</p><p>2,解决了上面的问题后,那么我自定义一个坐标对象后,要怎么样才能将当前的UCS信息赋值到我定义的坐标对象里面去呢?</p><p>3,再弱弱的问一下,当我们定义UCS时,我们选择了3点定义出来的UCS,和选择了一条直线定义出来的UCS有什么不同吗?说实话,我没有弄清帮助文档里面说的OCS是什么,它总是说用Poloyline还有一个别的什么玩意定义出来的OCS,但是我们平常选择一根直线也可以定义UCS啊。</p>

alin 发表于 2007-10-19 08:29:00

<p>from help files</p><p>Sub Example_ActiveUCS()<br/>&nbsp;&nbsp;&nbsp; ' This example returns the current saved UCS (or saves a new one dynamically)<br/>&nbsp;&nbsp;&nbsp; ' and then sets a new UCS.<br/>&nbsp;&nbsp;&nbsp; ' Finally, it returns the UCS to the previous setting.<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim newUCS As AcadUCS<br/>&nbsp;&nbsp;&nbsp; Dim currUCS As AcadUCS<br/>&nbsp;&nbsp;&nbsp; Dim origin(0 To 2) As Double<br/>&nbsp;&nbsp;&nbsp; Dim xAxis(0 To 2) As Double<br/>&nbsp;&nbsp;&nbsp; Dim yAxis(0 To 2) As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Get the current saved UCS of the active document. If the current UCS is<br/>&nbsp;&nbsp;&nbsp; ' not saved, then add a new UCS to the UserCoordinateSystems collection<br/>&nbsp;&nbsp;&nbsp; If ThisDrawing.GetVariable("UCSNAME") = "" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Current UCS is not saved so get the data and save it<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With ThisDrawing<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set currUCS = .UserCoordinateSystems.Add( _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .GetVariable("UCSORG"), _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "OriginalUCS")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End With<br/>&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set currUCS = ThisDrawing.ActiveUCS&nbsp; 'current UCS is saved<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; MsgBox "The current UCS is " &amp; currUCS.Name, vbInformation, "ActiveUCS Example"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create a UCS and make it current<br/>&nbsp;&nbsp;&nbsp; origin(0) = 0: origin(1) = 0: origin(2) = 0<br/>&nbsp;&nbsp;&nbsp; xAxis(0) = 1: xAxis(1) = 1: xAxis(2) = 0<br/>&nbsp;&nbsp;&nbsp; yAxis(0) = -1: yAxis(1) = 1: yAxis(2) = 0<br/>&nbsp;&nbsp;&nbsp; Set newUCS = ThisDrawing.UserCoordinateSystems.Add(origin, xAxis, yAxis, "TestUCS")<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveUCS = newUCS<br/>&nbsp;&nbsp;&nbsp; MsgBox "The new UCS is " &amp; newUCS.Name, vbInformation, "ActiveUCS Example"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Reset the UCS to its previous setting<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveUCS = currUCS<br/>&nbsp;&nbsp;&nbsp; MsgBox "The UCS is reset to " &amp; currUCS.Name, vbInformation, "ActiveUCS Example"<br/>End Sub</p>

alin 发表于 2007-10-19 09:03:00

<p>From system variable "WORDLUCS" you can detect if the current coord system is WCS</p>

enocheasty 发表于 2007-10-19 22:44:00

<p>我试试看,能不能解决问题!</p><p>还是老大厉害,我在CAD的帮助文档里面翻来翻去就没看到这个Example</p><p>都是关于讲解UCS Translation ,都晕了!</p><p>Thankyou very much!<img alt="" src="http://www.mjtd.com/bbs/Skins/default/topicface/face3.gif"/></p>

crazylsp 发表于 2013-1-17 14:47:07

谢谢提示如何建UCS坐标系。

crazylsp 发表于 2013-5-22 17:31:57

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


我试了一下午当为变量时好像都无法建成UCS!
页: [1]
查看完整版本: [求助]关于VBA控制UCS的问题