Hallo, all
I think this script is very simple but it doesn't work as what I want.
I recoreded the macro to copy and paste a cataprt or catproduct.
And I modified a little bit like below script.
To copy "Part1" in "Product1" works very well.
But it doesn't work in "Product2".
I uploaded the picture of tree to attatched file.
I want to copy and paste a CATPart or CATProduct in every product.
Could you check my script?!
Link
I think this script is very simple but it doesn't work as what I want.
I recoreded the macro to copy and paste a cataprt or catproduct.
And I modified a little bit like below script.
To copy "Part1" in "Product1" works very well.
But it doesn't work in "Product2".
I uploaded the picture of tree to attatched file.
I want to copy and paste a CATPart or CATProduct in every product.
Could you check my script?!
Link
Code:
Language="VBSCRIPT"
Sub CATMain()
Dim Inputobject(0)
Dim Selection(1)
Set productDocument1 = CATIA.ActiveDocument
Set selection1 = productDocument1.Selection
selection1.Clear
Set product1 = productDocument1.Product
Set products1 = product1.Products
MsgBox "Please, Select a Product for linked part."
Set Selection(0) = CATIA.ActiveDocument.Selection
Selection(0).Clear
Inputobject(0) = "Product"
Status = Selection(0).SelectElement2(Inputobject, "Select a Product", True)
SelObj1 = Selection(0).Item(1).Value.Name
'Set product2 = products1.Item("Product1.1")
Set product2 = products1.Item(SelObj1)
Set products2 = product2.Products
MsgBox "Please, Select a Part to copy."
Set Selection(1) = CATIA.ActiveDocument.Selection
Selection(1).Clear
Inputobject(0) = "Product"
Status = Selection(1).SelectElement2(Inputobject, "Select a Product", True)
SelObj2 = Selection(1).Item(1).Value.Name
'Set product3 = products2.Item("Part1.3")
Set product3 = products2.Item(SelObj2)
selection1.Add product3
selection1.Copy
Set productDocument1 = CATIA.ActiveDocument
Set selection2 = productDocument1.Selection
selection2.Clear
selection2.Add product2
selection2.Paste
End Sub