09-30-2024
10:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-30-2024
10:35 AM
@WCrihfield Thanks for the great info. I will make those changes to further clarify the document.
I did end up getting the file detection aspect of the script working once I moved System IO below the portion of the code gathering the part number. Now I'm having a heck of a time trying to understand how to get the vbYes and vbNo to work. I found your blog post related to using Yes and No (https://inventortrenches.blogspot.com/2011/03/using-yes-no-message-box-in-your-ilogic.html) but I'm having a hard time trying to understand how to add in if Yes then run the rest of my code but if No then exit the code entirely and disregard overwriting the STEP file.
....snipped code....
' Get Part Number
Dim sPN As String = iProperties.Value("Project", "Part Number")
If sPN.StartsWith("U") Then
oStepFileName = iProperties.Value("Custom", "FS Part Number")
Else If sPN.StartsWith("PS") Then
oStepFileName = iProperties.Value("Project", "Part Number")
Else oStepFileName = iProperties.Value("Project", "Part Number")
End If
If System.IO.File.Exists(ThisDoc.Path & "\" & oStepFileName & ".stp") Then
oSTEPDetMess = MessageBox.Show("The STEP file with this name already exists in this folder location. Do you wish to overwrite the file?", _
"STEP file detected", MessageBoxButtons.YesNo, _
MessageBoxIcon.Hand, _
MessageBoxDefaultButton.Button1)
If oSTEPDetMess = vbYes
This is where I'm having trouble. How can I run this Yes answer into the Else below?
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.Path & "\" & oStepFileName & ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
And then how can I run this No answer to cancel this rule entirely so that the STEP file does not get overwritten?
If oSTEPDetMess = vbNo ???
Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!