Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Catvba Edge fillet on Y direction 4

Status
Not open for further replies.

TudorM

Automotive
Mar 30, 2020
99
0
6
AT
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 :
Captureghfghgfhf_wsiqbu.jpg


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
 
Replies continue below

Recommended for you

On dir(2) it worked but selected only 2 edges out of 4 ... and on dir(0) and (1) same error like in picture above .

 
dir(2) is the dimension of the array dir : dir(0), dir(1) and dir(2) will be the 3 values that define the direction of the edge (like x,y,z)

so if you want only edge along x you will test dir(0) = 1



Eric N.
indocti discant et ament meminisse periti
 
also i might be wrong but you ReDim edges_ref the the count of edge from selection.
If you have 4 edges in selection and they are coming in the following order ( alongX, alongY, alongX, alongY ) and you work only on edge along X your edges_ref will be ( edge1, Nothing, edge3, Nothing) be carefull when you fillet your edges from the loop...

Eric N.
indocti discant et ament meminisse periti
 
That's correct and i understood that but the code should work - on any direction , should be just a matter of dir 0 or 1 or 2. I am still getting same error .

jjjjj_z3eywf.jpg
kkkk_mxs6er.jpg
hhh_eekqc5.jpg


It does select all of them but not wich ones i need :(
 
you need dir(2) as refedge.GetDirection dir need an of dimension 3 so because you start counting at 0 you need dir(2) and it will always returns the 3 values: X, Y and Z.

it is not a filter to get only the edge along 1 direction

Eric N.
indocti discant et ament meminisse periti
 
your selection will always select all edges

it is after when you fill the edges_ref array that you define which one you want to fillet

Eric N.
indocti discant et ament meminisse periti
 
are you saying like this :

Dim dir(2)

refEdge.GetDirection dir

Debug.Print dir(0) & " / " & dir(1) & " / " & dir(2)

If dir(2) = 1 Then ???
 
not sure if Direction is oriented.. you might have to check if you want dir(2)=1 and dir(2) = -1 ...

Eric N.
indocti discant et ament meminisse periti
 
it's the next part of your code that is not working

you set a fillet on the same edge:

Code:
part1.ShapeFactory.AddNewEdgeFilletWithConstantRadius([b]edges_ref([COLOR=#EF2929]1[/color])[/b], 1, 3)

Eric N.
indocti discant et ament meminisse periti
 
sorry about that.

also it seems the logic you want to apply is wrong... you search edges then you fillet some of them. I see a problem here as edges are defined by the solid composition, as soon as you create the first fillet, you change the definition of few edges, and your search done previously is just not usable.

I would search all edge, create first edge compatible with your criteria, then search again all edges.... I would use a while loop...

edited : the assumption above is false

you can select all edges, keep only the one you want and fillet them

let me know when you want the code...

Eric N.
indocti discant et ament meminisse periti
 
But i do not know how :( let me try couple of hours or days and if i will give up then i will post again , just need to figure out myself how to do this . You still helped me a lot, a huge thank you !!!
 
Status
Not open for further replies.
Back
Top