-
1
- #1
Hi,
I want to create a macro with the next structure:
Input: a geometrical set which contains a surface and a lot of points (200 up to 1000 points)
Output: a new geometrical set that contain normal to input surface through each input point
I have already done a the next script.
I have to specify that in my geometrical set the surface is on the firs position of selection and after that are those points.
My macro fails at the red line, if I replace parameters1.Item(1) with parameters1.Item("surface_name") it works, but i want to make the macro for any different surfaces names.
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Search "(CATGmoSearch.Surface + CATGmoSearch.Point),sel"
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
Set hybridShapeSurfaceExplicit1 = parameters1.Item(1)
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
Set hybridShapes1 = hybridBody1.HybridShapes
Dim i As Integer
For i = 2 To selection1.Count
Set hybridShapePointOnSurface1 = hybridShapes1.Item(i)
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointOnSurface1)
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, -15#, 15#, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
Next i
End Sub
So any idea?
I want to create a macro with the next structure:
Input: a geometrical set which contains a surface and a lot of points (200 up to 1000 points)
Output: a new geometrical set that contain normal to input surface through each input point
I have already done a the next script.
I have to specify that in my geometrical set the surface is on the firs position of selection and after that are those points.
My macro fails at the red line, if I replace parameters1.Item(1) with parameters1.Item("surface_name") it works, but i want to make the macro for any different surfaces names.
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Search "(CATGmoSearch.Surface + CATGmoSearch.Point),sel"
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set parameters1 = part1.Parameters
Set hybridShapeSurfaceExplicit1 = parameters1.Item(1)
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
Set hybridShapes1 = hybridBody1.HybridShapes
Dim i As Integer
For i = 2 To selection1.Count
Set hybridShapePointOnSurface1 = hybridShapes1.Item(i)
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointOnSurface1)
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, -15#, 15#, False)
hybridBody1.AppendHybridShape hybridShapeLineNormal1
part1.InWorkObject = hybridShapeLineNormal1
part1.Update
Next i
End Sub
So any idea?