• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    *Expert Elite*
    PaulMunford
    Posts: 671
    Registered: ‎11-13-2006

    Trigger iLogic rule on change of parameters in Assembly, 'Link Parameters' tool

    488 Views, 4 Replies
    11-07-2011 09:08 AM

    I'm having fun experimenting with the Autodesk Labs 'Link Paramneters' addin.

     

    The addin maps the parameters between my assembly file and part file perfectly. However, when I change parameter values in my Assembly file, I need to run the rule again to push the parameter values down to the part file.

     

    Is there any way to make the rule run as soon as the parameters are changed in the assembly document?

     

    Thanks in advance for any help you can offer.

     

    Paul

    The CAD Setter Out Blog
    @CadSetterOut
     
    Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
    Please use plain text.
    *Expert Elite*
    PaulMunford
    Posts: 671
    Registered: ‎11-13-2006

    Re: Trigger iLogic rule on change of parameters in Assembly, 'Link Parameters' t

    11-08-2011 12:11 PM in reply to: PaulMunford

    Bump!

     

    I am running windows 7 64 Bit, and Inventor 2012.

     

    I've tried adding the code to the 'Model Paremetrs' event trigger - no luck. Any more suggestions?

    The CAD Setter Out Blog
    @CadSetterOut
     
    Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
    Please use plain text.
    Mentor
    Posts: 565
    Registered: ‎10-22-2007

    Re: Trigger iLogic rule on change of parameters in Assembly, 'Link Parameters' t

    11-09-2011 01:02 PM in reply to: PaulMunford

    You may need to fire an event within the assembly that activates an ilogic rule within the part.

     

    E.g. insert a rule within your part and call the rule from the assembly rule.

    Please use plain text.
    *Expert Elite*
    PaulMunford
    Posts: 671
    Registered: ‎11-13-2006

    Re: Trigger iLogic rule on change of parameters in Assembly, 'Link Parameters' t

    11-09-2011 01:23 PM in reply to: PACDrafting

    Thanks PACdrafting. That's exactly the kind of thing I would like to do. Can you point me to any exmaples of how to do this?

    The CAD Setter Out Blog
    @CadSetterOut
     
    Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
    Please use plain text.
    *Expert Elite*
    PaulMunford
    Posts: 671
    Registered: ‎11-13-2006

    Re: Trigger iLogic rule on change of parameters in Assembly, 'Link Parameters' t

    11-17-2011 06:02 AM in reply to: PaulMunford

    I've knocked up a bit of code to make it happen.

     

     

    It's not very elegant though. If you have an opionion - please wade in!

     

    Option Explicit
    Private WithEvents oModelingEvents As ModelingEvents
    Private paramExpression As String
    
    'Run code in back ground as soon as the document opens
    Sub AutoOpen()
     
    OnParamChange
     
    End Sub
    
    'Look out for parameter changes
    Public Sub OnParamChange()
    
        Set oModelingEvents = ThisApplication.ModelingEvents
        
    End Sub
    
    'If a a parameter changes - run the "Table Rule"
    Private Sub oModelingEvents_OnParameterChange(ByVal DocumentObject As Document, ByVal Parameter As Parameter, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
    
    RuniLogic "Table Rule"
    
    End Sub
    
    'This stuff runs an iLogic rule from inside VBA
    Public Sub RuniLogic(ByVal RuleName As String)
      Dim iLogicAuto As Object
      Dim oDoc As Document
      Set oDoc = ThisApplication.ActiveDocument
      If oDoc Is Nothing Then
        MsgBox "Missing Inventor Document"
        Exit Sub
      End If
      Set iLogicAuto = GetiLogicAddin(ThisApplication)
      If (iLogicAuto Is Nothing) Then Exit Sub
      iLogicAuto.runrule oDoc, RuleName
    End Sub
    
    'This function gets the iLogic API
    Function GetiLogicAddin(oApplication As Inventor.Application) As Object
    Dim addins As ApplicationAddIns
    Set addins = oApplication.ApplicationAddIns
    'Find the add-in you are looking for
    Dim addIn As ApplicationAddIn
    On Error GoTo NotFound
    Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
    If (addIn Is Nothing) Then Exit Function
    addIn.Activate
    Set GetiLogicAddin = addIn.Automation
    Exit Function
    NotFound:
    End Function

     I have this saved in the document VBA module.

     

    I wish iLogic had more event hooks to make this sort of thing happen.

     

    Paul

    The CAD Setter Out Blog
    @CadSetterOut
     
    Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
    Please use plain text.