The PlanarSketch.AddByProjectingEntity can be used in a part environment to project geometry onto a sketch plane. It is also applicable to project geometry from one occurrence to another.
The only issue you need to mote is: you must use a proxy object, not a native object, no matter the geometries or the object which is projected to, such as a sketch.
The following code assumes an assembly has two parts. It projects the first edge of the first surfacebody of the part1 to the first sketch of the part2.
static void Test()
_InvApplication = (Inventor.Application)
// assume we have had Inventor application
AssemblyDocument asmDoc =
ComponentOccurrence occ1 =
ComponentOccurrence occ2 =
PartComponentDefinition partDef1 =
PartComponentDefinition partDef2 =
Edge oEdge = partDef1.SurfaceBodies.Edges;
occ1.CreateGeometryProxy(oEdge, out objedge);
EdgeProxy oProxyEdge = (EdgeProxy)objedge;
PlanarSketch mySketch =
occ2.CreateGeometryProxy(mySketch, out objsketch);
PlanarSketchProxy myProxySketchProxy =
//SketchEntity projEdge =
SketchEntity projEdge =