Macro to export in STEP like my macro PDF

Macro to export in STEP like my macro PDF

Anonymous
Not applicable
5,817 Views
11 Replies
Message 1 of 12

Macro to export in STEP like my macro PDF

Anonymous
Not applicable

Hi,

I wish to create a macro for to export my parts and assemblies in STEP files.
I tried to restart of the macro "PDF" (see attached file), but without success.

Where can I find the "key" of the ItemByID("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx}")

Like this :

Set PDFAddin = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

 

Thanks by advance

0 Likes
Accepted solutions (1)
5,818 Views
11 Replies
Replies (11)
Message 2 of 12

rossano_praderi
Collaborator
Collaborator

Hi,

this is a simple Ilogic rule that list all available addins

 

List = ""
For Each addin In ThisApplication.ApplicationAddIns
	If TypeOf addin Is TranslatorAddIn Then
		List &= addin.DisplayName & addin.ClassIdString & vbCr
	End If
Next
MsgBox(List)

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 3 of 12

Jon.Dean
Alumni
Alumni

Hi,

Did Rossano code help you with your problem?

It seems to feedback the information you was requesting.

Jon.



Jon Dean

0 Likes
Message 4 of 12

Anonymous
Not applicable

This tip helped me, but I trying again to do it work my macro VBA.

0 Likes
Message 5 of 12

VdVeek
Advocate
Advocate
Accepted solution

There is an example in the API Programming Help under TranslatorAddIn Interface. See Example 5 Export to STEP.

 

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 6 of 12

Anonymous
Not applicable
Great !
I didn't know that there are samples to export / save to ...
It's much easier !
 
I will keep you updated.
0 Likes
Message 7 of 12

Anonymous
Not applicable

I want to export with the filename of the part, but it's doesn't work.

 

Below my macro VBA, stopped at "FileName = oDocument.FullFileName"

 

Sub ExportToSTEP()
    ' Get the STEP translator Add-In.
    Dim oSTEPTranslator As TranslatorAddIn
    Set oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")

    If oSTEPTranslator Is Nothing Then
        MsgBox "Could not access STEP translator."
        Exit Sub
    End If

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
        ' Set application protocol.
        ' 2 = AP 203 - Configuration Controlled Design
        ' 3 = AP 214 - Automotive Design
        oOptions.Value("ApplicationProtocolType") = 3

        ' Other options...
        'oOptions.Value("Author") = ""
        'oOptions.Value("Authorization") = ""
        'oOptions.Value("Description") = ""
        'oOptions.Value("Organization") = ""

        oContext.Type = kFileBrowseIOMechanism

    'Set filename as original document filename.
    Dim FileName As String
    FileName = oDocument.FullFileName
 
    Dim Temp() As String
    Temp = Split(FileName, "\")
 
    FileName = Left(Temp(UBound(Temp)), Len(Temp(UBound(Temp))) - 4)

    'Set the destination to save files.
    Dim oDocRevision As Property
    Dim Revision As String
    Set oDocRevision = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
        If oDocRevision.Value = "" Then
            oDataMedium.FileName = "C:\Users\amn\Desktop\" & FileName & ".stp"
        Else
            Revision = "_" + CStr(oDocRevision.Value)
            oDataMedium.FileName = "C:\Users\amn\Desktop\" & FileName & Revision & ".stp"
        End If

        Dim oData As DataMedium
        Set oData = ThisApplication.TransientObjects.CreateDataMedium

    'Publish document.
    Call oSTEPTranslator.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
    End If
End Sub

 

0 Likes
Message 8 of 12

VdVeek
Advocate
Advocate

In the line where the error occurred, you are referring to oDocument but you didn't create the oDocument in your code.
If you create the oDocument and Set it to the active document than the code should work.

'Set filename as original document filename.
Dim oDocument As PartDocument
Set oDocument = ThisApplication.ActiveDocument
Dim FileName As String
FileName = oDocument.FullFileName

 Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 9 of 12

rolf_zimmermann
Enthusiast
Enthusiast

Dear all,

I need a macro to export a specific representation view to STP, not the whole model.

How can I do that with the macro ?

 

Kind regards

 

Rolf

0 Likes
Message 10 of 12

MechMachineMan
Advisor
Advisor

Hah. Don't think you can. Probably have to make a new .iam that only contains those components that match that view rep and export that.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 11 of 12

VdVeek
Advocate
Advocate
When you manualy make a step, it exports the model as the active LOD. So i think when you first let your code activate the LOD that the rest of the script will use that LOD.
Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 12 of 12

rolf_zimmermann
Enthusiast
Enthusiast

Thank you, yes this works.

0 Likes