TudorM
Automotive
- Mar 30, 2020
- 100
Hello guys , i am trying to get the edges on Y direction and to fillet them , i found some info on other forum and trying to combine but i am getting an eror and do not know how to solve it , please help :
the error is on refEdge.GetDirection dir
Here is the full code :
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search ("Topology.CGMEdge,sel")
Dim Num_edges1 As Integer
Num_edges1 = selection1.Count
Dim edges_ref() As Reference
ReDim edges_ref(1 To Num_edges1)
Dim i
For i = 1 To Num_edges1
Dim refEdge As Edge
Set refEdge = selection1.Item(i).Reference
Dim dir(1)
refEdge.GetDirection dir
Debug.Print dir(0) & " / " & dir(1) & " / " & dir(2)
If dir(1) = 1 Then
Set edges_ref(i) = selection1.Item(i).Reference
End If
Next
Dim oEdgeFillet1 As ConstRadEdgeFillet
Set oEdgeFillet1 = part1.ShapeFactory.AddNewEdgeFilletWithConstantRadius(edges_ref(1), 1, 3)
For i = 2 To Num_edges1
oEdgeFillet1.AddObjectToFillet edges_ref(i)
Next
oEdgeFillet1.Radius.Value = 3
oEdgeFillet1.EdgePropagation = 1
part1.Update
End Sub
the error is on refEdge.GetDirection dir
Here is the full code :
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search ("Topology.CGMEdge,sel")
Dim Num_edges1 As Integer
Num_edges1 = selection1.Count
Dim edges_ref() As Reference
ReDim edges_ref(1 To Num_edges1)
Dim i
For i = 1 To Num_edges1
Dim refEdge As Edge
Set refEdge = selection1.Item(i).Reference
Dim dir(1)
refEdge.GetDirection dir
Debug.Print dir(0) & " / " & dir(1) & " / " & dir(2)
If dir(1) = 1 Then
Set edges_ref(i) = selection1.Item(i).Reference
End If
Next
Dim oEdgeFillet1 As ConstRadEdgeFillet
Set oEdgeFillet1 = part1.ShapeFactory.AddNewEdgeFilletWithConstantRadius(edges_ref(1), 1, 3)
For i = 2 To Num_edges1
oEdgeFillet1.AddObjectToFillet edges_ref(i)
Next
oEdgeFillet1.Radius.Value = 3
oEdgeFillet1.EdgePropagation = 1
part1.Update
End Sub