Blog posts

Bio

By Luke Davenport 

Problem:

You want to automatically flip the direction of an insert constraint using an iLogic rule.

Solution:

This was a request from one of our customers on a support call – we don’t normally write code for support purposes, but occasionally we can be enticed to blog it (:

I must admit, I thought this would be 2 lines of code. Find the insert constraint, and flip it. How hard can it be? But strangely, the ‘AxisOpposed’ property of insert constraints is Read-Only, so you can’t change it with code. However any good iLogic jockey knows a workaround or two – if you can’t edit it, delete it and re-create it right?

You can download the code below. It does the following:

  • Looks for a constraint called ‘InsertNew’ in the active assembly (you can change this to anything you like).
  • Gets some information from the constraint (which edges are constrained and whether the direction is currently opposed)
  • Deletes the constraint
  • Creates the constraint again, the other way around.
  • Renames it to be the same name as before. 

You could of course edit the rule to flip multiple insert constraints instead of just the one, but I’ll leave some of the fun to you. See the video below showing the rule in action. 

Download the code HERE

Comments

1 comment

  • Avatar
    Laurence Marshall

    Can I also suggest that under your AxesOpposed Dim, that you also name the parameter:
    Dim Distance As String = Parameter(InsertName)

Please sign in to leave a comment.