iLogic rule that would allow me to change which dimensions were defined and which were reference

iLogic rule that would allow me to change which dimensions were defined and which were reference

chris
Advisor Advisor
708 Views
7 Replies
Message 1 of 8

iLogic rule that would allow me to change which dimensions were defined and which were reference

chris
Advisor
Advisor

I have a unique design that requires I have the ability to fully dimension it, but based on which option is chosen would also have the ability to change any reference dimensions to defined or any defined dim's to reference.

0 Likes
709 Views
7 Replies
Replies (7)
Message 2 of 8

mat_hijs
Collaborator
Collaborator

@bradeneuropeArthur recently made a tool to do this: Sketch Driven Dimensional Constraints Switch - Autodesk Community

Maybe he can point you in the right direction.

Message 3 of 8

WCrihfield
Mentor
Mentor

Not sure how familiar you are with the objects involved, or their properties, but this does sound relatively easy to do.  There are two main categories of constraints in sketches (geometric & dimensional).  Within each category there is a 'base type' (GeometricConstraint & DimensionConstraint), and more specific types, for different purposes, that are 'derived from' that base type, but have more specific properties than the base type.  Anyways, the main property you would need to be working with is:  DimensionConstraint.Driven.  It is a Read/Write property with a Boolean type value.  Also, each DimensionConstraint has a Parameter associated with it, which can be obtained with the DimensionConstraint.Parameter property.  This is ReadOnly, which just means you can not set a different Parameter object as its value, but it does not mean you can not change the value of the Parameter object itself.  You will notice that when you change the value of the Driven property, that changes the Parameter associated with it between a regular ModelParameter and a ReferenceParameter in the Parameters dialog.  You can use this Parameter object to identify which constraint you are dealing with, as long as you know the names of those Parameters, or have renamed them.

 

With that in mind, you could have one or more Boolean type UserParameters specifically designated to controlling pairs of these (one that is Driven, and another that is Driving).  That Boolean UserParameter could be put into an iLogic Form as a checkbox control.  Then, if using an internal iLogic rule, including that blue, unquoted boolean parameters name in it, that would cause that rule to run whenever the value of that parameter changes.  Within that rule, could be some code that toggles which of those two DimensionConstraints is Driving or Driven.  Not exactly a 'direct' connection, but possible to automate with iLogic this way.

Just some food for thought that may help you during your development.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 8

chris
Advisor
Advisor

@WCrihfield is what you are talking about "snippet" iLogic or API iLogic?

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

It would be Inventor API based, so no iLogic snippets for that.  But there are not really any 'sketch' related iLogic snippets, so no big 'shortcuts' available.  The iLogic rule would need to be able to find the specific sketch that contains the DimensionConstraint first, then look within its DimensionConstraints collection to find the two you want to work with.  Usually by the names of the parameters associated with them.  Then, once you have a reference to those two objects, you can have a simple little If...ElseIf...End If type statement that sets their Driven property based on the value of that Boolean UserParameter.  Or, you can just skip the whole Boolean idea, and just name the iLogic rule for toggling those two specific constraints, then use different rules for toggling the other ones.  There are multiple options for how it could all be set-up.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 8

chris
Advisor
Advisor

@WCrihfield Do you know of a good training series that takes a movie, (no programming) through setting up on-two "simple rules with the IV API?

0 Likes
Message 7 of 8

WCrihfield
Mentor
Mentor

Not sure about a video just about this task, but you can check out the following two links on YouTube, which are pretty nice.

Autodesk Inventor iLogic Tutorial 

3DAllDayEveryDay 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor

Here is a quickie Inventor 2024 part file containing a simple block, with a single hole in it.  The sketch controlling where the hole is located on that part's face contains 4 dimensions.  One dimension from left edge to hole, and one from right edge to hole (pair to control), and one from bottom edge to hole, and one from top edge to hole (another pair to control).  I also created 2 Boolean UserParameters for the two internal iLogic rules in the part (as triggers to run them, when their values change by the internal iLogic Form.)  For some reason, the top/bottom pair is being controlled nicely, but the left/right pair are not behaving as expected.  It is saying that it can not find their dimension constraints.  Not sure why.  Anyways, I'm on my way out for the day, so that what I got done before leaving.  I hope it helps.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes