Ilogic for autofillet of sheetmetal

Ilogic for autofillet of sheetmetal

sakari.viitalaTFK9C
Participant Participant
1,182 Views
13 Replies
Message 1 of 14

Ilogic for autofillet of sheetmetal

sakari.viitalaTFK9C
Participant
Participant

Hi!

I would like to make an ilogic that makes corner round (feature) to flat pattern. Corner round radius depends on sheet metal thickness and the rule should take it into account. Is this possible to make?

0 Likes
1,183 Views
13 Replies
Replies (13)
Message 2 of 14

HermJan.Otterman
Advisor
Advisor

if you would like to make an iLogic rule that does that, how far have you come until now?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 14

sakari.viitalaTFK9C
Participant
Participant

Hi!

I doesn't have much experience in ilogic. I have only made some changes to rules I've copied on this forum. So I haven't come that far. I would need someone to help me with this.

0 Likes
Message 4 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

@sakari.viitalaTFK9C,

 

Hoping that below iLogic code may be helpful.

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

Dim oDef As SheetMetalComponentDefinition
oDef = oDoc.ComponentDefinition

Dim oEdgeColl As ObjectCollection
oEdgeColl = ThisApplication.TransientObjects.CreateEdgeCollection

Dim oEdge As Edge
Do While True
oEdge = ThisApplication.CommandManager.Pick(kPartEdgeFilter, "Select edges to make corner edges")

	If oEdge Is Nothing Then
		Exit Do
	End If
	Call oEdgeColl.Add(oEdge)
Loop

Dim oCornerDef As CornerRoundDefinition
oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, "0.125 in")

Dim oFillet As CornerRoundFeature
oFillet = oDef.Features.CornerRoundFeatures.Add(oCornerDef)

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 14

sakari.viitalaTFK9C
Participant
Participant

Hi thanks for reply!

 

Ilogic needs to make fillet automatically. I propably need to explain more in detail.

 

I need ilogic that makes fillets to every nonfillet corner when i create flat pattern of my sheet metal part. Ilogic needs to recognize the actual sheet metal thickness and make fillet depending on the thickness. For example 5 mm part would need 0,5 mm fillet and 20 mm part a 1 mm fillet.

0 Likes
Message 6 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

@sakari.viitalaTFK9C,

 

Can you please provide non confidential sheet metal part (10mm and 5mm thickness)to test?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

@sakari.viitalaTFK9C,

 

Try this. Still more conditions can be added. Corner Radius value in "cm" unit. For ex : 0.1 = 1 mm

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

Dim oDef As SheetMetalComponentDefinition
oDef = oDoc.ComponentDefinition

Dim oEdgeColl As ObjectCollection
oEdgeColl = ThisApplication.TransientObjects.CreateEdgeCollection

Dim oEdge As Edge
Do While True
oEdge = ThisApplication.CommandManager.Pick(kPartEdgeFilter, "Select edges to make corner edges")

	If oEdge Is Nothing Then
		Exit Do
	End If
	Call oEdgeColl.Add(oEdge)
Loop

Dim oCornerDef As CornerRoundDefinition
If Thickness = 10 Then
	oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.1)
Else If Thickness = 5 Then
	oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.05)
Else 	
	oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.05)
End If 

Dim oFillet As CornerRoundFeature
oFillet = oDef.Features.CornerRoundFeatures.Add(oCornerDef)

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 8 of 14

sakari.viitalaTFK9C
Participant
Participant

Hi!

Many thanks for your attempt!

 

Do I need to pick every corner with this ilogic? I'm getting a message "Select edges to make corner edges". I thought you would use corner round command in sheet metal and there option "feature". It also should make corner rounds in sheet metal mode so I don't get those fillets in folded model.

Corner round.JPG

0 Likes
Message 9 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

@sakari.viitalaTFK9C,

 

Unfortunately, Inventor API does not support to create corner round by selecting feature. Please log this wish list at idea station using below link.

 

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 14

lmc.engineering
Advocate
Advocate

Hi @sakari.viitalaTFK9C 

 

I believe this will do what you are after.

 

Public Sub Main()
    'reference to the currently active document.
    Dim oPart As PartDocument
    oPart = ThisApplication.ActiveDocument
    '  a reference to the component definition.
    Dim oDef As PartComponentDefinition
    oDef = oPart.ComponentDefinition

    Dim featFace As Face
	'Check if a flat pattern exists, If not create one and edit.
	If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
		Try
			If oDef.HasFlatPattern = False Then
				oDef.Unfold
			Else
				oDef.FlatPattern.Edit
			End If
		Catch
			MessageBox.Show("Error editting the flat pattern.", "iLogic")
		End Try
    End If
	Dim oFlatPattern As FlatPattern
	oFlatPattern = ThisApplication.ActiveEditObject
	
	Dim oEdgeColl As ObjectCollection
	oEdgeColl = ThisApplication.TransientObjects.CreateEdgeCollection
	'Iterate over bodies in flat pattern
    For Each oSurfBody As SurfaceBody In oFlatPattern.SurfaceBodies
        ' Iterate over the edges in the faces.
        Dim featEdge As Edge
        For Each featEdge In oSurfBody.Edges
		'Get length of edges
		Z1 = featEdge.StartVertex.Point.Z
    		Z2 = featEdge.StopVertex.Point.Z
		Z3 = Round(Z1 - Z2, 3)
		'Check length of edges against thickness. If edge is correct length, add to edge collection.
		If Z3*10 = Thickness Or Z3*10 = -Thickness Then
			oEdgeColl.Add(featEdge)
		End If
        Next
    Next
Dim oCornerDef As CornerRoundDefinition
If Thickness = 10 Then
	oCornerDef = oFlatPattern.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.1)
Else If Thickness = 5 Then
	oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.05)
Else 	
	oCornerDef = oDef.Features.CornerRoundFeatures.CreateCornerRoundDefinition(oEdgeColl, 0.2)
End If 
Dim oFillet As CornerRoundFeature
oFillet = oFlatPattern.Features.CornerRoundFeatures.Add(oCornerDef)
'Exit flat pattern edit
oDef.FlatPattern.ExitEdit
End Sub

 Regards

0 Likes
Message 11 of 14

sakari.viitalaTFK9C
Participant
Participant

Hi!

 

Many thanks, seems to work for me, I'll just need to do couple more tests. Do you happen to know how I get it to trigger when I go/create flat pattern?

0 Likes
Message 12 of 14

lmc.engineering
Advocate
Advocate

Unfortunately with iLogic I don't believe it's possible to trigger on flat pattern creation as it would require it to be watching for events. A limitation of iLogic I'm afraid.

 

To my best knowledge, you'd ideally want this built as an add-in that triggers on FlatPattern.PartEvents(). However I've never done it myself so can't say for sure.  It may be possible to do this through a VBA macro too, but I tend to either go iLogic or full vb.net Add-in, so I'm not the greatest help there.

 

Best bet for you may be to use this rule to create your flat pattern, then all will be done in one go.

0 Likes
Message 13 of 14

sakari.viitalaTFK9C
Participant
Participant

Hi!

Ok! I tried to trigger it everytime I save a document. Problem is that if I don't have any edges to fillet (already done that) so I get an error message " (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". If I go and delete existing corner rounds in sheet metal it will work, or if I make new faces that doesn't have corner round. Is it possible to edit rule not to run if there is no edges to fillet?

 

Otherwise just great rule for me and many thanks for making it!

0 Likes
Message 14 of 14

YuhanZhang
Autodesk
Autodesk

You can add a Try...Catch...End Try to handle the failure for the CornerRoundFeatures.Add method like below:

 

Try
	Dim oFillet As CornerRoundFeature
	oFillet = oFlatPattern.Features.CornerRoundFeatures.Add(oCornerDef)
Catch
End Try


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes