enigmabindra
Mechanical
Here is the script....its working...but if 3 bodies r there
then it is assembling 2nd body 2times and
not assembling the 3rd body. Anybody pls correct
the script. Thanks in advance...
Sub CATMain()
Dim partDocument1 As Document
On Error Resume Next
Set partDocument1 = CATIA.ActiveDocument
If Err.Number <> 0 Then
MsgBox "Open a CATPart first!!!", vbCritical, "Error"
Exit Sub
End If
Dim part1 As Part
On Error Resume Next
Set part1 = partDocument1.Part
If Err.Number <> 0 Then
MsgBox "This macro is good only for a CATPart!!!", vbCritical, "Error"
Exit Sub
End If
Dim Bodies1 As Bodies
Set bodies1 = part1.Bodies
n = bodies1.Count
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")'The fisrt body of my CATPart
Dim shapeFactory1 As Factory
Set shapeFactory1 = part1.ShapeFactory
Dim i As Integer
For i = 2 To n
part1.InWorkObject = body1
Dim body2 As Body
Set body2 = bodies1.Item(i)
'~ MsgBox body2.Name
Dim assemble1 As Assemble
Set assemble1 = shapeFactory1.AddNewAssemble(body2)
Next
part1.UpdateObject assemble1
'~ MsgBox "Finish"
Part1.Update
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
viewer3D1.Reframe
Set viewpoint3D1 = viewer3D1.Viewpoint3D
Set body1 = Bodies1.Item("PartBody")
Part1.InWorkObject = Body1
End Sub
then it is assembling 2nd body 2times and
not assembling the 3rd body. Anybody pls correct
the script. Thanks in advance...
Sub CATMain()
Dim partDocument1 As Document
On Error Resume Next
Set partDocument1 = CATIA.ActiveDocument
If Err.Number <> 0 Then
MsgBox "Open a CATPart first!!!", vbCritical, "Error"
Exit Sub
End If
Dim part1 As Part
On Error Resume Next
Set part1 = partDocument1.Part
If Err.Number <> 0 Then
MsgBox "This macro is good only for a CATPart!!!", vbCritical, "Error"
Exit Sub
End If
Dim Bodies1 As Bodies
Set bodies1 = part1.Bodies
n = bodies1.Count
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")'The fisrt body of my CATPart
Dim shapeFactory1 As Factory
Set shapeFactory1 = part1.ShapeFactory
Dim i As Integer
For i = 2 To n
part1.InWorkObject = body1
Dim body2 As Body
Set body2 = bodies1.Item(i)
'~ MsgBox body2.Name
Dim assemble1 As Assemble
Set assemble1 = shapeFactory1.AddNewAssemble(body2)
Next
part1.UpdateObject assemble1
'~ MsgBox "Finish"
Part1.Update
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
viewer3D1.Reframe
Set viewpoint3D1 = viewer3D1.Viewpoint3D
Set body1 = Bodies1.Item("PartBody")
Part1.InWorkObject = Body1
End Sub