Sheet Metal Flat Pattern Template

Sheet Metal Flat Pattern Template

phoenixwahoff
Contributor Contributor
770 Views
3 Replies
Message 1 of 4

Sheet Metal Flat Pattern Template

phoenixwahoff
Contributor
Contributor

Hi To All,

 

I am creating this sheet metal template and i was able to incorporate a parametric Kfactor which swops the Kfactor Value And The Sheet Metal Rules Via A switch in my parameter list. As well i created Some Rules Which overwrite the imported Length Width And Thickness To The Sheet Metal Parameters (Flat Pattern Extent) And Thickness.

The first problem i have is:

It does successfully overwrite the parameters in the F(x) Parameter list Once The Flat Pattern Is created.

But I would like to be able to delete the flat pattern which i cant as it ll recreate the flat pattern on safe. So i went in the code and deleted the upper portion of the code which will let me delete the flat pattern:

 

1. BEFORE (This Rule creates the flat pattern and adds it to the parameters (SheetMetalLength etc.)

'This Rule Adds The Sheet Metal LENGTH To The Parameter & Overwrites The Imported Parameter From Rule 000001'
'Rule Will Only Overwrite Parameter, IF The User Converts The Part To A Sheet Metal Part'
'If User Decides To Convert It Back To A Standard Part, Then This Rule Will Revert It Back To The Imported Parameter'
'This Is Also Applicable, If The User Decides To Delete The Flat Pattern BUT The Sheet Metal Remains'
'Written By Phoenix Ocean - Date 2023-06-17 - Code Tested - Date 2023-06-17


Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim oType As String
oType = oDoc.DocumentSubType.DocumentSubTypeID

If oType =  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" And MetalComponent = ("NO")  Then
      Parameter("SheetMetalLength") = SheetMetal.FlatExtentsLength

Else If oType <>  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" And MetalComponent = ("NO")  Then
      Parameter("SheetMetalLength") = LengthImport
End If

iLogicVb.UpdateWhenDone = True



The Code Above Succeeds BUT On Delete the Flat Pattern & Safe it recreates the flat Pattern which id like it not to do.

So i went ahead and deleted the first part of the code such as follow:

 

2. After (This Rule works and also lets me delete the flat pattern BUT It DOESNT ADD Now The Values To The Parameter:

'This Rule Adds The Sheet Metal LENGTH To The Parameter & Overwrites The Imported Parameter From Rule 000001'
'Rule Will Only Overwrite Parameter, IF The User Converts The Part To A Sheet Metal Part'
'If User Decides To Convert It Back To A Standard Part, Then This Rule Will Revert It Back To The Imported Parameter'
'This Is Also Applicable, If The User Decides To Delete The Flat Pattern BUT The Sheet Metal Remains'
'Written By Phoenix Ocean - Date 2023-06-17 - Code Tested - Date 2023-06-17


'First Part Deleted Out Of Code.

If oType =  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" And MetalComponent = ("NO")  Then
      Parameter("SheetMetalLength") = SheetMetal.FlatExtentsLength

Else If oType <>  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" And MetalComponent = ("NO")  Then
      Parameter("SheetMetalLength") = LengthImport
End If

iLogicVb.UpdateWhenDone = True

What am i missing? There isnt any Ilogic refering to creating a sheet metal flat pattern in this code....
See file attached - Drawn & created In Inventor 2024 Professional

 

0 Likes
771 Views
3 Replies
Replies (3)
Message 2 of 4

phoenixwahoff
Contributor
Contributor

I had to make a second Post on this as well:

 

The second thing i cant figure out is: There is a switch in the parameters called ,, Metal Component,, YES or NO

I wrote some code to suppress then my previous KFactor Values and That works Well (As Far as i know) I havent tested it throughoutly though.

My goal would be Set Metal Component to NO - then it ll take the KFactors 1 & 0 Based On the rule (Including the style / Rule written in the code.

BUT On YES i would like to swop the styles to the list i made in the parameters and select it from the list.

  The List I added Via If The As Follow Below:

 

If SheetMetalSelect = "Aluminum, 040" Then
SheetMetal.SetActiveStyle("Aluminum, 040")

ElseIf SheetMetalSelect = "Aluminum, 050" Then
SheetMetal.SetActiveStyle("Aluminum, 050")

ElseIf SheetMetalSelect = "Aluminum, 063" Then
SheetMetal.SetActiveStyle("Aluminum, 063")

ElseIf SheetMetalSelect = "Aluminum, 080" Then
SheetMetal.SetActiveStyle("Aluminum, 080")

ElseIf SheetMetalSelect = "Aluminum, 100" Then
SheetMetal.SetActiveStyle("Aluminum, 100")

ElseIf SheetMetalSelect = "Aluminum, 125" Then
SheetMetal.SetActiveStyle("Aluminum, 125")

ElseIf SheetMetalSelect = "Cold Rolled, 10ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 10ga")

ElseIf SheetMetalSelect = "Cold Rolled, 11ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 11ga")

ElseIf SheetMetalSelect = "Cold Rolled, 12ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 12ga")

ElseIf SheetMetalSelect = "Cold Rolled, 14ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 14ga")

ElseIf SheetMetalSelect = "Cold Rolled, 16ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 16ga")

ElseIf SheetMetalSelect = "Cold Rolled, 18ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 18ga")

ElseIf SheetMetalSelect = "Cold Rolled, 20ga" Then
SheetMetal.SetActiveStyle("Cold Rolled, 20ga")

ElseIf SheetMetalSelect = "Hot Rolled, 0.187" Then
SheetMetal.SetActiveStyle("Hot Rolled, .187")

ElseIf SheetMetalSelect = "Hot Rolled, 0.250" Then
SheetMetal.SetActiveStyle("Hot Rolled, .250")

ElseIf SheetMetalSelect = "Stainless, 0.187" Then
SheetMetal.SetActiveStyle("Stainless, .187")

ElseIf SheetMetalSelect = "Stainless, 11ga" Then
SheetMetal.SetActiveStyle("Stainless, 11ga")

ElseIf SheetMetalSelect = "Stainless, 12ga" Then
SheetMetal.SetActiveStyle("Stainless, 12ga")

ElseIf SheetMetalSelect = "Stainless, 14ga" Then
SheetMetal.SetActiveStyle("Stainless, 14ga")

ElseIf SheetMetalSelect = "Stainless, 16ga" Then
SheetMetal.SetActiveStyle("Stainless, 16ga")

ElseIf SheetMetalSelect = "Stainless, 18ga" Then
SheetMetal.SetActiveStyle("Stainless, 18ga")

ElseIf SheetMetalSelect = "Stainless, 20ga" Then
SheetMetal.SetActiveStyle("Stainless, 20ga")

End If
0 Likes
Message 3 of 4

A.Acheson
Mentor
Mentor

Hi @phoenixwahoff 

The reason you see a flatpattern generated is due to the ilogic code 

SheetMetal.FlatExtentsLength

This function creates a flatpattern and returns its length. 

 

On save you can use the API method to delete the flatpattern as the last step in your code. See API help here and here.

  Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument

    ' Make sure the document is a sheet metal document.
    If oPartDoc.SubType  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        MsgBox "A sheet metal document must be open."
        Return
    End If

    Dim oSheetMetalCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
oSheetMetalCompDef.Unfold
Messagebox.show("Deleting flat pattern")
oSheetMetalCompDef.FlatPattern.Delete

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @phoenixwahoff 

 

If I understood correctly, I think you can use something like this:

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim oType As String
oType = oDoc.DocumentSubType.DocumentSubTypeID

' Make sure the document is a sheet metal document.
If Not oType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	Parameter("SheetMetalLength") = LengthImport
	Exit Sub 'exit the rule
End If


Dim oSheetMetalCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition

If oSheetMetalCompDef.HasFlatPattern = False Then oSheetMetalCompDef.Unfold()

Parameter("SheetMetalLength") = SheetMetal.FlatExtentsLength
If MetalComponent = "YES" Then SheetMetal.SetActiveStyle(SheetMetalSelect)

'go back to folded model if applicable
Try : oSheetMetalCompDef.FlatPattern.ExitEdit() : Catch : End Try

 

Note that since the variable SheetMetalSelect matches exactly to the ActiveStyle name you can replace this:

 

If SheetMetalSelect = "Aluminum, 040" Then
SheetMetal.SetActiveStyle("Aluminum, 040")

ElseIf ...
ElseIf ...
ElseIf ...
ElseIf ...
ElseIf ...
ElseIf ...

End if

 

with just this:

 

SheetMetal.SetActiveStyle(SheetMetalSelect)

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

0 Likes