Ready to be blown away?
This is the long way to automate do it, but it gets the job done whey I tried it.
It basically simulates the manual actions of activating the FEA Analysis Environment, then creating a Study (because there needs to be one, and I'm not sure how to check to see if one already exists...yet), then opens the Settings dialog, then navigates through that dialog using simulated keyboard key presses, then either turns that specific setting on or off (depending on which line of code yo choose to use at the end), then uses Enter key to accept the changes and close the dialog.
This is not the preferred or recommended method, but may help you get through a lot of stuff in a hurry, if it works for you right now.
Here's the code:
'AddReference "Microsoft.VisualBasic.Devices"
Imports Microsoft.VisualBasic.Devices
Dim oRib As String
If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kPartDocumentObject Then
oRib = "Part"
ElseIf ThisApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oRib = "Assembly"
Else
MsgBox("This rule only works from a Part or Assembly document. Exiting.")
Return
End If
Dim oUIMgr As UserInterfaceManager = ThisApplication.UserInterfaceManager
Dim oRibbon As Ribbon = oUIMgr.Ribbons.Item(oRib)
Dim oTab As RibbonTab = oRibbon.RibbonTabs.Item("id_TabEnvironments")
Dim oPanel As RibbonPanel = oTab.RibbonPanels.Item("id_Panel_EnvironmentsBegin")
Dim oCC As CommandControl = oPanel.CommandControls.Item("FEA Environment Internal Name")
'This activates the Stress Analysis environment
oCC.ControlDefinition.Execute
Dim oFEA_Env As Inventor.Environment = oUIMgr.Environments.Item("FEA Environment Internal Name")
Dim oFEA_Ribbon As Ribbon = oFEA_Env.Ribbon
Dim oFEA_Tab As RibbonTab = oFEA_Ribbon.RibbonTabs.Item("id_TabAFEA")
Dim oFEA_ManagePanel As RibbonPanel = oFEA_Tab.RibbonPanels.Item("id_PanelA_AFEAManage")
Dim oFEA_SettingsPanel As RibbonPanel = oFEA_Tab.RibbonPanels.Item("id_PanelA_AFEASettings")
Dim oFEA_CreateStudy As CommandControl = oFEA_ManagePanel.CommandControls.Item("FeaCreateSimCmd")
'Creates a new Study
oFEA_CreateStudy.ControlDefinition.Execute
Dim oFEA_Settings As CommandControl = oFEA_SettingsPanel.CommandControls.Item("FeaSimulationSettingsCmd")
'Opens the Settings dialog
oFEA_Settings.ControlDefinition.Execute
'The following two lines of code use keyboard keys to navigate through the Settings dialog, turn the option on or off, then choose OK to keep the changes and close the dialog.
'To check the box (turn the option on) use the following line.
System.Windows.Forms.SendKeys.SendWait("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{RIGHT}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{+}{ENTER}")
'To un-check the box (turn the option Off) use the following line.
System.Windows.Forms.SendKeys.SendWait("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{RIGHT}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{-}{ENTER}")
It does not return you to the regular modeling environment either, yet. But probably could with some more work.
Wesley Crihfield

(Not an Autodesk Employee)