Batch flat pattern

Batch flat pattern

aurel_e
Collaborator Collaborator
208 Views
1 Reply
Message 1 of 2

Batch flat pattern

aurel_e
Collaborator
Collaborator

Hi all,

I am trying to make an Inventor add-in to scan assemblies before batch DXF export.

I need to identify and highlight sheet-metal parts that are unsuitable for laser DXF export, including parts where:

  • A flat pattern cannot be created
  • A flat pattern has regeneration errors
  • Bend/radius geometry is invalid
  • Flat geometry overlaps or self-intersects

I have tested HasFlatPattern, Unfold() with try/catch, Update2(true), feature HealthStatus, Application.ErrorManager, FlatBendResults, and flat-pattern body validation.

The test cases I have simulated are:

  • One or both bend radii removed
  • Non-uniform sheet thickness, for example an added extrusion on a sheet face
  • Invalid bend radius that creates non-uniform thickness through the bend area
  • Overlapping bends or overlapping flat-pattern geometry

The difficult case is when Inventor shows an intersecting-features warning during unfolding and the user accepts the errors. The part can then retain a flat pattern, but the public API checks above can still report it as valid.

Is there an API property, error state, warning collection, or supported workflow that exposes accepted intersecting errors or otherwise reliably identifies an invalid flat pattern for batch DXF export?

Inventor 2026, C# add-in.

Thanks.

0 Likes
209 Views
1 Reply
Reply (1)
Message 2 of 2

info28T45
Explorer
Explorer

As far as I know there's no public API property that tells you the user accepted the intersect errors. We hit the same wall on a batch of ~150 parts and stopped asking Inventor if the flat pattern is valid. We check the flat result itself instead, with tests that don't depend on Inventor's error state.

 

Here's a function you can drop into your add-in and call for each part in your scan, after the checks you already have. It returns an empty string if the part looks OK, otherwise the reason, so you can show it in your report.

 

// Returns "" if the flat pattern looks usable, otherwise the reason.
private string CheckFlatPattern(Inventor.Application invApp, PartDocument partDoc)
{
    SheetMetalComponentDefinition smDef = partDoc.ComponentDefinition as SheetMetalComponentDefinition;
    if (smDef == null) return "not a sheet metal part";
    if (!smDef.HasFlatPattern) return "no flat pattern";

    SurfaceBody folded = smDef.SurfaceBodies[1];
    SurfaceBody flat = smDef.FlatPattern.SurfaceBodies[1];

    // 1. Flat plate or bent part? If folded and flat bodies are identical,
    //    the part has no bends, so there is nothing that can overlap.
    ObjectCollection coll = invApp.TransientObjects.CreateObjectCollection();
    coll.Add(folded);
    coll.Add(flat);
    ObjectCollection identical = invApp.TransientBRep.GetIdenticalBodies(coll);
    if (identical.Count > 0) return "";

    // 2. Bent part: compare volumes. Overlapping geometry that got merged
    //    into the flat solid makes the flat volume smaller than the folded one.
    double vFolded = folded.get_Volume(0.001);
    double vFlat = flat.get_Volume(0.001);
    double diff = Math.Abs(vFlat - vFolded) / vFolded;
    if (diff > 0.01)
        return "flat volume differs from folded by " + (diff * 100).ToString("0.0") + " %";

    return "";
}

 

Why these two. The first one splits flat plates from bent parts: a flat plate can't have overlapping bends, so you skip it. We use this on every job and it's cheap. The second one is the one aimed at your accepted-errors case. When Inventor accepts overlapping geometry the overlap gets merged into one solid, so the flat body should lose volume compared to the folded one. I haven't had one of your accepted-errors parts to test it on, so please try it on the test cases you already built and tune the 1 % tolerance. Volume needs the precision argument, that's why it's get_Volume(0.001) and not just Volume.

 

A third check we do outside Inventor, since you export DXF anyway: read the flat pattern DXF in python with ezdxf, build polygons from the outer profile with shapely, and flag the part if the outline doesn't close into one polygon or if polygon.is_valid is False, which is what a self-intersecting outline gives. It doesn't care about Inventor's error state at all.

 

If someone knows an API call that reads the accepted-errors state directly I'd like to know too.

 

Happy to help if you have more questions on the add-in or other automation stuff. I maintain an iLogic rule of over 10,000 lines for our drawings, so I've fought with the sheet metal API quite a bit.

0 Likes