AddInsertConstraint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I want to create a insert constraint between:
- edge in ifeature in PartA (1.png)
- edge in PartB (2.png)
But I don't know how to recognize the right edge in the parts.
Attached you can see how I realize the constraint with Inventor Command (3.png is the final result)
To get the edge from i features in partA I use the following code:
foreach (iFeature ifea in PartA.ComponentDefinition.Features.iFeatures)
{
if (ifea.Name == "GAS_A1")
{
Edge edgeA= ifea.Faces[2].Edges[1]; //I don't know if this is the right one
}
}
to get the edge from PartB:
PartDocument oDoc = (PartDocument) occ.Definition.Document;
PartFeatures lavs = oDoc.ComponentDefinition.Features;
foreach (PartFeature parte in lavs)
{
if (parte.Name == "Extrusion2")
{
Edge edgeB = parte.SurfaceBodies[1].Faces[1].Edges[1]; //Don't know if this is the right one
}
}
to assembly:
InsertConstraint oInsert;
oInsert = asm.ComponentDefinition.Constraints.AddInsertConstraint(edgeA, edgeB, true, 0);
In this way I have an exception because I can't identify the right edges.
is this the right way? How can I choose via code the right edgeA and edgeB? is it possible?
Thanks, Bye,
Mario