Suppress Event Trigger iLogic Rule when opening STEP file

checkcheck_master
Advocate

Suppress Event Trigger iLogic Rule when opening STEP file

checkcheck_master
Advocate
Advocate

I have a rule that starts up with every new document.
In the rule, the browser tree is displayed in a certain way.
Works fine for ipt and iam files.
If I want to open a STEP file, the rule ensures that the STEP is not built.
How can I make sure that the rule is suppressed when a STEP file is opened?

0 Likes
Reply
550 Views
4 Replies
Replies (4)

A.Acheson
Mentor
Mentor

How are you opening the steps, manually or using iLogic?  In what way does the file get effected? Have you a video or screenshots? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

checkcheck_master
Advocate
Advocate

Thank you A.Acheson for your comment,

See attached video and code.
Inventor itself bypasses the 'Import' dialog window.
You would say it shouldn't be that complicated to get the path of the file, but I don't know how.

 

' Expand_Browser_On_Save_Or_Open_Document
'MessageBox.Show("Wait...")
'Sub main

Logger.Info(vbNewLine & vbNewLine & vbNewLine)

Logger.Info("ThisApplication.ToString: " & ThisApplication.ToString)

Dim ActiveDoc As Inventor.Document = ThisApplication.ActiveDocument
Logger.Info("ActiveDoc: " & ActiveDoc.FullDocumentName )

Dim ActiveEditDoc As Inventor.Document = ThisApplication.ActiveEditDocument
Logger.Info("ActiveEditDoc: " & ActiveEditDoc.FullDocumentName )

Dim oDoc As Inventor.Document = ThisDoc.Document
Logger.Info("ThisDoc.Document: " & oDoc.FullDocumentName)

Logger.Info("")

If Not oDoc.FullDocumentName = "" Then GoTo EndRule

'' ONLY for Project Specific Files or Template Files to avoid annoying behavior for other files
'If Not oDoc.FullDocumentName Like "*Projecten*" Or Not oDoc.FullDocumentName Like "*Templates*" Then
'	Exit Sub
'Else
'	' Do Nothing
'End If

'Dim xDoc As Inventor.Document = ThisApplication.ActiveDocument
'Dim strTime As String
'strTime = DateTime.Now.ToString(("HH:mm:ss"))
'Logger.Info(vbNewLine & vbNewLine & vbNewLine)
'Logger.Info(strTime & " InventorPLUS: Collapse Browser: oDoc.FullDocumentName = ThisApplication.ActiveEditDocument: "  & oDoc.FullDocumentName)
'Logger.Info(strTime & " InventorPLUS: Collapse Browser: ThisDoc.Document.FullDocumentName                                   : "  & ThisDoc.Document.FullDocumentName)
'Logger.Info(strTime & " InventorPLUS: Collapse Browser: xDoc.FullDocumentName = ThisApplication.ActiveDocument     : " & xDoc.FullDocumentName)
'Logger.Info(strTime & " InventorPLUS: Collapse Browser: ThisDoc.Document.FullDocumentName                                   : " & oDoc.AllReferencedDocuments.Count)
'Logger.Info("")

' Check file type
If oDoc.DocumentType = kPartDocumentObject Then
'If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		
	' BUG in IV2022 for next line, therefore alternative approach by Krieg:
	'ThisApplication.CommandManager.ControlDefinitions("AppBrowserExpandAllCmd").Execute 
	InventorVb.RunMacro("ApplicationProject", "Collapse_Expand_nav_bug", "CollapseAll")
	
	' Use DoEvents to force Inventor to wait till the code is finished...
	Call ThisApplication.UserInterfaceManager.DoEvents
	
	'RunMacro()
	
	' Fake Task, after CollapseAll Inventor did Collapse the Browser tree but did not Expand it, it looks like it takes to long for some reason.the Browser Tree
	'For i = 1 To 2
	'Logger.Info(i & " Fake Task to Let Inventor do his thing...")	
	'Next
	
	'System.Threading.Thread.Sleep(3000)
	'MessageBox.Show("Wait...")
	'GoTo EndRule
		
	' Set Home view / Zoom All
	Call ThisApplication.ActiveView.GoHome

		'Set a reference to the top node of the active browser
		Dim oTopNode As BrowserNode
		oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
		
		' Check for Normal Part or Sheet Metal Part
		If oDoc.DocumentSubType.DocumentSubTypeID = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then ' Normal Part (No Sheetmetal)
			Dim oNode1 As BrowserNode
			For Each oNode1 In oTopNode.BrowserNodes
				Try : If oNode1.FullPath Like "*Model States*" Then oNode1.Expanded = True
					Catch: End Try
				'If oNode1.FullPath Like "*Folded Model*" Then oNode1.Expanded = True
				Try :If oNode1.FullPath Like "*Solid Bodies*" Then oNode1.Expanded = True
					Catch: End Try
				Try :If oNode1.FullPath Like "*View*" Then oNode1.Expanded = True
					Catch: End Try
				Try :If oNode1.FullPath Like "*Origin*" Then oNode1.Expanded = True
					Catch: End Try
				
					'Dim oNode2 As BrowserNode
					'For Each oNode2 In oNode1.BrowserNodes
					'	If oNode2.FullPath Like "*Model States*" Then oNode2.Expanded = True
					'	If oNode2.FullPath Like "*Folded Model*" Then oNode2.Expanded = True
					'	If oNode2.FullPath Like "*Solid Bodies*" Then oNode2.Expanded = True
					'	If oNode2.FullPath Like "*View*" Then oNode2.Expanded = True
					'	If oNode2.FullPath Like "*Origin*" Then oNode2.Expanded = True
					
						'Dim oNode3 As BrowserNode
						'For Each oNode3 In oNode2.BrowserNodes
						'	If oNode3.FullPath Like "*Model States*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*Folded Model*" Then oNode3.Expanded = True	
						'	If oNode3.FullPath Like "*Solid Bodies*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*View*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*Origin*" Then oNode3.Expanded = True	
						'Next	
				'Next
			Next
		End If
		
		' Check for Normal Part or Sheet Metal Part
		If oDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' Sheetmetal Part
			Dim oNode1 As BrowserNode
			For Each oNode1 In oTopNode.BrowserNodes
				Try : If oNode1.FullPath Like "*Model States*" Then oNode1.Expanded = True
					Catch:MessageBox.Show("Error when expand Model States") : End Try
				Try : If oNode1.FullPath Like "*Folded Model*" Then oNode1.Expanded = True
					Catch:MessageBox.Show("Error when expand Folded Model") : End Try
				'Try :If oNode1.FullPath Like "Solid Bodies*" Then oNode1.Expanded = True
				'	Catch: End Try
				'Try :If oNode1.FullPath Like "*View*" Then oNode1.Expanded = True
				'	Catch: End Try
				'Try :If oNode1.FullPath Like "*Origin*" Then oNode1.Expanded = True
				'	Catch: End Try
				
				Dim oNode2 As BrowserNode
				For Each oNode2 In oNode1.BrowserNodes
					'Try :If oNode2.FullPath Like "*Model States*" Then oNode2.Expanded = True
					'	Catch: End Try
					'Try :If oNode2.FullPath Like "*Folded Model*" Then oNode2.Expanded = True
					'	Catch: End Try
					Try :If oNode2.FullPath Like "*Solid Bodies*" Then oNode2.Expanded = True
						Catch : 'MessageBox.Show("Error when expand Solid Bodies")
							End Try
					Try :If oNode2.FullPath Like "*Folded Model:View*" Then oNode2.Expanded = True
						Catch : 'MessageBox.Show("Error when expand Folded Model:View")
							End Try
					Try :If oNode2.FullPath Like "*Origin*" Then oNode2.Expanded = True
						Catch : 'MessageBox.Show("Error when expand Origin")
							End Try
					
						'Dim oNode3 As BrowserNode
						'For Each oNode3 In oNode2.BrowserNodes
						'	If oNode3.FullPath Like "*Model States*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*Folded Model*" Then oNode3.Expanded = True	
						'	If oNode3.FullPath Like "*Solid Bodies*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*View*" Then oNode3.Expanded = True
						'	If oNode3.FullPath Like "*Origin*" Then oNode3.Expanded = True	
						'Next	
				Next
			Next
		End If

' -------------------------------------------------------------------------------------------------------------------------------------------------------------	
Else If oDoc.DocumentType = kAssemblyDocumentObject Then
'ElseIf ThisApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject And oDoc.FullDocumentName = ThisDoc.Document.FullDocumentName Then 
		
	' BUG in IV2022:
	'ThisApplication.CommandManager.ControlDefinitions("AppBrowserExpandAllCmd").Execute 
	InventorVb.RunMacro("ApplicationProject", "Collapse_Expand_nav_bug", "CollapseAll")
	
	' Use DoEvents to force Inventor to wait till the code is finished...
	Call ThisApplication.UserInterfaceManager.DoEvents
	
	'RunMacro()

	' Fake Task, after CollapseAll Inventor did Collapse the Browser tree but did not Expand it, it looks like it takes to long for some reason.the Browser Tree
	'For i = 1 To 20
	'	Logger.Info(i & " Fake Task to Let Inventor do his thing...")
		'System.Threading.Thread.Sleep(1000)
	'Next

	'MessageBox.Show("Wait...")
		
	' Set Home view / Zoom All
	Call ThisApplication.ActiveView.GoHome
	
	'TryOut()
		
		'Set a reference to the top node of the active browser
		Dim oTopNode As BrowserNode
		oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
			
		' All nodes where collapsed, expand some folders
			
		Dim oNode1 As BrowserNode
		For Each oNode1 In oTopNode.BrowserNodes
			If oNode1.FullPath Like "*:Model States*" Or _	
			   oNode1.FullPath Like "*:Representations*" Or _
			   oNode1.FullPath Like "*:View*" Or _
			   oNode1.FullPath Like "*Position*" Or _
			   oNode1.FullPath Like "*:Origin*" Or _
			   oNode1.FullPath Like "*xxWelds*" Or _
			   oNode1.FullPath Like "*xxBeads*" Or _
			   oNode1.FullPath Like "*Sheet" Then
				' If the node is visible and expanded, collapse it.
				If oNode1.Visible = True And oNode1.Expanded = False Then
				oNode1.Expanded = True
				End If
			End If
		
			Dim oNode2 As BrowserNode
			For Each oNode2 In oNode1.BrowserNodes
				If oNode2.FullPath Like "*Position*" Or _
				   oNode2.FullPath Like "*View*" Or _
				   oNode2.FullPath Like "*xxWelds*" Or _
				   oNode2.FullPath Like "*xxBeads*" Or _
				   oNode2.FullPath Like "*Sheet" Then
					' If the node is visible and expanded, collapse it.
					If oNode2.Visible = True And oNode2.Expanded = False Then
					oNode2.Expanded = True
					End If
				End If
			Next
		Next
End If

EndRule:

'End Sub

'Sub RunMacro
	
'	' BUG in IV2022:
'	'ThisApplication.CommandManager.ControlDefinitions("AppBrowserExpandAllCmd").Execute 
'	InventorVb.RunMacro("ApplicationProject", "Collapse_Expand_nav_bug", "CollapseAll")
	
'End Sub

'Function TryOut()As Integer

'Dim oDoc As Inventor.Document = ThisApplication.ActiveEditDocument

''Set a reference to the top node of the active browser
'		Dim oTopNode As BrowserNode
'		oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
			
'		' All nodes where collapsed, expand some folders
			
'		Dim oNode1 As BrowserNode
'		For Each oNode1 In oTopNode.BrowserNodes
'			If oNode1.FullPath Like "*:Model States*" Or _	
'			   oNode1.FullPath Like "*:Representations*" Or _
'			   oNode1.FullPath Like "*:View*" Or _
'			   oNode1.FullPath Like "*Position*" Or _
'			   oNode1.FullPath Like "*:Origin*" Or _
'			   oNode1.FullPath Like "*xxWelds*" Or _
'			   oNode1.FullPath Like "*xxBeads*" Or _
'			   oNode1.FullPath Like "*Sheet" Then
'				' If the node is visible and expanded, collapse it.
'				If oNode1.Visible = True And oNode1.Expanded = False Then
'				oNode1.Expanded = True
'				End If
'			End If
		
'			Dim oNode2 As BrowserNode
'			For Each oNode2 In oNode1.BrowserNodes
'				If oNode2.FullPath Like "*Position*" Or _
'				   oNode2.FullPath Like "*View*" Or _
'				   oNode2.FullPath Like "*xxWelds*" Or _
'				   oNode2.FullPath Like "*xxBeads*" Or _
'				   oNode2.FullPath Like "*Sheet" Then
'					' If the node is visible and expanded, collapse it.
'					If oNode2.Visible = True And oNode2.Expanded = False Then
'					oNode2.Expanded = True
'					End If
'				End If
'			Next
'		Next

'End Function

 

 

 
0 Likes

A.Acheson
Mentor
Mentor

I tried this rule on various step files but not .stp extensions. it seemed to open fine for the part where as for a step that opened as an assembly the assembly rule failed to collapse the browser. However I was missing the Macro called in the rule so I wonder does that also impact the rule performance?

 

If this reason for not working correctly is tied into the on events "New Document" you may have limited option available to you. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

checkcheck_master
Advocate
Advocate

Thanks A.Acheson for your testing and comment and thus pointing me in the right direction!
It turns out that it is indeed the 'missing macro'.
That macro thinks it finds a part/assembly and can then reorganize the browser there by means of a mouse event.
However, at that moment Inventor shows the 'Import' window and then waits for input from the user, which causes it to go wrong.


As far as I've been able to determine, oDoc.Dirty = True when opening a STEP file and = False when starting a new Part or Assembly.
It seems to work fine by running the macro based on this value.

 

What is your thought on this?

0 Likes