Hi friends
I try to find a macro that can you read me the total number of holes of a catia part
The code is the follow:
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
dim selection1 as selection
set selection1=CATIA.activedocument.selection
selection1.clear
for i = 1 to shapes1.count
selection1.add shapes1.Item(i)
NEXT
Dim xSelObj() As Variant
Dim xObj As Variant
Dim n as Integer
Dim myObj As AnyObject
Dim nCount As Integer
nCount = 0
for n= 0 to shapes1.count
On Error Resume Next
Set myObj = selection1.FindObject("CATIAHole")
ReDim Preserve xSelObj(nCount)
Set xSelObj(nCount) = myObj
nCount = nCount + 1
next
' Listing holes
Dim sList As String
Dim nI As Integer
'Loop for message
For nI =0 To ncount-3
dim referenceX as reference
Set referenceX = part1.CreateReferenceFromObject(xSelObj(nI))
Next
part1.Update
End Sub
My Problem is that this macro can´t read the hole made with a rectangular or circullar pateerm
If it posible, someone can you help me whit this
And How can export the information of this hole (Thread, length...etc)
Thank you very much for all
I try to find a macro that can you read me the total number of holes of a catia part
The code is the follow:
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
dim selection1 as selection
set selection1=CATIA.activedocument.selection
selection1.clear
for i = 1 to shapes1.count
selection1.add shapes1.Item(i)
NEXT
Dim xSelObj() As Variant
Dim xObj As Variant
Dim n as Integer
Dim myObj As AnyObject
Dim nCount As Integer
nCount = 0
for n= 0 to shapes1.count
On Error Resume Next
Set myObj = selection1.FindObject("CATIAHole")
ReDim Preserve xSelObj(nCount)
Set xSelObj(nCount) = myObj
nCount = nCount + 1
next
' Listing holes
Dim sList As String
Dim nI As Integer
'Loop for message
For nI =0 To ncount-3
dim referenceX as reference
Set referenceX = part1.CreateReferenceFromObject(xSelObj(nI))
Next
part1.Update
End Sub
My Problem is that this macro can´t read the hole made with a rectangular or circullar pateerm
If it posible, someone can you help me whit this
And How can export the information of this hole (Thread, length...etc)
Thank you very much for all