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: 

ilogic export step to custom directory

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
4029 Views, 2 Replies

ilogic export step to custom directory

Hi Guys, 

 

We've got a few Ilogic external rules we use regularly to export PDF/DXF's of our sheet metal parts for laser cutting and folding. They go into a specific directory on another drive for our purchasing staff to use.

 

Our suppliers have a new software which can work more efficiently using .step files. I found a code which exports the step file to the same directory the parts our saved, but I'm not great with ilogic and I'm struggling to figure out how to direct the exported part to the specific directory we want them to go to.

 

This is the step file code, I've seen it posted in a few different threads.

' Start of iLogic code *******************************************
Stepfilename = ThisDoc.PathAndFileName(False)
FileExists = True
 
'check to see if the file to be exported already exists
Do While FileExists    
    ' Define name of exported file - note a .stp file extension 
    ' Is currently being used. In this example I am exporting a Step file
	Rev = iProperties.Value("Project", "Revision Number")
    CurrentFile = Stepfilename & Rev & ".stp"
    
    'If Dir(CurrentFile) <> "" Then ' The file does exist
     '   Counter += 1
      '  FileExists = True
    'Else
        SaveAs = MessageBox.Show("Export file as '" & CurrentFile & _
        "'?", "Cadline iLogic", _
        MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
        MessageBoxDefaultButton.Button1)
        If SaveAs = vbNo Then
            Return
        Else ' User says continue
            FileExists = False
        End If
 '   End If
Loop
 
' Put your export or 'save as' code in here ***********************
 
' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById _
("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
 
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument _
, oContext, oOptions) Then
    oOptions.Value("ApplicationProtocolType") = 3
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oData As DataMedium
    oData = ThisApplication.TransientObjects.CreateDataMedium
    
    ' Set export name of STEP file
    oData.FileName = CurrentFile
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext _
, oOptions, oData)
End If
 
' End of export code ***********************************************
 
' Ask user if they want to open the export folder
'OpenFolder = MessageBox.Show("Export successful! " & _
'"- open containing folder now?", "Cadline iLogic", _
'MessageBoxButtons.YesNo, _
'MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)
 
'If OpenFolder = vbYes Then
'    Process.Start("explorer.exe", ThisDoc.Path)
'Else ' User says continue
    'Return
'End If
 
' End of iLogic code **************************************************

I've looked at these snippets of our dxf export code to try and get the parts directing the file to the correct directory

Dim sPATH As String

    sPATH = "P:\Procurement\Drawing"

    sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES"

    Dim sFname As String

    sFname = sPATH & "\" & ThisDoc.FileName(False) & iProperties.Value("Project", "Revision Number") & ".dxf"

    MessageBox.Show("DXF SAVED TO: " & sFname ,"DXF Saved", MessageBoxButtons.OK)

Any help would be greatly appreciated

 

Thanks
Matt

2 REPLIES 2
Message 2 of 3
mcgyvr
in reply to: Anonymous

Change this line..

CurrentFile = Stepfilename & Rev & ".stp"

To this..

CurrentFile = "C:\Mylocation\" & Stepfilename & Rev & ".stp"

C:\Mylocation\ is the folder path where you want it saved..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 3
Anonymous
in reply to: mcgyvr

Easy as that, thanks

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

Post to forums  

Autodesk Design & Make Report