[求助]关于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> <p>from help files</p><p>Sub Example_ActiveUCS()<br/> ' This example returns the current saved UCS (or saves a new one dynamically)<br/> ' and then sets a new UCS.<br/> ' Finally, it returns the UCS to the previous setting.<br/> <br/> Dim newUCS As AcadUCS<br/> Dim currUCS As AcadUCS<br/> Dim origin(0 To 2) As Double<br/> Dim xAxis(0 To 2) As Double<br/> Dim yAxis(0 To 2) As Double<br/> <br/> ' Get the current saved UCS of the active document. If the current UCS is<br/> ' not saved, then add a new UCS to the UserCoordinateSystems collection<br/> If ThisDrawing.GetVariable("UCSNAME") = "" Then<br/> ' Current UCS is not saved so get the data and save it<br/> With ThisDrawing<br/> Set currUCS = .UserCoordinateSystems.Add( _<br/> .GetVariable("UCSORG"), _<br/> .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _<br/> .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _<br/> "OriginalUCS")<br/> End With<br/> Else<br/> Set currUCS = ThisDrawing.ActiveUCS 'current UCS is saved<br/> End If<br/> <br/> MsgBox "The current UCS is " & currUCS.Name, vbInformation, "ActiveUCS Example"<br/> <br/> ' Create a UCS and make it current<br/> origin(0) = 0: origin(1) = 0: origin(2) = 0<br/> xAxis(0) = 1: xAxis(1) = 1: xAxis(2) = 0<br/> yAxis(0) = -1: yAxis(1) = 1: yAxis(2) = 0<br/> Set newUCS = ThisDrawing.UserCoordinateSystems.Add(origin, xAxis, yAxis, "TestUCS")<br/> ThisDrawing.ActiveUCS = newUCS<br/> MsgBox "The new UCS is " & newUCS.Name, vbInformation, "ActiveUCS Example"<br/> <br/> ' Reset the UCS to its previous setting<br/> ThisDrawing.ActiveUCS = currUCS<br/> MsgBox "The UCS is reset to " & currUCS.Name, vbInformation, "ActiveUCS Example"<br/>End Sub</p> <p>From system variable "WORDLUCS" you can detect if the current coord system is WCS</p> <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> 谢谢提示如何建UCS坐标系。 origin(0) = 0: origin(1) = 0: origin(2) = 0xAxis(0) = 1: xAxis(1) = 1: xAxis(2) = 0
yAxis(0) = -1: yAxis(1) = 1: yAxis(2) = 0
我试了一下午当为变量时好像都无法建成UCS!
页:
[1]