CATIA VBA DrawingView .X .xAxisData对比解析

* Property xAxisData( ) As double

Returns or sets the x coordinate of the drawing view coordinate system origin. It is expressed with respect to the sheet coordinate system. This coordinate, like any length, is measured in millimeters.
Warning: This method is not available with 2D Layout for 3D Design.
Example:
This example retrieves the x coordinate of the coordinate system origin of the MyView drawing view.
X = MyView.xAxisData

* Property x( ) As double

For an interactive view, get_x and put_x methods are equivalents to get_xAxisData, put_xAxisData In a generative case, get_x. put_x returns or sets the x coordinate of the projection of the 3D centre of gravity. It is expressed with respect to the sheet coordinate system. This coordinate, like any length, is measured in millimeters.
Warning: This method is not available with 2D Layout for 3D Design.
Example:
This example retrieves the x coordinate of the view relative position MyView.
X = MyView.x

* Property yAxisData( ) As double

Returns or sets the y coordinate of the drawing view coordinate system origin. It is expressed with respect to the sheet coordinate system. This coordinate, like any length, is measured in millimeters.
Warning: This method is not available with 2D Layout for 3D Design.
Example:
This example sets the y coordinate of the coordinate system origin of the MyView drawing view to 5 inches. You need first to convert the 5 inches into millimeters.
NewYCoordinate = 5*25.4
MyView.yAxisData = NewYCoordinate

* Property y( ) As double

For an interactive view, get_y and put_y methods are equivalents to get_yAxisData, put_yAxisData In a generative case, get_y. put_y returns or sets the y coordinate of the projection of the 3D centre of gravity. It is expressed with respect to the sheet coordinate system. This coordinate, like any length, is measured in millimeters.
Warning: This method is not available with 2D Layout for 3D Design.
Example:
This example sets the y coordinate of the view relative position MyView to 5 inches. You need first to convert the 5 inches into millimeters.
NewYCoordinate = 5*25.4
MyView.y = NewYCoordinate

以上为官方API说明,具体对比效果如下:

  • 使用.xAxisData .yAxisData
    factory.CreateCircle oXY(0) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(0) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi
.xAxisData .yAxisData
  • 使用.X .Y
    factory.CreateCircle oXY(0) - view.X, oXY(2) - view.Y, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(0) - view.X, oXY(3) - view.Y, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.X, oXY(2) - view.Y, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.X, oXY(3) - view.Y, 3, 0, 2 * Dpi
.X .Y
可以发现.xAxisData .yAxisData 表示的是视图中心,而.X .Y指代的是视图对应的3D图形的原点位置。

以下为完整.xAxisData .yAxisData代码参考,.X .Y可如法炮制:

Sub testCarLine()
    Dim sheet As DrawingSheet
    Set sheet = CATIA.ActiveDocument.Sheets.ActiveSheet
    Dim mainView As DrawingView
    Set mainView = sheet.Views.Item(1)
    mainView.Activate
    
    For i = 3 To sheet.Views.Count
        Set view = sheet.Views.Item(i)
        drawCircles view
    Next
End Sub

Sub drawCircles(view)
    Dim oXY(4)
    view.SIZE oXY()
    
    Dim factory As Factory2D
    Set factory = view.Factory2D   

    view.Activate

    factory.CreateCircle oXY(0) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(0) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi

End Sub

细心的朋友注意到以下代码:

    For i = 3 To sheet.Views.Count

这里i从3开始,原因是一个sheet里的views.item(1)代表MainView,views.item(2)代表BackgroundView

    factory.CreateCircle oXY(0) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(0) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(2) - view.yAxisData, 3, 0, 2 * Dpi
    factory.CreateCircle oXY(1) - view.xAxisData, oXY(3) - view.yAxisData, 3, 0, 2 * Dpi

上面的Dpi代表的是pi弧度。

DrawingView

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空