
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all!
I'm having trouble writing an ilogic code that exports a part or sheet metal part to a given location. The ideal code should prompt the user if the name is correct with a message box 'Yes or No'. It should also prompt user if there is already a file with the given name, and if so, does the user choose to override it. The given name comes from a custom iproperty called 'Item Code'. Lastly, if the iproperty has the character ` in the Revision Number field, then it just names it 'Item Code value', if it has anything else written in 'Revision Number' field, then it prints 'Item code + Revision Number' as the name.
I tried writing it using code as a base, and had to many errors, couldn't figure it out:
'Dim title As String = "converted to title case" ' Console.WriteLine(StrConv(title, VbStrConv.ProperCase)) oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) DrawingName = iProperties.Value(oModelDoc, "Custom", "Item Code") DesiredPath = "C:\JACKRABBIT\INVENTOR TEMPLATES 2022\MISC\PDF" NewFileName = DesiredPath & "\" & DrawingName & ".pdf" 'check file name to see if it is used 'if it is, ask the user to overwrite 'if it's not, save the file question = MessageBox.Show("Is this a good file name?: " & DrawingName & ".pdf", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question) If question=vbYes Then If System.IO.File.Exists(NewFileName) Then question = MessageBox.Show("File exists, do you want to overwrite?", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question) If question = vbYes Then System.IO.File.Delete(NewFileName) ThisDoc.Document.SaveAs(NewFileName, True) Else If question =vbNo Then MessageBox.Show("File was not overwritten", "iLogic Message") End If Else ThisDoc.Document.SaveAs(NewFileName, True) End If Else If question=vbNo Then MessageBox.Show("Please fix Part Number") End If
Solved! Go to Solution.