Message 1 of 4
Create Flat Pattern On Save
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I made an add-in that creates a flat pattern when a part is saved (if it needs one). It works as expected when a single part is open. However, it does not work well when an assembly with sheet metal part children is saved. When the code is executed, Inventor opens one of the children, unfolds it, and exits flat pattern, which is great. However, I get exceptions for each of the remaining children.
public void CreateFlatPattern()
{
if (CompDefinition.SurfaceBodies.Count != 1) return;
//Above handles multi-body or no body
//Sheet metal part can't be unfolded if multi-body
if (!SheetDefinition.HasFlatPattern)
{
try
{
SheetDefinition.Unfold();
SheetDefinition.FlatPattern.ExitEdit();
}
catch
{ throw new System.Exception("Unable to unfold model"); }
}
}
Does anyone understand this behavior?