The 2014 API supports new functionality to do solid imprinting. (This functionality is only available in the API). The new method is:
TransientBRep.ImprintBodies
This method takes two bodies and modified versions of the bodies are output. The functions finds coincident faces on the bodies and splits the coincident faces where the faces overlap. Imprinting will primarily be useful to applications that perform their own meshing for some form of analysis. By splitting the faces where the bodies connect, they’re guaranteed to get mesh nodes along these boundaries.
C# example:
Download Inventor_2014_Imprinting_Example
This example has these VBA examples converted from the Inventor API help file:
CreateImprintFromAssembly()
SampleImprintMatching2()
This screenshot shows two parts in assembly. When you run CreateImprintFromAssembly() you will prompted to select two parts that have a coincident face. (need to have an assembly active or an error occurs)
When the function completes a new part with two bodies will be created. The two bodies have edges where the edge in the other part was coincident. Here you can see these edges on one of the parts:
Here is CreateImprintFromAssembly():
// Imprint bodies within an assembly
// This sample demonstrates creating imprinted bodies
// from two selected occurrences in an assembly.
public void CreateImprintFromAssembly()
{
// Get the active assembly document
// and its definition.
AssemblyDocument asmDoc = (AssemblyDocument)
ThisApplication.ActiveDocument;
// Have two parts selected in the assembly.
ComponentOccurrence part1 = (ComponentOccurrence)
ThisApplication.CommandManager.Pick
(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,
"Select part 1");
ComponentOccurrence part2 = (ComponentOccurrence)
ThisApplication.CommandManager.Pick
(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,
"Select part 2");
// Get the bodies associated with the occurrences.
// Because of a problem when this sample was
// written the ImprintBodies method fails when
// used with SurfaceBodyProxy objects. The code
// below works around this by creating new
// transformed bodies that will provide the
// equivalent result.
// Get the bodies in part space
// as transient bodies.
TransientBRep transBrep =
(TransientBRep)ThisApplication.TransientBRep;
SurfaceBody body1 = (SurfaceBody)transBrep.Copy
(part1.Definition.SurfaceBodies[1]);
SurfaceBody body2 = (SurfaceBody)transBrep.Copy
(part2.Definition.SurfaceBodies[1]);
// Transform the bodies to be in the
// location represented in the assembly.
transBrep.Transform(body1, part1.Transformation);
transBrep.Transform(body2, part2.Transformation);
// Imprint the bodies.
SurfaceBody newBody1 = null;
SurfaceBody newBody2 = null;
Faces body1OverlapFaces = null;
Faces body2OverlapFaces = null;
Edges body1OverlapEdges = null;
Edges body2OverlapEdges = null;
ThisApplication.TransientBRep.ImprintBodies
(body1, body2, true, out newBody1,
out newBody2, out body1OverlapFaces,
out body2OverlapFaces, out body1OverlapEdges,
out body2OverlapEdges);
// Create a new part document to show the
// resulting bodies in.
PartDocument partDoc =
(PartDocument)ThisApplication.Documents.Add
(DocumentTypeEnum.kPartDocumentObject,
ThisApplication.FileManager.GetTemplateFile
(DocumentTypeEnum.kPartDocumentObject));
PartComponentDefinition partDef =
(PartComponentDefinition)partDoc.
ComponentDefinition;
// Create a new feature from the
// first imprinted body.
NonParametricBaseFeature non1 =
(NonParametricBaseFeature)partDef.Features.
NonParametricBaseFeatures.Add(newBody1);
newBody1 = non1.SurfaceBodies[1];
// Create a new feature from the
// second imprinted body.
NonParametricBaseFeature non2 =
(NonParametricBaseFeature)partDef.Features.
NonParametricBaseFeatures.Add(newBody2);
newBody2 = non2.SurfaceBodies[1];
}
-Wayne