Select face and add Imate on PART

Select face and add Imate on PART

J.VandeMerckt
Advocate Advocate
535 Views
5 Replies
Message 1 of 6

Select face and add Imate on PART

J.VandeMerckt
Advocate
Advocate

Hi Forum

 

I'm trying to add a Imate on a Part with Ilogic.
I want to select a face and then run rule.
So first select and then Ilogic.

I know this is possible with normal Constrains on Assembly level. But don't know how it works with Imates on part level.
My knowledge of Ilogic is basic.

Can anyone help?

 

Br

Justin

 

0 Likes
Accepted solutions (1)
536 Views
5 Replies
Replies (5)
Message 2 of 6

FINET_Laurent
Advisor
Advisor

Hi @J.VandeMerckt

 

This little code let you pick a face once the rule is fired, then create a simple iMate constraint :

Dim f As Inventor.Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a face :")

Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim pcd As Inventor.PartComponentDefinition = doc.ComponentDefinition

Dim def As Inventor.iMateDefinition = pcd.iMateDefinitions.AddMateiMateDefinition(f, 0,,,"New iMate")

 

If you wan to select the face first, then fire the rule, here is the code adapted :

Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim pcd As Inventor.PartComponentDefinition = doc.ComponentDefinition

Dim f As Inventor.Face = doc.SelectSet.Item(1)

Dim def As Inventor.iMateDefinition = pcd.iMateDefinitions.AddMateiMateDefinition(f, 0,,,"New iMate")

 

Does this suits your needs?

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 6

J.VandeMerckt
Advocate
Advocate
Hi Laurent.

Thank you for the answers. It works as intended.
How should I change the last line when it's a flush or insert constrain?
For the matchlist it looks like I just place it behind the Imate name. I will test this.
0 Likes
Message 4 of 6

J.VandeMerckt
Advocate
Advocate

Edit: So it seems that I have to add the matchlist as object but I don't know how to do that.
My matchlist is just the name of a Imate of another part. Any idea how to add this one?

0 Likes
Message 5 of 6

FINET_Laurent
Advisor
Advisor
Accepted solution

@J.VandeMerckt,

 

Here are the code snippets for the flush & the insert constraints. You can uncomment the one you need :

Dim f As Inventor.Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a face :")

Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim pcd As Inventor.PartComponentDefinition = doc.ComponentDefinition

Dim matchList As String() = {"Match1", "Match2", "Match3"}

'Dim mate As Inventor.iMateDefinition = pcd.iMateDefinitions.AddMateiMateDefinition(f, 0, , , "New iMate", matchList)
Dim flush As Inventor.iMateDefinition = pcd.iMateDefinitions.AddFlushiMateDefinition(f, 0, , "New iFlush", matchList)
'Dim instert As Inventor.iMateDefinition = pcd.iMateDefinitions.AddInsertiMateDefinition(f, False, 0,, "New iInsert", matchList)

Notice that you need a circular face for the insert constraint. 

As for the match list, it requires a string array. I implemented it in the code above.

 

Here is some info about arrays :

Arrays - Visual Basic | Microsoft Learn

VB.NET Array Examples - Dot Net Perls

 

Kind regards,

FINET L.

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 6 of 6

J.VandeMerckt
Advocate
Advocate
Thank you for the help.
With this kind of code we can make repetitive assemblies much faster.