A bit of fun with Inventor iLogic and driven constraints

Zen Admin
Zen Admin

by Clint Brown

I’ve called this a bit of fun with iLogic and driven constraints, because my intention is exactly that. What I am about to show you is a bit buggy and is far from perfect, but may be useful in some instances. For this reason, I urge you to not try it on any large assemblies, or on any production work.

I ran across a forum post in the Inventor customisation area of the Autodesk Community and it got me thinking. I have been asked if it is possible to drive more than one constraint at a time, I usually advise the best option is to do the animation suite in Inventor Studio, but when this post popped up, I decided to do something with it.

I’ve converted the VBA code to iLogic. The code iterates through the assembly and identifies constraints that were previously driven, the constraint is tagged as being “IsInitialized” under drive settings in the API. Once this “IsInitialized” flag is posted against the constraint, you cannot remove it (well at least not without going back in via the API which is a bit of overkill for this specific post).

The following video is self-explanatory.


Here is the code:

Sub Main()

    Dim assyDoc As AssemblyDocument

    assyDoc = ThisApplication.ActiveDocument

    Dim oConstraint As AssemblyConstraint

    For Each oConstraint In assyDoc.ComponentDefinition.Constraints

        If oConstraint.DriveConstraintSettings.IsInitialized Then

            With oConstraint.DriveConstraintSettings

                .StartValue = 0

                .EndValue = 20



                .StartValue = 0

                .EndValue = 20



            End With

        End If


End Sub

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.