Hi All,
I am trying to create macro with input as GS in which only Surfaces are there and output expected is to create a point which is CG of each surface and then create a normal to respective surface with respective point as input.
I need help in putting this macro in loop i mean point and line to be created for all the surfaces in the input GS.
When I try to run this macro its failing in LINE 41 WHICH I have highlighted in red color.
Thanks in advance for any suggestion or guidance.
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
'Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
MsgBox "Select Geometrical set."
Dim oSelection ' 'As Selection
Dim InputObjectType(0)
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = "HybridBody"
Status = oSelection.SelectElement2(InputObjectType, "Select Geometrical set.", True)
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
Set hybridShapeSurfaceExplicit1 = parameters1.Item("Surface.679") 'this is one of the surfaces in my GS but I want for all the surfaces in GS
Set hybridBody1 = hybridBodies1.Add()
part1.UpdateObject hybridBody1
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)
Set parameters2 = part1.Parameters
[highlight #CC0000]Set hybridShapePointExplicit1 = parameters2.Item("")[/highlight]
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointExplicit1)
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, 0.000000, 1000.000000, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
End Sub
I am trying to create macro with input as GS in which only Surfaces are there and output expected is to create a point which is CG of each surface and then create a normal to respective surface with respective point as input.
I need help in putting this macro in loop i mean point and line to be created for all the surfaces in the input GS.
When I try to run this macro its failing in LINE 41 WHICH I have highlighted in red color.
Thanks in advance for any suggestion or guidance.
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
'Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
MsgBox "Select Geometrical set."
Dim oSelection ' 'As Selection
Dim InputObjectType(0)
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Clear
InputObjectType(0) = "HybridBody"
Status = oSelection.SelectElement2(InputObjectType, "Select Geometrical set.", True)
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
Set hybridShapeSurfaceExplicit1 = parameters1.Item("Surface.679") 'this is one of the surfaces in my GS but I want for all the surfaces in GS
Set hybridBody1 = hybridBodies1.Add()
part1.UpdateObject hybridBody1
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)
Set parameters2 = part1.Parameters
[highlight #CC0000]Set hybridShapePointExplicit1 = parameters2.Item("")[/highlight]
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointExplicit1)
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, 0.000000, 1000.000000, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
End Sub