- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ilogic Open Assembly with All Components Suppressed
Hi,
I'm looking for some code to open a document with all components suppressed. I had a look at OpenWithOptions in the help file but this did not have an open for this.
can someone help?
thanks,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @johnster100. You can use the ThisApplicaiton.Documents.OpenWithOptions method, which will allow you to specify that 'all suppressed' LOD (or ModelState). But of course you would have to have created that LOD or ModelState ahead of time, otherwise it will not be an available option. It would be nice if there was already a pre-existing LOD or ModelState like that, but unfortunately there was not.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A couple of other settings that may help in cases like this are the:
ApplicationOptions > Assembly tab > Defer update
and the
ApplicationOptions > Assembly tab > Enable Express mode worflows - check the checkbox,
then set 'File Open Options' below that to 'Open Express when referenced unique files exeeds'
and set the number very low, like 4.
Disable the option named "Enable relationship redundancy analysis", on that same page.
All these settings can be accessed by code too, so you could temporarily set them this way ahead of opening assemblies, then set them back the way you normally want them, after the assembly has been opened.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Another idea would be to create/use an external iLogic rule, as a batch preparation utility, that you can run during 'off hours', that will process an entire directory of assembly files at a time. Opening each one, record its originally active LOD, then attempt to create the needed 'all components suppressed' LOD (or ModelState), then suppress all of the components, then set the LOD back to original, then save the assembly. That way, you will have the needed LOD's in place for future use. I'm pretty sure I have seen others here on the forums use that technique before too, so there may already be code like that here somewhere. It does not see like it would be too difficult to create something like that, but it would have to be thoroughly debugged, and fool proof, so it can run unattended.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
: