Assembling parts in Product with macro
Assembling parts in Product with macro
(OP)
Hi, i need macro who will assemble for example 10 instances of the same part in product in different places. Before that i had created axis System for each Location, so i ll have only one constraint in assembly, coincidence between created axis and axis in part.
1. Open part for Assembling
2. select Axis for instances(this will be in one part already inside the product)
3. Assembled
any hints and idea pls
1. Open part for Assembling
2. select Axis for instances(this will be in one part already inside the product)
3. Assembled
any hints and idea pls





RE: Assembling parts in Product with macro
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim constraints1 As Collection
Set constraints1 = product1.Connections("CATIAConstraints")
'-----------------------------------------------------------------------------------------
'this is for coincidence
'-----------------------------------------------------------------------------------------
Dim InputObjectType(0)
Dim InputDocType(0)
InputDocType(0) = "Part"
Set ActiveDoc = CATIA.ActiveDocument
Set osel = ActiveDoc.Selection
InputObjectType(0)= "AxisSystem"
Result = osel.SelectElement2(InputObjectType, "Select a Axis System ", False)
If Result = "Cancel" Then
MsgBox ("Command Canceled")
Exit Sub
End If
Dim reference1 As Reference
reference1=osel.item(1).name
Dim reference2 As Reference
Set reference2 = product1.CreateReferenceFromName("PRODUCT1/PART2.2/!PART2/Absolute Axis System")
Dim constraint1 As Constraint
Set constraint1 = constraints1.AddBiEltCst(2, reference1, reference2)
product1.Update