iLogic Command to load full assembly for exiting expressmode

iLogic Command to load full assembly for exiting expressmode

fabian.steinruck
Contributor Contributor
990 Views
8 Replies
Message 1 of 9

iLogic Command to load full assembly for exiting expressmode

fabian.steinruck
Contributor
Contributor

Hello, 

 

in our iLogic Routine, we export the opened assembly as a STEP file. 

In this existing rule we need to fully load the assembly before the export is happening, i couldn't find the command in the documentation about that. 

Also, tried the EventWatcher, but without success. 

 

How is the command called to fully load the assembly for exiting the express mode via iLogic?

0 Likes
Accepted solutions (1)
991 Views
8 Replies
Replies (8)
Message 2 of 9

Andrii_Humeniuk
Advisor
Advisor

Hi @fabian.steinruck . This code opens your assembly in full mode. Don't forget to write down the path to your file, line 4 (YourFile).

 

 

Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("ExpressModeBehavior", "OpenFull")
ThisApplication.Documents.OpenWithOptions(YourFile, oOptions, True)

 

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 9

fabian.steinruck
Contributor
Contributor

Sorry if I wrote my question a bit imprecise, the assembly is already opened. 

 

So if we decided to export this assembly as an step while already opened, I need the full load command like pressing the full load button.

0 Likes
Message 4 of 9

Andrii_Humeniuk
Advisor
Advisor

I'm sorry, but I couldn't find a command that directly exits Express mode. I hope this code helps you.

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim YourFile As String = oDoc.FullFileName
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("ExpressModeBehavior", "OpenFull")
oDoc.Close()
Dim expressDoc As AssemblyDocument = ThisApplication.Documents.OpenWithOptions(YourFile, oOptions, True)

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 5 of 9

fabian.steinruck
Contributor
Contributor
The sequence with close and reopen the Doc works but takes to long for the User for large assemblys over 1GB.

I also havent found a command that directly exits the Express mode while the doc is opened without closing it.
0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

Hi @fabian.steinruck.  Here are the two commands you are looking for:

AssemblyMakeHeavyWeightCmd

AssemblyMakeLightWeightCmd

...As you can imagine, the one with "MakeHeavy" will load the assembly fully, while the one with "MakeLight" will load it Express Mode.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Just in case you were not familiar with how to use those commands, they are the names of ControlDefinitions, which must be found, then executed, like this:

ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyMakeHeavyWeightCmd").Execute

The normal Inventor API way of switching an assembly from Express Mode to Load Full, is like this:

Dim oADoc As AssemblyDocument = ThisDoc.Document
If oADoc.IsOpenExpress Then
	oADoc.IsOpenExpress = False
End If

That property can only be changed one way (from True to False, not from False to True).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 9

fabian.steinruck
Contributor
Contributor

Awesome! 
Works as intended.

 

Such a time saver now! 
Thank you

0 Likes
Message 9 of 9

fabian.steinruck
Contributor
Contributor

Also here is my complete Code with the implementation for exiting the Express mode 

Maybe usefull for othere people

 

Spoiler
Imports System.Windows.Forms
Imports System.IO
Imports System.Diagnostics

Sub Main()
    Dim oDocument As Document = ThisApplication.ActiveDocument

    ' CHECK THAT PART OR ASSEMBLY FILE IS OPEN.
    If Not (oDocument.DocumentType = kAssemblyDocumentObject Or oDocument.DocumentType = kPartDocumentObject) Then
        MessageBox.Show("STEP können nur von 3D Modellen erzeugt werden", "Kein 3D Modell", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    ' GET THE FILE NAME FROM ACTIVE DOCUMENT.
    Dim oFileName As String = oDocument.DisplayName.Replace(".iam", "").Replace(".ipt", "")

    ' SET THE DEFAULT FOLDER PATH FOR FILE LOCATION.
    Dim sUserName As String = Environ("Username")
    Dim iPath As String = "C:\Users\" + sUserName + "\Documents\_Vault\"

    ' GET THE EXPORT FILE LOCATION FROM USER INPUT.
    Dim oFilePath = InputBox("Ordnerpfad angeben:" & vbNewLine & vbNewLine _
        & "Dateiname der STEP ist der Anzeigename der Baugruppe im Inventor Browser" _
        & vbNewLine & vbNewLine & "Vorschau:" & vbNewLine _
		& oFileName & ".stp" & vbNewLine & vbNewLine _
        & "Pfad kann mittels STRG+V eingefügt werden!", "Angabe STEP Ablageort", iPath)

    ' CHECK IF USER INPUT IS VALID
    If oFilePath = "" Then
        MessageBox.Show("Export Abgebrochen", "Export Abgebrochen", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    ' Exiting Express mode, only try if it's an assembly doc
    If oDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim oAssemblyDocument As AssemblyDocument = oDocument
        If oAssemblyDocument.ComponentDefinition.IsOpenExpress Then
            oAssemblyDocument.ComponentDefinition.IsOpenExpress = False
        End If
    End If

    ' Change "Ansichtsdarstellung" to Mainview
    Dim oCompDef As ComponentDefinition = oDocument.ComponentDefinition
    oCompDef.RepresentationsManager.DesignViewRepresentations.Item("Hauptansicht").Activate()

    ' GET THE STEP EXPORT ADDIN USING ID & ACTIVATE IT.
    Dim oInvAddIns As ApplicationAddIns = ThisApplication.ApplicationAddIns
    Dim STEP_TranslatorAddIn As TranslatorAddIn = oInvAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") 'TRANSLATOR: STP EXPORT
    STEP_TranslatorAddIn.Activate()

    Dim transientObj As TransientObjects = ThisApplication.TransientObjects
    Dim oContext As TranslationContext = transientObj.CreateTranslationContext
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oOptions As NameValueMap = transientObj.CreateNameValueMap
    Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium

    ' CHECK IF THE TRANSLATOR HAS 'SAVECOPYAS' OPTIONS
    If STEP_TranslatorAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
        oOptions.Value("ApplicationProtocolType") = 2 ' INTEGER
        oOptions.Value("IncludeSketches") = False ' BOOLEAN
        ' Set application protocol.
        ' 2 = AP 203 - Configuration Controlled Design
        ' 3 = AP 214 - Automotive Design

        oDataMedium.FileName = oFilePath & "\" & oFileName & ".stp"

        ' EXPORT STEP WITH PRE-SELECTED SETTINGS IN THE SELECTED FILE LOCATION.
        Try
            STEP_TranslatorAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

            ' Fancy Success message box
            ' Dim message As String = "Export erfolgreich." & vbNewLine & vbNewLine _
            ' & "Pfad: " & vbNewLine & oFilePath & vbNewLine & vbNewLine & "Name: " & vbNewLine & oFileName & ".stp"
            ' MsgBox(message, vbInformation, "Export Erfolgreich")
        Catch
            MessageBox.Show("Bei der STEP Erzeugung scheint etwas schief gelaufen zu sein", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End If

    STEP_TranslatorAddIn.Deactivate()
End Sub
0 Likes