Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
400 Views, 1 Reply

Stitch a composite surface via API

Hi,

 

After I load a STEP file containing a single surface, it appears in Inventor as a part with a single Work Surface coming from a "Composite Feature".

 

I want to stitch it via the API as the first step in an automation process, so I do:

 

// Get last added document
PartDocument doc = app.Documents[1] as PartDocument;
PartComponentDefinition compDef = doc.ComponentDefinition;

// Stitch all faces in the surface
ObjectCollection args = app.TransientObjects.CreateObjectCollection();
foreach (Face face in compDef.WorkSurfaces[1].SurfaceBodies[1].Faces)
{
    args.Add(face.SurfaceBody);
}
compDef.Features.KnitFeatures.Add(args);

However, the call to 

KnitFeatures.Add

 just throws an exception and I don't know what's wrong. Via the UI, it's as easy as clicking on the composite surface to select the composite.

 

I've tried passing the WorkSurface directly instead of all the faces, but still the same result. Any ideas?

 

Thanks!