AddInsertConstraint

AddInsertConstraint

Anonymous
Not applicable
509 Views
2 Replies
Message 1 of 3

AddInsertConstraint

Anonymous
Not applicable

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

 

0 Likes
510 Views
2 Replies
Replies (2)
Message 2 of 3

CCarreiras
Mentor
Mentor

Hi!

 

Maybe with iMates?

CCarreiras

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

yes, 

Imate could be a good idea but unfortunately the customer doesn't want to modify the PartB creating iMate because it's a component from Library.

 

ideas? 

 

Thank you,

 

Mario

0 Likes