FabienF
New member
- Jul 5, 2017
- 19
Hello,
I need to deactivate some products in an assembly comprised of products at different levels( in the tree)
For first level products my code is working:
'--------------------------------------------
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Dim Selection1 As selection
Set productDocument1 = CATIA.ActiveDocument
Set Selection1 = productDocument1.selection
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("productnamelevel1")
Selection1.Clear
Selection1.Add (product2)
CATIA.StartCommand ("Activate / Deactivate Component")
Selection1.Clear
'--------------------------------------------
However for level2 products this code does not work:
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim Selection1 As selection
Set Selection1 = productDocument1.selection
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim product2 As Product
Set product2 = products1.Item("productnamelevel1")
Dim products2 As Products
Set products2 = product2.Products
Dim product3 As Product
Set product3 = products2.Item("productnamelevel2")
Selection1.Clear
Selection1.Add (product3)
CATIA.StartCommand ("Activate / Deactivate Component")
Selection1.Clear
Does anyone has an idea of the solution please ? I know that it is breaking at line catia.startCommand.
Thanking you in advance
I need to deactivate some products in an assembly comprised of products at different levels( in the tree)
For first level products my code is working:
'--------------------------------------------
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Dim Selection1 As selection
Set productDocument1 = CATIA.ActiveDocument
Set Selection1 = productDocument1.selection
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("productnamelevel1")
Selection1.Clear
Selection1.Add (product2)
CATIA.StartCommand ("Activate / Deactivate Component")
Selection1.Clear
'--------------------------------------------
However for level2 products this code does not work:
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim Selection1 As selection
Set Selection1 = productDocument1.selection
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim product2 As Product
Set product2 = products1.Item("productnamelevel1")
Dim products2 As Products
Set products2 = product2.Products
Dim product3 As Product
Set product3 = products2.Item("productnamelevel2")
Selection1.Clear
Selection1.Add (product3)
CATIA.StartCommand ("Activate / Deactivate Component")
Selection1.Clear
Does anyone has an idea of the solution please ? I know that it is breaking at line catia.startCommand.
Thanking you in advance