- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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"
- - - - - - - - - - - - - - -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- - - - - - - - - - - - - - -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ah, I see now. See the code below:
oData.FileName = "N:\PE\" & ThisDoc.FileName(False) & "_" & iProperties.Value("Project", "Revision Number") & ".stp"
- - - - - - - - - - - - - - -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You're welcomed.
Maybe you just missed & or quotation marks.
- - - - - - - - - - - - - - -
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