- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys,
I'm trying to improve our workflow a bit and I had a couple of Ideas
1 - I want to let the user pick the project they are working on and let iLogic place the PDF's in subfolders in that project.
2 - based on the filename (X-YYPZZZZ-001.dwg) I want iLogic to find the correct folder (we have folders with numbers in them)
3 - no user interaction; just press the button and iLogic will find out - based on the filenumber - where the drawing should be saved to.
So! I'm currently working on no. 1
I'll paste the whole code below but what I'm struggeling with at the moment is the point after I chose where to save the file.
'Ask which project the User uses
oQuestion2 = InputListBox("Choose where", ProjectChoice, ProjectChoice, Title := "KIES PROJECT", ListName := "ProjectChooser")
the relevant piece of code is this:
'Choose Preselected Folder
Dim oChoice
Dim ProjectChoice As New ArrayList
ProjectChoice.Add("Project 1")
ProjectChoice.Add("Project 2")
oFolder = "G:\folder\"& ProjectChoice(oChoice) &"\folder\"
Dim Proc As String = "Explorer.exe"
Dim Args As String = ControlChars.Quote & IO.Path.Combine("G:\", oFolder) & ControlChars.Quote
no matter what I choose, it will always save on the (0) value in the arraylist.
Any advise?
Here is the complete code I've written.
Public Sub Main()
Dim oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oDuctName = iProperties.Value("Project", "Description")
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oDWGAddIn As TranslatorAddIn
oDWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
oDrafstman = ThisApplication.UserName
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium
oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium
'Choose Preselected Folder
Dim oChoice
Dim ProjectChoice As New ArrayList
ProjectChoice.Add("Project 1")
ProjectChoice.Add("Project 2")
oFolder = "G:\COMPANYNAME\orders\2016\Projecten\"& ProjectChoice(oChoice) &"\Tekeningen Engineering\2D Tekeningen\"
Dim Proc As String = "Explorer.exe"
Dim Args As String = ControlChars.Quote & IO.Path.Combine("G:\", oFolder) & ControlChars.Quote
'PDF Setup
If oPDFAddIn.HasSaveCopyAsOptions(oDataMediumPDF, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 500
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
' DWG SETUP - Check whether the translator has 'SaveCopyAs' options
If oDWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "G:\folder\INVENTOR\iLogic\Save as DWG aparte sheets.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'get target folder path
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'Set the destination file name
Dim fileName As String
fileName = ThisDoc.FileName(False) & " - " & oDuctName & " - REV " & iProperties.Value("Project", "Revision Number")
oDataMediumDWG.FileName = oFolder & fileName & ".dwg"
oDataMediumPDF.FileName = oFolder & fileName & ".pdf"
'Ask which project the User uses
oQuestion2 = InputListBox("KIES HET PROJECT WAAR DE PDF/DWG MOET WORDEN OPGESLAGEN", ProjectChoice, ProjectChoice, Title := "KIES PROJECT", ListName := "ProjectChooser")
'Ask the User if he wants PDF or PDF+DWG
oQuestion = MessageBox.Show("For PDF select YES for PDF+DWG select NO", "PDF or PDF/DWG", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
'Publish document.
If oQuestion = vbYes Then
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumPDF)
Else If oQuestion = vbNo Then
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumPDF)
oDWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG)
Else
'MessageBox.Show("Canceled", "We're doing nothing now...")
End If
If oQuestion = vbYes Or oQuestion = vbNo Then
OpenFolder= MessageBox.Show("Would you open the folder?", "PDF EXPORTED", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
'open the folder where the new files are saved
If OpenFolder = vbYes Then
Process.Start(Proc, Args)
Else
'Return
End If
Else
End If
End Sub
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________Solved! Go to Solution.