Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic Axis to Axis Mate Opposed Or Aligned

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Russell.BrownVEZMW
1008 Views, 5 Replies

Ilogic Axis to Axis Mate Opposed Or Aligned

Hi,

 

Does anyone know if there's a way to define whether an axis to axis mate constraint is aligned or opposed. My code below just sets the constraint to unidirectional by default:

 

oAsmCompDef.Constraints.AddMateConstraint(ComponentAxis1Prox, ComponentAxis2, 0, ) 

Any help would be much appreciated!

 

Thanks,

5 REPLIES 5
Message 2 of 6

You would have to compare the vectors or unit vectors of both Axis objects to see if they need to be aligned or opposed.  It's not the most straight forward process, because when you start talking about vectors, unit vectors, Matrix, Matrix2d, and similar objects, it starts going over most folks heads, but they had to call these things something within the code environment, to be able to compare and manipulate physical things in 3D space.

 

UnitVectors consist of a set of coordinates, with at least one of the coordinates being equal to 1 length unit in the direction it is pointing.

I think this is one way you can compare the two axes, if I'm not mistaken.

I'm not 100% sure if the two UnitVectors being equal means they are both perfectly aligned and pointing in the same direction, or if it just means both are pointing in the same direction.

Dim oAx1 As WorkAxis
Dim oAx2 As WorkAxis
Dim oV1 As UnitVector = oAx1.Line.Direction
Dim oV2 As UnitVector = oAx2.Line.Direction
If oV1.IsEqualTo(oV2) Then
	'They are aligned and pointing in the same direction
ElseIf oV1.IsParallelTo(oV2) Then
	'They are parellel with each other
ElseIf oV1.IsPerpendicularTo(oV2) Then
	'They are perpendicular to each other
End If

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

Thank you @WCrihfield, but I think I have just found the solution to my problem.

 

I did not realise that there is a AddMateContraint2 method now. Using this in the code below allows me to select which type the constraint is. 

oAsmCompDef.Constraints.AddMateConstraint2(ComponentAxis1Prox, ComponentAxis2, 0,,,kOpposedSolutionType)

 

Message 4 of 6
alewis
in reply to: Russell.BrownVEZMW

Yes that's great. We now know there are options for solution types. Now they just need to cough up the option names.

Message 5 of 6
WCrihfield
in reply to: alewis

Hi @alewis.  As for the available option names...

The online help page for that 'AddMateConstraint2' method shows the two Enum's being used in that method to pull options from.  The one Enum is the 'InferredTypeEnum', and the other is the 'MateConstraintSolutionTypeEnum'.  If you follow those two links you will see what variations are available within each of them.  These can be tricky to use if you are not familiar with using Enum's, but to make life easier for yourself, always start by typing in the main name of the Enum, then put a point after that word (.), and that will usually show a list of the options/variations available within it, so you can choose one from the little pop-up list in the iLogic rule editor.  The line of code above did not include the main name of the Enum, just the option/variation name within it, which will usually still work OK, but then it doesn't offer any pop-up help when you hover your mouse over it.

As an example, copy and paste the following into a new empty iLogic rule:

MateConstraintSolutionTypeEnum

now put the dot (.) at the end of it, and it should show a little list of what variations are available within it.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6
alewis
in reply to: WCrihfield

Thank you for your help to my sarcastic plea. Thanks again for making clear what otherwise looks like a blurry mess of words in a foreign language.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report