乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 40|回复: 2

[VBA]如何得到当前文档的当前无名ucs的转换矩阵?

[复制链接]

1

主题

12

帖子

4

银币

初来乍到

Rank: 1

铜币
16
发表于 2006-9-18 20:43:00 | 显示全部楼层 |阅读模式
rt
回复

使用道具 举报

1

主题

12

帖子

4

银币

初来乍到

Rank: 1

铜币
16
发表于 2006-9-19 11:17:00 | 显示全部楼层
autodesk的代码如下,按照原理应该可行,可惜坐标转换之后保存的OriginalUCS有错误。郁闷啊。
Sub Example_ActiveUCS1()
    ' 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
    Dim pnt As Variant
    ' 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
'                            .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _
'                            .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _
                           
'
pnt = ThisDrawing.GetVariable("UCSORG")
    Debug.Print pnt(0); pnt(1); pnt(2)
    pnt = ThisDrawing.GetVariable("UCSXDIR")
    Debug.Print pnt(0); pnt(1); pnt(2)
    pnt = ThisDrawing.GetVariable("UCSYDIR")
    Debug.Print pnt(0); pnt(1); pnt(2)
   
    pnt = ThisDrawing.Utility.TranslateCoordinates(ThisDrawing.GetVariable("UCSXDIR"), acUCS, acWorld, 0)
    Debug.Print pnt(0); pnt(1); pnt(2)
   
    pnt = ThisDrawing.Utility.TranslateCoordinates(ThisDrawing.GetVariable("UCSYDIR"), acUCS, acWorld, 0)
    Debug.Print pnt(0); pnt(1); pnt(2)
     


    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


回复

使用道具 举报

1

主题

12

帖子

4

银币

初来乍到

Rank: 1

铜币
16
发表于 2006-9-19 14:19:00 | 显示全部楼层
这样就好了。呵呵。小心autodesk蒙人。

    If ThisDrawing.GetVariable("UCSNAME") = "" Then
        ' Current UCS is not saved so get the data and save it   '.GetVariable("UCSORG"),
        With ThisDrawing
            Set currUCS = .UserCoordinateSystems.Add( _
                            pnt1, _
                            .GetVariable("UCSXDIR"), _
                            .GetVariable("UCSYDIR"), _
                            "OriginalUCS")
                            currUCS.origin = .GetVariable("UCSORG")
        End With
    Else
        Set currUCS = ThisDrawing.ActiveUCS  'current UCS is saved
    End If
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 13:07 , Processed in 0.659639 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表