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: 

Problem running VBA triggered iLogic Rule in subparts and -assemblies

0 REPLIES 0
Reply
Message 1 of 1
matsprestegard
268 Views, 0 Replies

Problem running VBA triggered iLogic Rule in subparts and -assemblies

Hi

 

I have an external iLogic rule that is triggered by a VBA. The problem i am havin is that when i edit a sub-part or sub-assembly within an assembly the iLogic rule is run on the overhead assembly.

 

My iLogic rule is for showing the the weight of the current part/assembly, but when i edit a sub-part or -assembly it shows the weight of the overhead assembly as stated above.

 

I suspect the problem is within the VBA as i'm not having this problem running the iLogic rule manually

 

Se VBA code below

 

Public Sub Weight()
  RuniLogic "Weight"
End Sub

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.RunExternalRule oDoc, RuleName
End Sub
 
Function GetiLogicAddin(oApplication As Inventor.Application) As Object
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

iLogic Rule used:

 

MessageBox.Show (Round(iProperties.Mass) & " Kg", "Weight")

 

 

Example pictures showing the problem. 

 

Example 1.png

Example 2.png

 

 

0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report