Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Catia VBA multi-fillet?

Status
Not open for further replies.

DanielMadureira

Automotive
Apr 13, 2017
16
0
0
CA
Hi everyone,

First of all, before anyone replies to this message: Thanks eng-tips! I've learned so much just by browsing through the existing forums. So many talented and generous people around here.

Here's what I'm trying to do.

I have a skin in CATIA that is like a saw-tooth kind of thing.

This skin is composed of about 3000 faces, all of them connected.

I'm trying to apply a fillet on all the top intersecting edges of a user value, and a different fillet on the bottom intersecting edges with another user input value.

Radius is the same for all top edges, and the same for all bottom edges.

I can't for the life of me find a VBA or CATScript way of selecting internal edges, putting them into an array and loop through.

I can for example search and select all edges on a solid and apply a fillet or chamfer via VBA.

Is it even possible to select only the internal edges ?

Any ideas?
IMG_0262_izymuu.gif

IMG_0263_txghac.gif
 
Replies continue below

Recommended for you

Thats actually a prettty good idea.

So basically I would create a collection with said surfaces using a loop with a step 2 . Within that loop I could do the fillets, then come back, and with another loop do fillet1 + surface5 - apply second fillet - fillet2 + surface8 and so on.

Then third loop, do fillets with the fillets created, join, save.

Something along these lines? Feel free to suggest another approach, as your scripting knowledge is waaaaaaaay more advanced than mine.
 
Don't be so sure about my scripting knowledge, I'm not a professional programmer, I just like to learn more about this subject.

For the time being I don't have another idea, I don't know how was created your geometry, another idea would be maybe you can check if some vertex has same coordinates and get their parents and fillet them?

Or if those lower edges are all of them co-planar...find a way to color them and select them in one shot by color....

I suppose in all cases it would be a long run...

Regards
Fernando

- Romania
- EU
 

Here's what i came up with:

Waddaya think?

Code:
Sub CATMain() 

CATIA.ActiveDocument.selection.Clear 


Dim PartDocumentDest As PartDocument 
Set PartDocumentDest = CATIA.ActiveDocument 
Dim PartDest As Part 
Set PartDest = PartDocumentDest.Part 

Dim hybridShapeFactory1 As HybridShapeFactory 
Set hybridShapeFactory1 = PartDest.HybridShapeFactory 

Set hybridBodies_srf = PartDest.HybridBodies 

Set hybridBody_srf = hybridBodies_srf.Add() 

hybridBody_srf.Name = "Fillet_Result" 

BottomRadius = InputBox("Enter Bottom radius", "Enter radius value in mm", 1) 
TopRadius = InputBox("Enter top radius", "Enter radius value in mm", 1) 


'Collect Input_1 

Dim vntTypes2(0) As Variant 
vntTypes2(0) = "BiDim" 


Set catSelectLine1 = CATIA.ActiveDocument.selection 

    catSelectLine1.Clear 

    
Dim strSelectedItem As String 
strSelectedItem = catSelectLine1.SelectElement3(vntTypes2, "Select surfaces.", False, CATMultiSelTriggWhenUserValidatesSelection, False) 

'strSelectedItem = catSelectLine1.Search "('Generative Shape Design'.Surface & Color='Dark Green'),scr" 

If (strSelectedItem = "Cancel") Then 
End 
Else 
            
Dim Line_Coll As New Collection 
        For sCount = 1 To catSelectLine1.Count 
        Line_Coll.Add catSelectLine1.selection.Item(sCount).Value 
        Next 
        
End If 




    
'Loop Bottom Fillet: 

For iInput = 1 To Line_Coll.Count 

Dim ref1 As Object 
Set ref1 = catSelectLine1.Item(iInput).Value 

Dim ref2 As Object 
Set ref2 = catSelectLine1.Item(iInput + 1).Value 


Set rf1 = PartDest.CreateReferenceFromObject(ref1) 
Set rf2 = PartDest.CreateReferenceFromObject(ref2) 

Dim hybridShapeFilletBiTangent1 As HybridShapeFilletBiTangent 
Set hybridShapeFilletBiTangent1 = hybridShapeFactory1.AddNewFilletBiTangent(rf1, rf2, BottomRadius, 1, 1, 1, 0) 

hybridShapeFactory1.GSMVisibility rf1, 0 

hybridShapeFactory1.GSMVisibility rf2, 0 

hybridBody_srf.AppendHybridShape hybridShapeFilletBiTangent1 

hybridShapeFilletBiTangent1.Name = "Fillet_1" 


iInput = iInput + 1 

Set rffil = PartDest.CreateReferenceFromObject(hybridShapeFilletBiTangent1) 
hybridShapeFactory1.GSMVisibility rffil, 0 

Next 


PartDest.Update 
    
    Dim catSelectsurf As selection 
    Set catSelectsurf = PartDocumentDest.selection 
    catSelectsurf.Search "Name=Fillet_1,all" 
    
    
        Dim FillColl As New Collection 
        For sCount2 = 1 To catSelectsurf.Count 
        FillColl.Add catSelectsurf.selection.Item(sCount2).Value 
        Next 
        
        
'Invert Surfaces 


For iAxis = 1 To FillColl.Count 


Set refInv = PartDest.CreateReferenceFromObject(FillColl.Item(iAxis)) 

Set hybridShapeAxisToAxis1 = hybridShapeFactory1.AddNewInverse(refInv, -1) 

hybridBody_srf.AppendHybridShape hybridShapeAxisToAxis1 

PartDest.InWorkObject = hybridShapeAxisToAxis1 

hybridShapeAxisToAxis1.Name = "Inverse_2" 


Next 



PartDest.Update 






        Dim catSelectsurf2 As selection 
        Set catSelectsurf2 = PartDocumentDest.selection 
        catSelectsurf2.Search "Name=Inverse_2,all" 
    
    
        Dim FillColl2 As New Collection 
        For sCount3 = 1 To catSelectsurf2.Count 
        FillColl2.Add catSelectsurf2.selection.Item(sCount3).Value 
        Next 
        
        
'Loop Top Fillet: 


Dim ref3 As Object 
Set ref3 = catSelectsurf2.Item(1).Value 
        
        
On Error Resume Next 
        
For iInput2 = 1 To FillColl2.Count - 1 



Dim ref4 As Object 
Set ref4 = catSelectsurf2.Item(iInput2 + 1).Value 


Set rf3 = PartDest.CreateReferenceFromObject(ref3) 
Set rf4 = PartDest.CreateReferenceFromObject(ref4) 

Dim hybridShapeFilletBiTangent2 As HybridShapeFilletBiTangent 
Set hybridShapeFilletBiTangent2 = hybridShapeFactory1.AddNewFilletBiTangent(rf3, rf4, TopRadius, 1, 1, 1, 0) 

hybridShapeFactory1.GSMVisibility rf3, 0 

hybridShapeFactory1.GSMVisibility rf4, 0 

hybridBody_srf.AppendHybridShape hybridShapeFilletBiTangent2 

Set ref3 = hybridShapeFilletBiTangent2 

Next 

CATIA.ActiveDocument.selection.Clear 
PartDest.Update 

End sub
 
Status
Not open for further replies.
Back
Top