inventor二次开发-课程4-你的画布你来说

| 返回总目录 | 前一课 | 后一课 |

1.坐标系的可见性

(1)坐标系的对象

注:可以下载英文语言包,安装到现有的inventor,查看英文版的界面,更有利于我们对照编程

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oua2eouR-1583056432146)(图片/对象.png)]

英文中文
Plane
Axis
Point
2D Sketch二维草图
3D Sketch三维草图

(2)坐标系中的对象关系

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OBOII33j-1583056432149)(图片/坐标系的对象关系.png)]

(3)坐标系中的常用方法属性

  1. WorkPlane.Delete( [*RetainDependents*] As Boolean ) 删除方法
  2. WorkPlane.Name() As String 名字属性
  3. WorkPlane.Visible() As Boolean 可见性属性
  4. WorkPlanes.Count() As Long 所有工作平面的个数属性
  5. WorkPlanes.Item( *Index* As Variant ) As WorkPlane 可迭代属性

注:对于WorkAxes 和 WorkPoints也具有同样的方法属性

(4)例子

功能:按下Button11按钮,依次显示工作平面的名字,并且使第三个平面可见

注:对于WorkAxes 和 WorkPoints也具有同样的操作

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        '定义模型树的对象变量
        Dim partDef As PartComponentDefinition
        partDef = _invApp.ActiveDocument.ComponentDefinition
        '遍历所有对象的
        Dim num As Integer
        num = partDef.WorkPlanes.Count '获取个数
        For i = 1 To num
            MsgBox("该文件有平面" & num & "个," & "其中" & partDef.WorkPlanes.Item(i).Name & "是第" & i & "个。")
        Next
		'设置第二个平面被删除,坐标系的平面不可删除
        'partDef.WorkPlanes.Item(2).Delete()
        '设置第三个平面可见
        partDef.WorkPlanes.Item(3).Visible = True
    End Sub

2.二维草图的基本操作

(1)原文

PartComponentDefinition.Sketches Property

Parent Object: PartComponentDefinition

Description

Gets the PlanarSketches collection object that encapsulates all of the planar sketches defined in this ComponentDefinition.

Syntax

PartComponentDefinition.Sketches() As PlanarSketches

PlanarSketches Object

Description

The PlanarSketches collection object provides access to all of the objects and provides methods to create additional PlanarSketch objects. See the article in the overviews section.

(2)主要方法和属性

Sketches(PlanarSketches)

NameDescription
Add()方法创建一个新的二维草图
Count 属性返回该集合里的草图个数
Item属性允许通迭代的方式访问每一个成员

Sketche(PlanarSketche)

NameDescription
Delete()删除方法
Edit()使得草图位于编辑状态方法
ExitEdit()使得草图退出编辑状态方法
name名字属性
Visible可见性属性

(3)封装代码

Private Sub New2DSketch()
        partDef = inventorApp.ActiveDocument.ComponentDefinition
        '创建一个二维草图
        Dim sketch1 As PlanarSketch
        sketch1 = partDef.Sketches.Add(partDef.WorkPlanes.Item(3))
        '草图的状态处于编辑状态
        sketch1.Edit()
    End Sub

3.三维草图的基本操作

(1)原文

PartComponentDefinition.Sketches3D Property

Parent Object: PartComponentDefinition

Description

Property that returns the Sketches3D collection object that encapsulates all of the 3D sketches defined in this ComponentDefinition.

Syntax

PartComponentDefinition.Sketches3D() As Sketches3D

Sketch3D Object

Description

The Sketch3D object provides access to the current contents of a specific 3D sketch and its related properties and methods. See the article in the overviews section.

(2)主要方法和属性

Sketches3D

NameDescription
Add()方法创建一个新的三维草图
Count 属性返回该集合里的草图个数
Item属性允许通迭代的方式访问每一个成员

Sketch3D

NameDescription
Delete()删除方法
Edit()使得草图位于编辑状态方法
ExitEdit()使得草图退出编辑状态方法
name名字属性
Visible可见性属性

(3)封装代码

实现:创建一个三维草图

注意:在创建二维草图和三维草图的区别在于,二维草图需要一个平面,而三维草图不需要。

Private Sub New3DSketch()
        partDef = inventorApp.ActiveDocument.ComponentDefinition
    '创建一个三维草图
        Dim sketch1 As PlanarSketch
        sketch1 = partDef.Sketches.Add
        '草图的状态处于编辑状态
        sketch1.Edit()
 End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值