iLogic save as STEP in same folder as source file with new name

iLogic save as STEP in same folder as source file with new name

EScales
Advocate Advocate
955 Views
2 Replies
Message 1 of 3

iLogic save as STEP in same folder as source file with new name

EScales
Advocate
Advocate

So, I used the custom iLogic snippet called "Save As STEP File".  It works fine, just the way it is to save the STEP file with the same name as the source file and in the same folder as the source file.  But, what I really want to do is save a STEP file to the same folder as the source, but use the iProperty "Part Number" and then an underscore "_" and then the iProperty "Revision Number" for the new file name.

I added one line to define the Step File Name and also added a line below the oData.Filename line, to try and pull the current document path and then the new file name.  It works except it always saves the file one folder higher than the source file folder location and it adds that folder name to the beginning of the new file name.

 

Example:

The source file is in C:\Work\Designs\Testing.  I want the file name to be Eric-123456_A.stp

It saves the file in C:\Work\Designs and names the file TestingEric-123456_A.stp

 

Any idea what I'm doing wrong?

 

Saving Step File.png

 

SyntaxEditor Code Snippet

' 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

oStepFileName = iProperties.Value("Project", "Part Number") & "_" & iProperties.Value("Project", "Revision Number")

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 = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oData As DataMedium
    oData = ThisApplication.TransientObjects.CreateDataMedium
    'oData.FileName = ThisDoc.PathAndFileName(False) & ".stp"
    oData.FileName = ThisDoc.Path & oStepFileName & ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If

 

0 Likes
Accepted solutions (1)
956 Views
2 Replies
Replies (2)
Message 2 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@EScales,

 

Code needs small changes in path of saved step file (oData.FileName = ThisDoc.Path & "\" & oStepFileName & ".stp")

 

' 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

oStepFileName = iProperties.Value("Project", "Part Number") & "_" & iProperties.Value("Project", "Revision Number")

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 = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oData As DataMedium
    oData = ThisApplication.TransientObjects.CreateDataMedium
    'oData.FileName = ThisDoc.PathAndFileName(False) & ".stp"
    oData.FileName = ThisDoc.Path & "\" & oStepFileName & ".stp"
    oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 3

EScales
Advocate
Advocate

This worked perfectly!  Thank you for the help.

0 Likes