Length of edges and cut outs (sheet metal part)

Length of edges and cut outs (sheet metal part)

Anonymous
Not applicable
2,257 Views
6 Replies
Message 1 of 7

Length of edges and cut outs (sheet metal part)

Anonymous
Not applicable

Hello,

when im trying to measure flat sheet metal part I can see overall length of all edges summed together (external edges and cut outs).  How can I invote this "parameter" in drawing? I want to add this to my drawing as a "length of laser cut".

 

I saw solutions for this on this forum but its only for elder versions (i'm using inventor 2k21). I also dont have skills to write a iLogic formule.

Can anyone help?

Best regards

0 Likes
Accepted solutions (1)
2,258 Views
6 Replies
Replies (6)
Message 2 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

A possible solution would be to create an external rule with the code below and add it to the OnSave Trigger of iLogic. On every save of your sheet metal part, a user parameter "LaserCutLength" ill either created or it's value updated.

The parameter can be used in your drawing for an annotation text.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub
Dim oDoc As PartDocument = ThisDoc.Document

If oDoc.DocumentSubType.documentsubtypeid <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Exit Sub
	
Dim oCompDef As SheetMetalComponentDefinition= oDoc.ComponentDefinition
Dim oFlatPattern As FlatPattern = oCompDef.FlatPattern

Dim dBottomLength As Double
Dim oEdgeLoop As EdgeLoop
For Each oEdgeLoop In oFlatPattern.BottomFace.EdgeLoops
    dBottomLength = dBottomLength + ThisApplication.MeasureTools.GetLoopLength(oEdgeLoop)
Next

Dim dTopLength As Double
For Each oEdgeLoop In oFlatPattern.TopFace.EdgeLoops
    dTopLength = dTopLength + ThisApplication.MeasureTools.GetLoopLength(oEdgeLoop)
Next

Dim oParam As UserParameter
Try
	oParam=oCompDef.Parameters.UserParameters.Item("LaserCutLength")
	oParam.Value = dTopLength
Catch
	oParam = oCompDef.Parameters.UserParameters.AddByValue("LaserCutLength", dTopLength, "mm")
End Try

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 7

michalCDNJV
Explorer
Explorer

Thank you for answer. Unfortunately this rule dont include cut-outs. I had a plate with 1 bend and I got correctly result with your iLogic rule but when I added one cut out in my plate, result didnt change even after saving this part. Is it any solution to add cut-out lengths?

EDIT:
ok, I added this rule when I converse my part to flat and now it works. I will give feedback if I can add this to my drawing 🙂

0 Likes
Message 4 of 7

Anonymous
Not applicable

Hello again,
for some parts your rule works good, for others one dont. It is example when your rule dont include inner cut out (length should be +1500mm for circle cut out). I've tried to delete and make new flat part, I've tried to save it again and other combinations and for this part it dont work. Do you have any idea why it is how it is?

Ofc thank you a lot for trying to help 🙂

doesnt work.PNG

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Anonymous  & @michalCDNJV .  You both seem to be having some troubles with this code.  Since it does seem to work part of the time, and you are not sure why it does not work other times, I thought that maybe you could use some extra checks and feedback within the rule to help out.  I also excluded checking the TopFace, in favor of just checking the BottomFace of the Flat Pattern, just to help avoid some kinds of features like countersink/counterbore holes, edge chamfers, radiuses, etc that are more likely to be on the top face (if any).  I am also using a List(Of Double) to record individual loop lengths for added information, in case it may be desired.  It has a Sum property which adds up all numeric values within, so it's still useful there too.  I included an InputListBox, just to show you the resulting list of individual loop lengths.  If you don't want this, you can just delete that line.  Also since a sheet metal part may not already have a flat pattern, I decided to check for this first, before just trying to use it.  If it is not found, I let the user know, then ask them if they want the rule to automatically create it, so that the rule can progress and produce the user parameter.  If they choose No, it exits the rule without creating it, and without creating/updating the user parameter.

Here's the updated iLogic rule:

If Not TypeOf ThisApplication.ActiveDocument Is PartDocument Then
	MsgBox("A Part document must be 'active' for this rule to work.  Exiting rule.",,"")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
If Not TypeOf oPDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
	MsgBox("This Part is not a Sheet Metal Part.  Exiting rule.",,"")
	Exit Sub
End If
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
If Not oSMDef.HasFlatPattern Then
	oAns = MsgBox("This Sheet Metal Part does not have a Flat Pattern." & vbCrLf & _
	"This is needed to calculate 'LaserCutLength'." & vbCrLf & _
	"Do you want this rule to automatically create the Flat Pattern, then continue?", vbYesNo + vbQuestion, "")
	If oAns = vbNo Then Exit Sub
		Try
			oSMDef.Unfold
		Catch oEx As Exception
			MsgBox("Failed to 'Unfold' this Sheet Metal Part, to create a Flat Pattern." & vbCrLf & _
			oEx.Message & vbCrLf & oEx.StackTrace, , "")
			Exit Sub
		End Try
End If
Dim oFP As FlatPattern = oSMDef.FlatPattern
Dim oLengths As New List(Of Double)
For Each oEL As EdgeLoop In oFP.BottomFace.EdgeLoops
    oLengths.Add(ThisApplication.MeasureTools.GetLoopLength(oEL))
Next
a = InputListBox("", oLengths, 0.0, "Loop Lengths", "Individual Loop Lengths")
Dim oParam As UserParameter
Try
	oParam = oSMDef.Parameters.UserParameters.Item("LaserCutLength")
	oParam.Value = oLengths.Sum
Catch
	oParam = oSMDef.Parameters.UserParameters.AddByValue("LaserCutLength", oLengths.Sum, "mm")
End Try

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

Sorry, I can't reproduce this behaviour. I've created a similar part and the cut out once per extrusion and also as cut out. Both works as expected. We have to search from the beginning to find the differences.

Which version of Inventor are you using?

Are all updates installed?

Is there any update deferred?

Does the parameter also not updating if you run manually the rule?

 

Can you post the demo file from which the screenshot was made? Don't forget to delete all confidental data before.

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

michalCDNJV
Explorer
Explorer

I dont know why it didnt work. I set this rule to work "before saving" and sometimes it had a problem with length updating. 
But WCrihfield rule works good. 

Thank you both so much - it will make my work easier.

Have a nie day!

0 Likes