save as STEP on network location

save as STEP on network location

Anonymous
Not applicable
650 Views
8 Replies
Message 1 of 9

save as STEP on network location

Anonymous
Not applicable

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
0 Likes
Accepted solutions (1)
651 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

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

 

0 Likes
Message 3 of 9

Owner2229
Advisor
Advisor

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
0 Likes
Message 4 of 9

Anonymous
Not applicable

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

0 Likes
Message 5 of 9

Owner2229
Advisor
Advisor

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
0 Likes
Message 6 of 9

Anonymous
Not applicable

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?

0 Likes
Message 7 of 9

Owner2229
Advisor
Advisor
Accepted solution

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
Message 8 of 9

Anonymous
Not applicable

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.

0 Likes
Message 9 of 9

Owner2229
Advisor
Advisor

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
0 Likes