CATIA Automation对象架构-Application对象详解(一)Document/SettingControllers

CATIA Automation对象架构

下面是CATIA Automation的对象架构,可以看出,Application是顶层对象。
在这里插入图片描述

Application对象

从对象架构中,可以看到Application对象下的子对象主要如下:

1. Documents: 是CATIA程序目前操作的所有文档的集合。

主要文档类型如下: 主要文档类型如下:
- [ ] PartDocument:零件文档-单个零件的3D数据
- [ ] ProductDocument:产品文档-产品和部件总成的3D数据
- [ ] DrawingDocument:图纸文档-2D图纸
- [ ] AnalysisDocument:分析文档-网格分析文件用于CAE分析等
- [ ] ProcessDocument:工艺文档-工艺设计文件,例如工艺仿真,人机模拟等
- [ ] FunctionalDocument:功能设计文档-设计一些复杂对象和函数的文档
- [ ] MaterialDocument:材料定义文档
- [ ] CatalogDocument:库文档-定义一些模板化的库文件用于调用
在CATIA中的文档如果不清楚类型时,可以定义为INFITF.Document(可简写Docment),这是一种泛型文档。
在获取文档类型以后,再定义为具体的类型文档。

'获取CATA Application对象
Dim oDoc As INFITF.Document
Dim oPartDoc As PartDocument
Dim oProductDoc As ProductDocument
Dim oDrawingDoc As DrawingDocument

'CATIA即为Application对象
'利用泛型对象oDoc获得CAITA当前文档
Set oDoc = CATIA.ActiveDocument

'利用typename或者文档类型名称再重新定义类型对象
If VBA.TypeName(oDoc) = "ProductDocument" Then
   Set oProductDoc = oDoc
ElseIf VBA.TypeName(oDoc) = "PartDocument" Then
   Set oPartDoc = oDoc
ElseIf VBA.TypeName(oDoc) = "DrawingDocument" Then
   Set oDrawingDoc = oDoc
End If
  1. ActiveDocument:获取当前正在前端运行的文档。ActiveDocument具有Document对象的全部属性和方法,如:
    Document属性:
    (1)Document.Cameras相机集合:返回文档具有的所有相机位置,如正/侧/后等。
    Camera:代表观察的相机位置
    相机的主要位置:
    * iso :轴侧,从1,1,1位置观察
    The origin is on a line with (1,1,1) as components with positive coordinates
    * front:前 , 起点在X轴且坐标为正
    The origin is on the x axis with a positive x coordinate
    * back 前 , 起点在X轴且坐标为负
    The origin is on the x axis with a negative x coordinate
    * left 左 , 起点在Y轴且坐标为正
    The origin is on the y axis with a positive y coordinate
    * right 右 , 起点在Y轴且坐标为负
    The origin is on the y axis with a negative y coordinate
    * top 顶 , 起点在Z轴且坐标为正
    The origin is on the z axis with a positive z coordinate
    * bottom 底 , 起点在Z轴且坐标为负
    The origin is on the z axis with a negative z coordinate

      相机的类型:Camera.type有两种
        enum CatCameraType {
                  catCamera2D,
                   catCamera3D}
    

    Document.Cameras是文档的观察相机集合,是配合Application.Windows.item(i).Viewer来使用的, 可以切换观察视角,放大缩小移动转动视图等。

' catCamera2D=1
' catCamera3D=2

Dim xCam As Camera
Dim i As Integer

'Application从当前窗口当前位置创建一个摄像机
CATIA.ActiveWindow.ActiveViewer.NewCamera
i = 0
For Each xCam In oDoc.Cameras
   i = i + 1
   Debug.Print i & "  " & xCam.Name & "  " & xCam.Type
Next

debug结果: 其中1,2相机是利用ActiveViewer创建的。
在这里插入图片描述
(2)Document.Selection文档的选择集合,可用来获取文档的选择对象,进行后续操作。
如选择点,实体,片体等,也可以选择文本,标注等。
Selection可以添加,清空,删除也可以复制,粘贴,以及利用对话框,过滤器等选择对象,包括选择2D对象和3D对象,功能十分强大。后面会逐一分析。
在这里插入图片描述
下面这段代码是选择当前Product下面的所有子集

'获取document的选择集合
Dim oSel As Selection
Dim i As Integer
Set oSel = oDoc.Selection
If VBA.TypeName(oDoc) = "ProductDocument" Then
   Set oProductDoc = oDoc
   n = oProductDoc.Product.Products.Count
   If n > 1 Then
       For i = 1 To n
          oSel.Add oProductDoc.Product.Products.Item(i)
       Next
   End If
End If

在这里插入图片描述

(3)Workbench工作台
Workbench 概念 : 针对的是一种特定的工作, CATIA 由 workbench 构架所组成,每一个 workbench 针对的是一种特定的工作,但有可能 构架所组成,多个模块使用一个workbench。是CATIA完成某类功能(或产品模块)的菜单集合。
在这里插入图片描述

Set oDoc = CATIA.ActiveDocument
Set oWorkBench = oDoc.GetWorkbench("StrWorkbench")   '获取结构工作台
Set strFactory = oProductDoc.Product.GetTechnologicalObject("StructureObjectFactory")
Set oWorkBench = oDoc.GetWorkbench("KinematicsWorkbench") '获取运动分析工作台
Set oWorkBench = oDoc.GetWorkbench("NavigatorWorkbench")
Set oWorkBench = oDoc.GetWorkbench("SPAWorkbench")  '获取空间分析工作台,如测量等
Set oWorkBench = oDoc.GetWorkbench("ArrWorkbench")
Set oWorkBench = oDoc.GetWorkbench("SchWorkbench")
Set oWorkBench = oDoc.GetWorkbench("SceneWorkbench")
Set oWorkBench = oDoc.GetWorkbench("PCBWorkbench")
Set oWorkBench = oDoc.GetWorkbench("Structural")

2. SettingControllers: 返回一个CATIA系统设置的集合

在这里插入图片描述

显示当前结果为75个SettingController
所有的SettingController都有2个参数:
(1)ioAdminLevel:参数的管理级别
(2)ioLocked :锁定的状态
锁定和解锁的方法: HRESULT SetPARAMETERLock(in boolean iLocked);
HRESULT GetPARAMETERInfo (inout CATBSTR ioAdminLevel,
inout CATBSTR ioLocked,
out /IDLRETVAL/ boolean oModified);
如果锁定,则使用管理员的默认值,需要修改者权限符合要求才能修改,否则不能;没有锁定则可以使用创建的参数值。
所有的SettingController都有5个方法:
在这里插入图片描述
参数的设置在VBA中还没有成功应用,目前通过Application只能获取SettingControllers集合。

发布了14 篇原创文章 · 获赞 6 · 访问量 1369

猜你喜欢

转载自blog.csdn.net/qq_43662503/article/details/84038179