Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA Macro Slows Down After Some Executions

Status
Not open for further replies.

Eren C.

Aerospace
Mar 26, 2019
1
TR
Hello,

I am trying to write a code to create points. These points will be placed on the all edges of a Pad (in the middle of edges).

In first executions, it takes less than 1 seconds to finish one pad. However, after some executions, it takes more than 4 seconds for a pad.

Could you please help me what I am missing here? Thanks a lot.

Here is my code: (I think the line bolded is the issue here. I am calculating the time over this line. At first, it takes nearly 0 seconds. After that, it takes nearly 0.5 seconds to execute this line.)

Code:
Sub CATMain()
Dim Selection
Dim InputObjectType(0)
Set Part1 = CATIA.ActiveDocument.Part
Set Selection = CATIA.ActiveDocument.Selection
Set HSF = Part1.HybridShapeFactory
Selection.Clear
InputObjectType(0) = "AnyObject"
Status = Selection.SelectElement3(InputObjectType, "Select a Pad", False, CATMultiSelTriggWhenUserValidatesSelection, False)
If Status = "Cancel" Then Exit Sub
Selection.Search ("Topology.CGMEdge,sel")
Part1.InWorkObject = Part1.Bodies.Item(Selection.Item2(1).Value.Parent.Parent.Parent.Name)
For i = 1 To Selection.Count
 [b]Set refPoints = HSF.AddNewPointOnCurveFromPercent(Selection.Item2(i).Value, 0.5,True)[/b]
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top