Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Catia Macro: How to Get Part/Product Document interface from Assembly Selection
(OP)
Hello Friends,
I have an assembly consisting of many Parts/Products. I want to get Part/Product Document Interface/Object of selected item from specification tree so that I can access its various properties like FullName, Path etc.
Please help
I have an assembly consisting of many Parts/Products. I want to get Part/Product Document Interface/Object of selected item from specification tree so that I can access its various properties like FullName, Path etc.
Please help





RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Try the following GetSelectedProductDocument helper function
CODE --> VBA
Function GetSelectedProductDocument() As Document Dim oSelection As Selection Set oSelection = CATIA.ActiveDocument.Selection If oSelection.Count > 0 Then If TypeName(oSelection.Item(1).Value) = "Product" Then Set GetSelectedProductDocument = oSelection.Item(1).Value.ReferenceProduct.Parent End If End If End FunctionCODE --> VBA
Sub TestOfGetSelectedProductDocument() Dim SelectedDocument As Document Set SelectedDocument = GetSelectedProductDocument If Not (SelectedDocument Is Nothing) Then MsgBox "Selected Document: " & SelectedDocument.FullName End If End Sub-GEL
Imposible is nothing.
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
-GEL
Imposible is nothing.
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
If InStr(CATIA.ActiveDocument.Name, ".CATProduct") < 1 Then
MsgBox "Active CATIA Document is not a Product. Open a Product file and run this script again.", , msgboxtext
Exit Sub
End If
partName = InputBox("Please Enter the Filename")
Call ListingNames(productDocument1.Product)
End Sub
Sub ListingNames(current_prod)
If current_prod.Products.Count > 0 Then
For i = 1 To current_prod.Products.Count
Call ListingNames(current_prod.Products.Item(i))
Dim returnName(current_prod.Products.Count) As String
returnName(i) = current_prod.Products.Item(i)
If partName = returnName(i)
MsgBox partName
End if
Next i
Else
'MsgBox current_prod.ReferenceProduct.Parent.Name
End If
End Sub
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
If InStr(CATIA.ActiveDocument.Name, ".CATProduct") < 1 Then
MsgBox "Active CATIA Document is not a Product. Open a Product file and run this script again.", , msgboxtext
Exit Sub
End If
Call ListingNames(productDocument1.Product)
End Sub
Sub ListingNames(current_prod)
Dim partName As String
partName = InputBox("Please Enter the Filename")
If current_prod.Products.Count > 0 Then
For i = 1 To current_prod.Products.Count
Call ListingNames(current_prod.Products.Item(i))
'MsgBox current_prod.Products.Item(i).Name
Next i
Else
If partName = current_prod.ReferenceProduct.Parent.Name Then
MsgBox "succesful"
Else
MsgBox "try again"
End If
MsgBox current_prod.ReferenceProduct.Parent.Name
End If
End Sub
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Check this link for a macro http://v5vb.wordpress.com/download/sel-obj-info-ma...
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
RE: Catia Macro: How to Get Part/Product Document interface from Assembly Selection
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...