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: 

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

4 REPLIES 4
Reply
Message 1 of 5
PaulMunford
1796 Views, 4 Replies

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

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

 


Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin Twitter Instagram Facebook Pinterest

4 REPLIES 4
Message 2 of 5
PaulMunford
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?

 


Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin Twitter Instagram Facebook Pinterest

Message 3 of 5
PACDrafting
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.

Message 4 of 5
PaulMunford
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?

 


Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin Twitter Instagram Facebook Pinterest

Message 5 of 5
PaulMunford
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

 


Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin Twitter Instagram Facebook Pinterest

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

Post to forums  

Autodesk Design & Make Report