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: 

iLogic detect FEA environment

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jls
Participant
408 Views, 2 Replies

iLogic detect FEA environment

Hello,

 

I would like to enable/suppress certain features in a part or assembly when entering FEA environment.

I have looked at the tips in http://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/discussion/t5/Inventor-Cu...

, but FEA doesn't report as an environment in that context, and i can't find it using the VBA object browser.

 

Any good tips?

 

Cheers

Jens

 

Tags (2)
2 REPLIES 2
Message 2 of 3
wayne.brill
in reply to: jls

Hi Jens,

 

The Inventor API has the UserInterfaceEvents.OnEnvironmentChange Event that may provide a way to do what you need. iLogic has Event Triggers but it does not include any event trigger that would run a rule when the environment changes.

 

Here is a VBA example to show the idea. (just to show the API). This example is suppressing/unsuppressing components in an assembly when the environment changes. Suppressing features would be similar.

 

Put this in a Class Module:

 

Private WithEvents UIE As UserInterfaceEvents

Private Sub Class_Initialize()

    Set UIE = ThisApplication.UserInterfaceManager.UserInterfaceEvents
End Sub

Private Sub Class_Terminate()
    Set UIE = Nothing
End Sub


Private Sub UIE_OnEnvironmentChange(ByVal Environment As Environment, ByVal EnvironmentState As EnvironmentStateEnum, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
    'Debug.Print Environment.DisplayName
    'Debug.Print BeforeOrAfter
    If Environment.DisplayName = "Assembly" Then
    If BeforeOrAfter = kAfter Then
    If ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Dim oCO As ComponentOccurrence
    For Each oCO In oAsmDoc.ComponentDefinition.Occurrences
        Debug.Print oCO.Name
        If oCO.Name = "EndPlate_Simple:1" Then
            If oCO.Suppressed = False Then
                Call oCO.Suppress
            Else
              Call oCO.Unsuppress
           End If
        End If
    Next
    End If
    End If
   End If
End Sub

 

Put this in a Module:

 

Dim oCls As clsUIE
Sub startE()
    Set oCls = New clsUIE
End Sub

Sub stopE()
    Set oCls = Nothing
End Sub

 

 

 

Run startE() to enable the event.

 

Thanks,

Wayne

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
jls
Participant
in reply to: wayne.brill

Hi Wayne,

 

I'm sorry it took so long for me to see your answer, i don't visit here often, and back then i had to just finish up and deliver.

However, i do appreciate your effort and i will try it out when i get a chance.

Thank you.

 

Cheers Jens

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

Post to forums  

Autodesk Design & Make Report