Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro to export in STEP like my macro PDF

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
amartin.r
4873 Views, 11 Replies

Macro to export in STEP like my macro PDF

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

11 REPLIES 11
Message 2 of 12
rossano_praderi
in reply to: amartin.r

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
in reply to: rossano_praderi

Hi,

Did Rossano code help you with your problem?

It seems to feedback the information you was requesting.

Jon.



Jon Dean

Message 4 of 12
amartin.r
in reply to: Jon.Dean

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

Message 5 of 12
VdVeek
in reply to: Jon.Dean

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
amartin.r
in reply to: VdVeek

Great !
I didn't know that there are samples to export / save to ...
It's much easier !
 
I will keep you updated.
Message 7 of 12
amartin.r
in reply to: amartin.r

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

 

Message 8 of 12
VdVeek
in reply to: amartin.r

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
in reply to: VdVeek

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

Message 10 of 12

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
Message 11 of 12
VdVeek
in reply to: MechMachineMan

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
in reply to: VdVeek

Thank you, yes this works.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report