Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Imate constraint with Ilogic

Anonymous

Imate constraint with Ilogic

Anonymous
Not applicable

I placed several bearings from Content Center and I want to place them on shafts with Insert constraint. I have the following rule that works:

 

SyntaxEditor Code Snippet

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
 
Dim oOcc1 As ComponentOccurrence
Dim oOcc2 As ComponentOccurrence
Dim bearing_name As String=Parameter("category4")+":1"
oOcc1 = Component.InventorComponent(bearing_name)
oOcc2 = Component.InventorComponent("shaft1")

Dim oPartDef1 As PartComponentDefinition
oPartDef1 = oOcc1.Definition
 
Dim oPartDef2 As PartComponentDefinition
oPartDef2 = oOcc2.Definition
 
Dim iMate1 As iMateDefinition
iMate1 = oPartDef1.iMateDefinitions.Item(2)

Dim iMate2 As iMateDefinition
iMate2 = oPartDef2.iMateDefinitions.Item(8)

Dim oEntity1 As Object
Dim oEntity2 As Object
 
Call oOcc1.CreateGeometryProxy(iMate1.Entity, oEntity1)
Call oOcc2.CreateGeometryProxy(iMate2.Entity, oEntity2)

Dim colCons As AssemblyConstraint
colCons = oAssyDoc.ComponentDefinition.Constraints.AddInsertConstraint(oEntity1, oEntity2, 1, 0)

The problem is on this line 

iMate1 = oPartDef1.iMateDefinitions.Item(2)

No2 reprezent the index number of the iMate constraint of the bearing from CC. (one of the insert constraints)

But sometimes the index number is different, 1 to 5.

I want to be able to define iMate1 as the name of the constraint "Insert In1" and not the index number. Somthing like this

iMate1 = oPartDef1.iMateDefinitions.name("Insert In1")

but is not working

0 Likes
Reply
Accepted solutions (1)
3,954 Views
12 Replies
Replies (12)

Anonymous
Not applicable

I'm still stuck on this stage. Could someone give me an answer?

0 Likes

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi marcu.bogdan,

 

If I understand correctly, you're wanting to use existing iMates to mate components in your assembly. Here is a quick example that uses AddByTwoiMate method.

 

I've attached a simple example file set as well.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
Dim oOcc1 As ComponentOccurrence
Dim oOcc2 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.ItemByName("Shaft101:1")
oOcc2 = oAsmCompDef.Occurrences.ItemByName("ISO 1224 (I) (Inch) 0.375 x 0.625 x 0.1562:1")

i = 1
For each  iMateDefinition in oOcc1.iMateDefinitions
	If iMateDefinition.Name= "Insert100" Then
		iMate1 = oOcc1.iMateDefinitions.Item(i)
		Exit For
	End If
	i = i+1
Next

i = 1
For each  iMateDefinition in oOcc2.iMateDefinitions
	If iMateDefinition.Name= "Insert In1" Then
		iMate2 = oOcc2.iMateDefinitions.Item(i)
		Exit For
	End If
	i = i+1
Next

' Create an iMate result between two iMates
Dim oiMateResult As iMateResult
oiMateResult = oAsmCompDef.iMateResults.AddByTwoiMates(iMate1, iMate2)



 

0 Likes

sam
Advocate
Advocate

Hi Curtis, 

Sorry to add to an already solved thread. 

if item A has a composite imate and it could be places on item B on 6 different locations (6 imate composites defined on item B as well. Is there way then when we place item A in assembly it asks for which solution to make out of 6 on item B. 

sorry again - here is link to my separate thread where I have requested for this:

https://forums.autodesk.com/t5/inventor-customization/ilogic-to-choose/m-p/8903303/highlight/true#M9...

 

Best regards, 

Sajid 

0 Likes

JBerns
Advisor
Advisor

Would someone please confirm that 'AddByTwoiMates' does not support iMates with non-matching Offset values?

Perhaps Chandra @chandra.shekar.g or Mike @MjDeck  from Autodesk?

 

I tested the assembly and iLogic above. It works correctly in its original form.

 

In the shaft part, I edited the iMate named, "Insert100". I changed the Offset value from 0.0 in to 1.0 in.

When I ran the rule, an error resulted: "The parameter is incorrect."

I edited the bearing's iMate named "Insert In1". It had a value of 0 mm. I changed it to 1.0 in. (Matching values)

The rule ran successfully.

 

Undo to restore part positions.

 

In the shaft part, I set an Offset = 1.0 in. In the bearing I set an Offset = 25.4 mm. The rule ran successfully.

 

I restored the bearing's iMate value to 0 mm and got an error: "iMate Result failed to compute due to value mismatch." I only got that error to happen one time after multiple Offset value edits.

 

I conclude the problem is that 'AddByTwoImates' must have matching Offset values. This is very inconvenient.

When manually constraining using iMates with different Offset values, the Offset value used is based on which part you select first. Use ALT-Drag to test this.

 

This would indicate that Content Center parts that use equations in their Offset value cannot be used with 'AddByTwoiMates' if there is a chance their Offset values will not evaluate to match.

 

For example, place from Content Center a Hex Cap Screw - Inch 1/2-13 - 2 UNC or an ISO 4017 M12 x 50. Each contain an iMate named 'Insert In1'. However, the ANSI part uses a formula in the Offset value, -( NLG + SD ) + GUL, and the ISO part uses a fixed value, 0.0 mm. The ANSI part has its iMate at the end of the threaded bolt away from the head. The ISO bolt has its iMate located under the head. That makes more sense to me.

CC Part Differences 2019-10-24_10-22-44.png

 

Can you interrogate the iMates within a Part to determine their type, direction, mode, value, etc.? If so, I guess you might be able to assemble ANSI CC parts using some other constraint method. Seems like a lot of extra work. Otherwise, I will have to re-edit the custom CC parts I have made from ANSI to change the existing iMate to that used in ISO CC parts.

 

I hope someone can find a way to use 'AddByTwoiMates' when Offsets have non-matching values.

 

I look forward to the replies.

 

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

MjDeck
Autodesk
Autodesk

@JBerns , I confirmed that AddByTwoiMates will only work if the offset values are equal. You could log an enhancement request to remove this limitation.
Yes, you can read the properties of the iMateDefinition (or InsertiMateDefinition in this case) through the API. You should be able to get enough data from that to create a constraint directly on the faces or edges.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes

JBerns
Advisor
Advisor

Mike,

 

I would consider this a bug, not an enhancement request.

 

Please watch this video that demonstrates how iMates with varying Offset values can be used with the ALT-Drag assembly technique.

https://autode.sk/2BGKqCH 

 

Clearly the AddByTwoiMates function supports non-zero values and mixed units that evaluate to the same value.

 

Why does the function require the values to match? Inventor doesn't, as shown in the video above.

 

 

Respectfully,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

MjDeck
Autodesk
Autodesk

Jerry,

 I agree there does seem to be a defect. The behavior is inconsistent between different workflows. However, the API behavior is as designed. You also get the same behavior if you add a component to an assembly without using the iMates and then use the Constrain command (from the ribbon) to try to put them together. They won't match if the offsets are different.

Here's a very old forum post that talks about our original intent for iMate offsets. See message 5 from Scott Kohls. I'll try to find out if anything has changed since then.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes

JBerns
Advisor
Advisor

Mike,

 

Thanks for the quick reply and agreement on the defect issue.

 

Could you clarify your statement, "You also get the same behavior if you add a component to an assembly without using the iMates and then use the Constrain command (from the ribbon) to try to put them together. They won't match if the offsets are different."

 

To my experience, you cannot select an iMate using the Constrain command from the ribbon. Their offset values are not accessed by the Constrain command. Offsets are used during 'Place Component' and yes, the Offset values must match or the iMate will not resolve.

 

The goal is to automate a drag conveyor which includes the fastening of different components and components that vary in thickness. Using iLogic, how would you assemble ANSI bolts, washers, and nuts obtained from the Content Center?

Drag_Images_2019-10-25_12-08-09.png

 

Will it be necessary to edit the ANSI bolts and change the Offset value from a formula to a number (0in)? I had already copied and edited the original ANSI parts to our custom CCL when I discovered this iMate issue. I may have to edit them again. I imagine I never would have had this problem if I had used ISO parts from the CCL. ๐Ÿ˜‰

 

Thanks again for your time and attention. I look forward to any advice you can offer, Mike, as well as the community,   regarding fastener automation.

 

Kind regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional

MjDeck
Autodesk
Autodesk

Jerry,

 Let me answer your question about using the Constrain command with iMates first. 
It will work if you select the proper type of constraint. When you start the command, the default is Mate. In this case, you want to select Insert. Then two Insert iMates with the same offset will work.

 

 


Mike Deck
Software Developer
Autodesk, Inc.

JBerns
Advisor
Advisor

Mike,

 

Interesting - in 20 years of using Inventor, I can't recall selecting an iMate with the Constrain command - I have typically used ALT-Drag. Good to know that. Thanks.

 

Do you think it would be a benefit if Constrain supported varying Offsets? Just use the value from the first selection much like ALT-Drag does. That I'm sure would have to be an enhancement request.

 

- Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

MjDeck
Autodesk
Autodesk

Jerry,

 It seems like the behavior in Alt-Drag is the same as it is in the API and Constrain command. You can't match two iMates with different offsets. However, you can connect an Insert iMate (with any offset) directly to a circular edge. That's an iMate-to-geometry constraint, not iMate-to-iMate.

 

About the related issue: I'm not sure why the ANSI and ISO hex cap screws differ in their iMate offsets. It would be better if they were the same. To work around that, you could have conditional code in a rule that would adjust the iMate offset in the connecting part depending on whether an ANSI or ISO screw was being used.


Mike Deck
Software Developer
Autodesk, Inc.

JBerns
Advisor
Advisor

Mike,

 

Thanks for the reply and explanation. I will have to find an alternate method to assemble the fasteners.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes