Hello,
I am trying to write a ilogic code that will save a Inventor drawings as a autoCad dwg in a earlier file version. (using 2018 trying to save as 2004 drawing) also I need to add a sufix to the drawing # (660-120-123.dwg save as 660-120-123R0.dwg the R0 is the current rev) also can I add the description of the part to the file name (660-120-123R0 CONVEYOR)
as a kicker I need to save to a different location from my local working folder to a site on the network into a different file location everytime.
dwg 660-120-123 is in a different folder than 660-801-123 depending on the dwg # determines the file location.
I would also like a pdf of the drawing saved to another location...
Not sure how difficult this would be
Thanks
Steven
Hi
There are quite a few samples of code available to this.
What you need to do is create an ".ini" file which will have all the settings needed to export the drawing as a dwg file.
When you export your drawings you have the opportunity to save the configuration.
EG.
When that is done, you can reference the .ini file in the iLogic code.
In my example it has a strange name, but I never got around to renaming the file.
Anyway, see my code below, it saves to a different directory (data\"1 Export") and also attaches the revision number to the filename.
'Date: 26.09.2016 'Author: Reg Hasell ' Version 1.0 ' 'It will Do a very basic check to see if the file already exists, (I did not want to slow the process down too much 'It will then Create a DWG file in the export directory. 'The major benefit is that it will also add the current Revision to the filename. ' Future development will also update the filename with a prompted date. Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Dim DWGAddIn As TranslatorAddIn DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") Dim oDocument As Document oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMediumDWG As DataMedium oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium '--- oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oDocument = ThisApplication.ActiveDocument 'oDataMedium = ThisApplication.TransientObjects.CreateDataMedium Dim strIniFile As String strIniFile = "d:\data\2016-acadexport-[jun16]-2.ini" oOptions.Value("Export_Acad_IniFile") = strIniFile oFolder ="d:\data\1 EXPORT" oDataMediumDWG.FileName =oFolder + "\" + oFileName & "[" & oRevNum & "]" & ".dwg" If System.IO.File.Exists(oDataMediumDWG.FileName) Then oChoice=MessageBox.Show(oDataMediumDWG.FileName & " Already Exists - Overwrite?", "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If oChoice=7 'MessageBox.Show("exit", "Title") Return Else 'MessageBox.Show("Overwrite", "Title") End If End If '''--- Publish document. DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG) Beep MessageBox.Show("Done!", "Title")
edit:
I added this screen as well, just in-case.
I used the following code to get some of the results im looking for:
SyntaxEditor Code Snippet
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) strFolder = "G:\engineer\drawings\test\" & ThisDoc.FileName(False) & "R" & iProperties.Value(modelName, "Project", "Revision Number") & " " & iProperties.Value(modelName, "Project", "description") 'without extension ThisDoc.Document.SaveAs(strFolder & (".pdf"), True) ThisDoc.Document.SaveAs(strFolder & (".dwg"), True)
and a friend sent me this code for using a dialog box to select a folder location:
SyntaxEditor Code Snippet
'Dim oFolderBrowser As New System.Windows.Forms.FolderBrowserDialog ''default location 'oFolderBrowser.SelectedPath = "G:\engineer\drawings" 'Dim oDiaResult As DialogResult = oFolderBrowser.ShowDialog() 'If oDiaResult = DialogResult.OK Then ' 'selected location ' Dim oSelectedPath As String = oFolderBrowser.SelectedPath ' messagebox.Show(oSelectedPath) 'Else ' messagebox.Show("Cancelled") 'End If
But i cant figure out how to take the results of the dialog box and insert it into my original code as the location
Can't find what you're looking for? Ask the community or share your knowledge.