Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi @johnster100,

 

Here is a quick attempt at some of what @WCrihfield suggests.

 

I haven't tested it much, but did run it on a few small assemblies I had on hand.

 

This rule will:

  • allow you to select an assembly file
  • open it invisibly in express mode
  • create a Model State called "All Components Suppressed"
  • then suppress each component
  • then open the file visible in the "All Components Suppressed" model state

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Sub Main

	sMSName = "All Components Suppressed"

	Dim oFileName As String = Select_File()
	If oFileName Is Nothing Then Exit Sub

	Dim oDoc As AssemblyDocument
	oDoc = OpenInvisible_Express(oFileName)
	
	Dim oMSExists As Boolean = CreateModelState(oDoc, sMSName)

	If oMSExists = False Then
		MsgBox("Could find or create " & sMSName)
		Exit Sub
	End If

	Call OpenAllSuppressed(oFileName, sMSName)

End Sub

Sub OpenAllSuppressed(oFileName As String, sMSName As String)

	Dim oOptions As NameValueMap
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	Call oOptions.Add("ModelState", sMSName)

	oDoc = ThisApplication.Documents.OpenWithOptions(oFileName, oOptions, True)

End Sub

Function OpenInvisible_Express(oFileName As String)
	Dim oOptions As NameValueMap
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	Call oOptions.Add("ExpressModeBehavior", "OpenExpress")

	oDoc = ThisApplication.Documents.OpenWithOptions(oFileName, oOptions, False)
	Return oDoc
End Function

Function CreateModelState(oDoc As AssemblyDocument, sMSName As String)

	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = oDoc.ComponentDefinition

	Dim oModelState As ModelState
	'create ModelState in the top level

	Try : oModelState = oAsmCompDef.ModelStates.Add(sMSName) : Catch : End Try

	Dim oMSExists As Boolean
	Try
		oAsmCompDef.ModelStates.Item(sMSName).Activate
		oMSExists = True
	Catch
		oMSExists = False
		GoTo EndFunction
	End Try

	oAsmCompDef.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditActiveMember

	Dim oOcc As ComponentOccurrence
	For Each oOcc In oDoc.ComponentDefinition.Occurrences
		oOcc.Suppress(True)
	Next

	EndFunction :
	Return oMSExists

End Function


Function Select_File()

	Dim oFileDlg As Inventor.FileDialog = Nothing
	InventorVb.Application.CreateFileDialog(oFileDlg)
	oFileDlg.InitialDirectory = ThisApplication.FileLocations.Workspace
	oFileDlg.CancelError = True
	oFileDlg.MultiSelectEnabled = False
	oFileDlg.ShowQuickLaunch = False
	oFileDlg.Filter = "Assembly Files (*.iam)|*.iam"
	oFileDlg.DialogTitle = "Select a file."

	On Error Resume Next
	oFileDlg.ShowOpen()
	If Err.Number <> 0 Then
		Exit Function
	ElseIf oFileDlg.FileName <> "" Then
		Return oFileDlg.FileName
	End If

End Function