Ilogic change active drawing

Ilogic change active drawing

aconwayAXDXE
Participant Participant
289 Views
2 Replies
Message 1 of 3

Ilogic change active drawing

aconwayAXDXE
Participant
Participant
i have the following ilopgic code to pull all open drawings and pdf them with the respective rev number after it. The problem is it only put in the rev of the current drawing. say i have 10 drawings all at different revisions. it will label them all the same as the document i run it from. i need it to change which drawing it is looking at and pull the revision from that drawing not the original drawing i ran it from

Sub
Main () '-----Inital User Input ----- '-----User defined Scope----- Dim UserChoice = InputRadioBox("What files do you want to export", "Only This Open Document", "All Open Documents", True, Title := "Defined the scope") '-----User question setup ----- Dim UserSelectedActionList = New String(){"PDF & DWG", "PDF Only", "DWG Only"} '-----User question input ----- Dim UserSelectedAction As String = InputListBox("What Format is Required ?", UserSelectedActionList, UserSelectedActionList(0), Title := "File Type to Export", ListName := "File Format Type") If UserChoice = True Then 'UserChoice will be True is first option is selected oDoc = ThisApplication.ActiveEditDocument Call ExportFile(oDoc, UserSelectedAction) '----- Single File Success Message----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" File successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" File successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" File successfully exported to DWG. ", "Export Complete") End Select Else For Each openDocument As Document In ThisApplication.Documents.VisibleDocuments If openDocument.DocumentType = kDrawingDocumentObject Then Try If Len(openDocument.File.FullFileName) >0 Then Call ExportFile(openDocument, UserSelectedAction) End If Catch End Try End If Next '----- Multi File Success Message ----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" All files successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" All files successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" All files successfully exported to DWG. ", "Export Complete") End Select End If End Sub Sub ExportFile(ByRef oDocument As Document, UserSelectedOption As String) '-----Check path----- oPath = ThisDoc.Path '-----Get Target folder paths----- oPDFFolder = oPath & "\#Auto PDFs\" oDWGFolder = oPath & "\#Auto DWGs\" '-----Check for the folder paths and create it if they do not exist----- If Not System.IO.Directory.Exists(oPDFFolder) Then System.IO.Directory.CreateDirectory(oPDFFolder) End If If Not System.IO.Directory.Exists(oDWGFolder) Then System.IO.Directory.CreateDirectory(oDWGFolder) End If '----- Fill Variables ----- oFullFileName = oDocument.File.FullFileName oPath = Left(oFullFileName, InStrRev(oFullFileName, "\") -1) oFileName = Right(oFullFileName, Len(oFullFileName) -InStrRev(oFullFileName, "\")) oFilePart = Left(oFileName, InStrRev(oFileName, ".") -1) '-----Load PDF Add In----- oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") 'oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium '-----PDF options ----- If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets End If '----- Sets the appened Revision Number text----- If iProperties.Value(oDoc,"Custom", "09 REVISION") = "" Then 'oRevString = "_(REV MISSING)" ElseIf iProperties.Value(oDoc,"Custom", "09 REVISION") = "AB" Then oRevString = "_" & iProperties.Value(oDoc,"Custom", "09 REVISION") & " (AS BUILT)" Else oRevString = "_rev" & iProperties.Value(oDoc,"Custom", "09 REVISION") & "" End If '-----Set the PDF target file name----- oDataMedium.FileName = oPDFFolder & "\" & oFilePart & oRevString & ".pdf" '-----Export User Selection----- Select Case UserSelectedOption Case "PDF & DWG" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) Case "PDF Only" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Case "DWG Only" 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) End Select End Sub
0 Likes
Accepted solutions (1)
290 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

The ilogic iproperty snippet are probably causing the issue. They can be difficult to target in the drawing. You also have not set the object oDoc in the exportfile sub routine, oDocument is the document object.

 

Replace 

iProperties.Value(oDoc,"Custom", "09 REVISION")

With the Inventor API equivalent

oDocument.PropertySets.Item("Inventor User Defined Properties").Item("09 REVISION").Value

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

aconwayAXDXE
Participant
Participant

Thank you so much for the help. this is going to save so much time now exporting over 20 drawings to PDF and DWG at once.

In case anyone wants the final code so that you can modify it for yourselves to suit your custom properties etc...