Hello,
I have issue with getting instance name path of selected item to root product.
Result that I want to get from CATIA in this case is string with the following path: "Product2.1\Part2.1"
Additional thing is that CATIA tree will be not known in the future. Getting path formula should work with different multilevel trees.
Simple CATIA tree:
+--------+
!Product1!
+--------+
VBA Code:
Dim Sel1 As Object
Dim Filter1(0)
Dim Status1 As String
Dim objSelPrd1 As Product
' [ Part Selection ] ***
Set Sel1 = CATIA.ActiveDocument.Selection
Filter1(0) = "Product"
Status1 = Sel1.SelectElement2(Filter1, "SELECT PART", False)
' [ Switch Part to Design Mode ] ***
Set objSelPrd1 = Sel1.Item2(1).LeafProduct
objSelPrd1.ApplyWorkMode DESIGN_MODE
MsgBox Sel1.Item2(1).LeafProduct.Name 'gives result "Part2.1"
MsgBox Sel1.Item2(1).LeafProduct.Parent.Name 'gives result "Products"
MsgBox Sel1.Item2(1).LeafProduct.Parent.Parent.Name 'gives result "Product2.1" but I don't know how many levels CATIA tree will have in different products
So I'm searching for a solution to get whole path as string from Part chosen by user no matter of CATIA tree complexity - in this case "Product2.1\Part2.1"
Thanks in advance,
Michal
I have issue with getting instance name path of selected item to root product.
Result that I want to get from CATIA in this case is string with the following path: "Product2.1\Part2.1"
Additional thing is that CATIA tree will be not known in the future. Getting path formula should work with different multilevel trees.
Simple CATIA tree:
+--------+
!Product1!
+--------+
!
+- Product2 (Product2.1)
!
+- Part1 (Part1.1)
+- Part1 (Part2.1) <- Selected Item by user
VBA Code:
Dim Sel1 As Object
Dim Filter1(0)
Dim Status1 As String
Dim objSelPrd1 As Product
' [ Part Selection ] ***
Set Sel1 = CATIA.ActiveDocument.Selection
Filter1(0) = "Product"
Status1 = Sel1.SelectElement2(Filter1, "SELECT PART", False)
' [ Switch Part to Design Mode ] ***
Set objSelPrd1 = Sel1.Item2(1).LeafProduct
objSelPrd1.ApplyWorkMode DESIGN_MODE
MsgBox Sel1.Item2(1).LeafProduct.Name 'gives result "Part2.1"
MsgBox Sel1.Item2(1).LeafProduct.Parent.Name 'gives result "Products"
MsgBox Sel1.Item2(1).LeafProduct.Parent.Parent.Name 'gives result "Product2.1" but I don't know how many levels CATIA tree will have in different products
So I'm searching for a solution to get whole path as string from Part chosen by user no matter of CATIA tree complexity - in this case "Product2.1\Part2.1"
Thanks in advance,
Michal