Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
569 Views, 8 Replies

save as STEP on network location

Hello

 

I have been exporting as STEP using the code supplied from the snippets.

My question is where in the code does it assign the save location? Can I send the STEP file out to a shared network location as an alternative to the default original folder?

Any help will be greatly appreciated.

' 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
    ' 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") = iProperties.Value("Summary", "Title")
    oOptions.Value("Organization") = "© XXXX XXXXX XXXXX " & Now.ToString("yyyy")
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oData As DataMedium
    oData = ThisApplication.TransientObjects.CreateDataMedium
    oData.FileName = ThisDoc.PathAndFileName(False) & "_" & iProperties.Value("Project", "Revision Number")& ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
Anonymous
in reply to: Anonymous

I should also mention that I have been attempting to do this another way but do not have all of the options I need to add the copyright details etc into the exported file.

Would it be easier to add the properties to this code?

If so, could anybody help me to do this please? 

'ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".stp"), True)
If Left(iProperties.Value(docFName,"Project", "Part Number"),2)= "PE" Then 
altName = "_" & iProperties.Value("Project","Revision Number") & ".stp" 
strFolder = "N:\PE\" & ThisDoc.FileName(False) 'without extension
ThisDoc.Document.SaveAs(strFolder & altName,True)

MessageBox.Show(ThisDoc.FileName(False) & altName & " saved!!" & vbCrLf & vbCrLf & strFolder & altName , "RELEASED STEP")


Else 


If Left(iProperties.Value(docFName,"Project", "Part Number"),2)= "SK" Then 
altName = "_" & iProperties.Value("Project","Revision Number") & ".stp" 
strFolder = "N:\SK\" & ThisDoc.FileName(False) 'without extension
ThisDoc.Document.SaveAs(strFolder & altName,True)

MessageBox.Show(ThisDoc.FileName(False) & altName & " saved!!" & vbCrLf & vbCrLf & strFolder & altName , "RELEASED STEP")


'ThisDoc.Document.SaveAs(strFolder & (".stp") , True)
'ThisDoc.Document.SaveAs(strFolder & (".pdf") , True)

'MessageBox.Show("All file formats saved", "File Save")

End If
End If

 

Owner2229
in reply to: Anonymous

Hey,

the folder is specifed on 3th row from bottom:

oData.FileName = ThisDoc.PathAndFileName(False) & "_" & iProperties.Value("Project", "Revision Number")& ".stp"

You can use this instead:

oData.FileName = "N:\PE\" & ThisDoc.FileName(False) & ".stp"

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Anonymous
in reply to: Owner2229

Excuse my naivety but isn't this to specify the filename? If I add the network location to this it throws up an error?

Owner2229
in reply to: Anonymous

By this you specify "Full path" which means "Path" & "File name".

 

I have no idea why it should throw an error, I'm ussing it to save files on shared server without any problems.

Inventor doesn't care if it is local or shared network or a post mail, as long as he can save there, he would.

 

But if you want to use this code on other PCs as well than either u need to map the server as the same disc letter (probably "N" In youre case) or use the network addres (e.g. "\\dc\file.ipt" for me).

 

And to use "ThisDoc.FileName(False)" the file muss be saved, so it have a name.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Anonymous
in reply to: Owner2229

Sorry I should have been more specific. When I use the code exactly as supplied it is fine but I need the underscore & revision number to appear at the end of the step file name. If I add this info to the line of code it no longer works. How can I specify this without it throwing up an error please?

Owner2229
in reply to: Anonymous

Ah, I see now. See the code below:

oData.FileName = "N:\PE\" & ThisDoc.FileName(False) & "_" & iProperties.Value("Project", "Revision Number") & ".stp"
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Anonymous
in reply to: Owner2229

That's working although I don't know why it wasn't when I tried it?

Can't thank you enough for your help, much appreciated.

Owner2229
in reply to: Anonymous

You're welcomed.

Maybe you just missed & or quotation marks.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods