Hi!
i would like to program a macro that will select:
-all Bodies named "name_1" and add them to new body with name "new group 1"
-all Bodies named "name_2" and add them to new body with name "new group 2"
-all Bodies named "name_3" and add them to new body with name "new group 3".
i successfully wrote this code on my CATIA R20, and works OK. It adds all bodies in new body. But then i tried to run a macro on CATIA R19 and R24, but it doesnt work! In R19/R24 it doesn't add all bodies named "name_1" but it adds only one body in new body! please anyone could tell me what could be the problem? see code below.. (only for one name_1)
I appreciate any response, thank you in advance
-----------------
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Set objSel = partDocument1.Selection
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Set shapeFactory1 = part1.ShapeFactory
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
objSel.Clear
'******************name_1*********************
objSel.Search ("Name=name_1,all")
objcount = objSel.Count
Set body1 = bodies1.Add()
body1.Name = "new_name_1"
Set body1 = bodies1.Item("new_name_1")
part1.InWorkObject = body1
For i = 1 To objcount
Set body11 = bodies1.Item("name_1")
Set add1 = shapeFactory1.AddNewAdd(body11)
Next
objSel.Clear
End Sub
i would like to program a macro that will select:
-all Bodies named "name_1" and add them to new body with name "new group 1"
-all Bodies named "name_2" and add them to new body with name "new group 2"
-all Bodies named "name_3" and add them to new body with name "new group 3".
i successfully wrote this code on my CATIA R20, and works OK. It adds all bodies in new body. But then i tried to run a macro on CATIA R19 and R24, but it doesnt work! In R19/R24 it doesn't add all bodies named "name_1" but it adds only one body in new body! please anyone could tell me what could be the problem? see code below.. (only for one name_1)
I appreciate any response, thank you in advance
-----------------
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Set objSel = partDocument1.Selection
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Set shapeFactory1 = part1.ShapeFactory
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
objSel.Clear
'******************name_1*********************
objSel.Search ("Name=name_1,all")
objcount = objSel.Count
Set body1 = bodies1.Add()
body1.Name = "new_name_1"
Set body1 = bodies1.Item("new_name_1")
part1.InWorkObject = body1
For i = 1 To objcount
Set body11 = bodies1.Item("name_1")
Set add1 = shapeFactory1.AddNewAdd(body11)
Next
objSel.Clear
End Sub