Sheet metal - refold flat pattern

Sheet metal - refold flat pattern

SharkDesign
Mentor Mentor
1,115 Views
9 Replies
Message 1 of 10

Sheet metal - refold flat pattern

SharkDesign
Mentor
Mentor

I've worked out how to get iLogic to unfold a part, but I want to be able to refold it. 
Does anyone know the command?

 

Basically, I'm writing code to check if there is a flat pattern.

If there isn't, Inventor will unfold and then return to the folded part before saving. 

  Inventor Certified Professional
0 Likes
1,116 Views
9 Replies
Replies (9)
Message 2 of 10

MechMachineMan
Advisor
Advisor

You might have a better time just checking if there is a flat pattern component def... Like such:

 

	If oCompDef.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject
		If oCompDef.HasFlatPattern = True
			oHasFP = True
			oCompDef = oCompDef.FlatPattern
		Else
			Try
				oCompDef.Document.Unfold
				oCompDef = oCompDef.FlatPattern
				oHasFP = True
			Catch
				MsgBox("Error In Generating Flat Pattern for " & oCompDef.Document.FullFileName)
			End Try	
		End If
		oFP = True

End if

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 10

SharkDesign
Mentor
Mentor

Thanks, but once it's unfolded does it not need to fold back up again, since Inventor won't let you save a part in the unfolded state?

 

Thanks

  Inventor Certified Professional
0 Likes
Message 4 of 10

MechMachineMan
Advisor
Advisor
I believe this is true, yes.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 10

wayne.brill
Collaborator
Collaborator

Hi James,

 

I believe ExitEdit of the flat pattern could provide a solution. Below is a VBA example I used to test.

 

I did not see a command being run when I went back to the folded part. (used the OnTerminateCommand event to check)

 

 

Public Sub sheetMetalTest()

    Dim oShtMetalDoc As PartDocument
    Set oShtMetalDoc = ThisApplication.ActiveDocument
    
    Dim oShtMetalCompDef As SheetMetalComponentDefinition
    Set oShtMetalCompDef = oShtMetalDoc.ComponentDefinition
    
    Dim oFlatCompDef As FlatPattern
    
    If oShtMetalCompDef.HasFlatPattern = True Then
       Set oFlatCompDef = oShtMetalCompDef.FlatPattern
       oFlatCompDef.ExitEdit
    Else
       oShtMetalCompDef.Unfold
       Set oFlatCompDef = oShtMetalCompDef.FlatPattern
       oFlatCompDef.ExitEdit
    End If
            
     oShtMetalDoc.Save
        
End Sub

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 6 of 10

SometimesInventorMakesMeAngry
Advocate
Advocate
Thank you! I would expect a method like SheetMetalComponentDefinition.Fold(), but it works, so whatever.
0 Likes
Message 7 of 10

ssyXENBT
Contributor
Contributor

like this  🙂 

Dim sheetMetalDef As SheetMetalComponentDefinition = oFuncPart.ComponentDefinition
sheetMetalDef.FlatPattern.ExitEdit()

 

0 Likes
Message 8 of 10


@SometimesInventorMakesMeAngry wrote:
Thank you! I would expect a method like SheetMetalComponentDefinition.Fold(), but it works, so whatever.

Don't expect anything.

 

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-26408B71-D87C-47EC-996A-6A3E3AD3816A

0 Likes
Message 9 of 10

WCrihfield
Mentor
Mentor

FYI:  The FlatPattern will always be 'flat', because that is its nature, and its right in the name.  The FlatPattern object is like its own ComponentDefinition type object within the SheetMetalComponentDefinition, so it is controlled separately, and even has its own separate set of Parameters that are not seen within the main SheetMetalComponentDefinition's own Parameters, sketches, & features.  Controlling whether or not your model is folded or unfolded can be done in other ways, besides entering or exiting the 'Edit Mode' of the FlatPattern.  If you need the ability to control folds in a sheet metal part, without having to go through the FlatPattern, you can use FoldFeatures, UnfoldFeatures, & RefoldFeatures within the SheetMetalFeatures collection.  The SheetMetalFeatures collection is obtained similarly to obtaining the SheetMetalComponentDefinition...by declaring a variable of that type ahead of time, then setting its value from the SheetMetalComponentDefinition.Features (which by default just returns a PartFeatures type object, not the SheetMetalFeatures type object type).  If you do not have any of those types of features, and do not want to create any of them, then your only options are to use the main model as it is (folded), or use the FlatPattern model, or use a ModelState of the main model in which the features of the model that create bends are suppressed.  But if your features that create bends are FlangeFeatures, instead of BendFeatures, then suppressing the FlangeFeature would be suppressed, eliminating the flange material itself.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 10 of 10

Frederick_Law
Mentor
Mentor

I found out:

Accessing SheetMetal FlatExtent properties will cause the model to "Unfold" if there was no flat pattern.

NewWidth = Round(SheetMetal.FlatExtentsWidth, 2)

 

0 Likes