forked from 454a1/CATIA_VBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path创建坐标点.bas
55 lines (42 loc) · 1.57 KB
/
创建坐标点.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Attribute VB_Name = "创建坐标点"
Sub CATMain()
'初始基本操作
'***************************************************
On Error Resume Next
Dim oPart As Part
Dim oHBodies As HybridBodies
Dim oHBody As HybridBody
Dim oHSF As HybridShapeFactory
Set oPart = CATIA.ActiveDocument.Part
If Err.Number <> 0 Then
Dim oDoc As Document
Set oDoc = CATIA.Documents.Add("Part")
Set oPart = oDoc.Part
End If
On Error GoTo 0
Set oHBodies = oPart.HybridBodies
Set oHSF = oPart.HybridShapeFactory
Set oHBody = oHBodies.Add()
'***************************************************
'创建坐标点
Dim oPoint1 As Point, oPoint2 As Point, oPoint3 As Point
Set oPoint1 = oHSF.AddNewPointCoord(0, 2, 3)
Set oPoint2 = oHSF.AddNewPointCoord(10, 5, 8)
Set oPoint3 = oHSF.AddNewPointCoord(8, 9, 10)
oHBody.AppendHybridShape oPoint1
oHBody.AppendHybridShape oPoint2
oHBody.AppendHybridShape oPoint3
'是否隐藏创建的点?
'以创建的点为参考
Dim oRefPoint1 As Reference, oRefPoint2 As Reference, oRefPoint3 As Reference
Set oRefPoint1 = oPart.CreateReferenceFromObject(oPoint1)
Set oRefPoint2 = oPart.CreateReferenceFromObject(oPoint2)
Set oRefPoint3 = oPart.CreateReferenceFromObject(oPoint3)
'隐藏点
oHSF.GSMVisibility oRefPoint1, 0
oHSF.GSMVisibility oRefPoint2, 0
oHSF.GSMVisibility oRefPoint3, 0
'更新几何图形集,更新Part文档
oPart.UpdateObject oHBody
oPart.Update
End Sub