Sidtha
Aerospace
- Nov 25, 2012
- 36
Hello All,
I have written below code to select the BNS from the catia tree and i am getting all parent node and other details.
But unable to get the properties like show in below picture. Could some one please help me to get the result.
Result should be:
View attachment 8006
Type: Bundle Segment
Reference designator: BNS0001
Diameter: 6.2mm
Bend Radius: 37.2mm
Length: 238.199mm
Flexibility: 3
View attachment 8005
Sub test_BNS()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb As Workbook
Dim ws As Worksheet
Dim MyProduct
Dim ShtNumber As Worksheet
Dim ShtRef As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("FIN_Data")
ws.Range("A2:I100000").ClearContents
lr = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
j = 2
Dim CATIA As Object
On Error Resume Next
Set CATIA = GetObject(, "CATIA.Application")
If Err.Number <> 0 Then
Set CATIA = CreateObject("CATIA.Application")
CATIA.Visible = True
End If
On Error GoTo 0
'--------------------Define CATIA------------------------------------------
Set CATIA = GetObject("", "CATIA.Application")
Set MyDocument = CATIA.ActiveDocument
Set MyProduct = MyDocument.Product
MyRootPN = MyProduct.PartNumber
MyRootInstanceName = MyProduct.Name
MyDSType = Left(MyRootPN, 4)
'--------------------ApplyDESIGN_MODE------------------------------------------
MyProduct.ApplyWorkMode DESIGN_MODE
CATIA.StartCommand ("Fit All In")
'--------------------Select BNS------------------------------------------
Dim objSel As Selection, oSel As Selection
Set objSel = CATIA.ActiveDocument.Selection
objSel.Search ("Name=BNS*,all")
j = 2
For i = 1 To objSel.Count
Set prod1 = objSel.Item(i).LeafProduct
Set myParameters = prod1.Parameters
Dim element As Object
Set element = objSel.Item(i).Value
partParent = objSel.Item2(i).LeafProduct.PartNumber
PartZone = objSel.Item2(i).LeafProduct.Parent.Parent.PartNumber
ws.Cells(j, 1).Value = MyRootPN
ws.Cells(j, 2).Value = PartZone
ws.Cells(j, 3).Value = partParent
j = j + 1
Next i
End Sub
I have written below code to select the BNS from the catia tree and i am getting all parent node and other details.
But unable to get the properties like show in below picture. Could some one please help me to get the result.
Result should be:
View attachment 8006
Type: Bundle Segment
Reference designator: BNS0001
Diameter: 6.2mm
Bend Radius: 37.2mm
Length: 238.199mm
Flexibility: 3
View attachment 8005
Sub test_BNS()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb As Workbook
Dim ws As Worksheet
Dim MyProduct
Dim ShtNumber As Worksheet
Dim ShtRef As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("FIN_Data")
ws.Range("A2:I100000").ClearContents
lr = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
j = 2
Dim CATIA As Object
On Error Resume Next
Set CATIA = GetObject(, "CATIA.Application")
If Err.Number <> 0 Then
Set CATIA = CreateObject("CATIA.Application")
CATIA.Visible = True
End If
On Error GoTo 0
'--------------------Define CATIA------------------------------------------
Set CATIA = GetObject("", "CATIA.Application")
Set MyDocument = CATIA.ActiveDocument
Set MyProduct = MyDocument.Product
MyRootPN = MyProduct.PartNumber
MyRootInstanceName = MyProduct.Name
MyDSType = Left(MyRootPN, 4)
'--------------------ApplyDESIGN_MODE------------------------------------------
MyProduct.ApplyWorkMode DESIGN_MODE
CATIA.StartCommand ("Fit All In")
'--------------------Select BNS------------------------------------------
Dim objSel As Selection, oSel As Selection
Set objSel = CATIA.ActiveDocument.Selection
objSel.Search ("Name=BNS*,all")
j = 2
For i = 1 To objSel.Count
Set prod1 = objSel.Item(i).LeafProduct
Set myParameters = prod1.Parameters
Dim element As Object
Set element = objSel.Item(i).Value
partParent = objSel.Item2(i).LeafProduct.PartNumber
PartZone = objSel.Item2(i).LeafProduct.Parent.Parent.PartNumber
ws.Cells(j, 1).Value = MyRootPN
ws.Cells(j, 2).Value = PartZone
ws.Cells(j, 3).Value = partParent
j = j + 1
Next i
End Sub
Last edited: