- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I'm having an issue with "my" code, which doesn't allow me to change the prompts in multiple title blocks.
What happens now:
I've a 2D drawing with title block already filled with information, all this information is prompted entry. And lots of idw follow the same structure.
Then if i want to reuse these drawings for another project which has different numbering (in this case "Nrº Obra" and "Codificação EQ"), i have to open one by one, change it and print it to PDF file.
What i would like to happen (if possible):
I would like to open multiple idw documents and run a rule which allows me to change the two prompt entries as i said above and it changes to all opened idw documents and print them.
I've found a code that allows me to print all the documents that i have open in inventor (link to original below)
https://magazine.thingimajigs.com/autodesk-inventor-batch-exporting-pdfs-dxfs-with-ilogic/
And now i've added one sub "Substitui_Legenda" (got if from somewhere also) to go and replace the prompts entry on the title block. But it only works on the idw that i've currently open, and doesnt replace on the others (i've tried on documents with the same title block to see if it was a title block issue)
If someone can help me with this or tell me if it is possible as i don't really have much experience with ilogic. See the code below.
During selection it says excel but it isnt currently running.
And sorry for the half english and half portuguese typing on the code
Sub Main Dim myDate As String = Now().ToString("dd-MM-yyyy") myDate = myDate.Replace(":","") ' & " - " & TypeString userChoice = InputRadioBox("Defined the scope", "This Document", "All Open Documents", True, Title := "Defined the scope") UserSelectedActionList = New String(){"DWG & PDF & Excel", "PDF Only", "PDF & Excel"} UserSelectedAction = InputListBox("What action must be performed with selected views?", _ UserSelectedActionList, UserSelectedActionList(0), Title := "Action to Perform", ListName := "Options") Select UserSelectedAction Case "DWG & PDF & Excel": UserSelectedAction = 3 Case "PDF Only": UserSelectedAction = 1 Case "PDF & Excel": UserSelectedAction = 2 End Select ' Insere novos dados na legenda SharedVariable("pNrº Obra") = InputBox("Escolher Numero de Obra", "Numbero de Obra") SharedVariable("pCodificação_EQ") = InputBox("Escolher Codificação", "Codificação") Call Substitui_Legenda If userChoice Then Call MakePDFFromDoc(ThisApplication.ActiveDocument, myDate, UserSelectedAction) Else For Each oDoc In ThisApplication.Documents If oDoc.DocumentType = kDrawingDocumentObject Try If Len(oDoc.File.FullFileName) >0 Then Call MakePDFFromDoc(oDoc, myDate, UserSelectedAction) End If Catch End Try End If Next End If End Sub Sub MakePDFFromDoc(ByRef oDocument As Document, DateString As String, UserSelectedAction As Integer) ' oPath = oDocument.Path ' oFileName = oDocument.FileName(False) 'without extension 'oDocument = ThisApplication.ActiveDocument oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium oFullFileName = oDocument.File.FullFileName oPath = Left(oFullFileName, InStrRev(oFullFileName, "\")-1) oFileName = Right(oFullFileName, Len(oFullFileName)-InStrRev(oFullFileName, "\")) oFilePart = Left(oFileName, InStrRev(oFileName, ".")-1) 'oRevNum = oDocument.iProperties.Value("Project", "Revision Number") 'oDocument = ThisApplication.ActiveDocument ' If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 ' End If 'get PDF target folder path 'oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" ' oFolder = oPath & "\Dokumentace(" & DateString & ")" oFolder = oPath & "\" & oFilePart oDirectoryName = System.IO.Path.GetDirectoryName(oFullFileName) 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFilePart & ".pdf" 'Publish document If (UserSelectedAction = 1) Then oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)'For PDF's oDocument.SaveAs(oFolder & "\" & oFilePart & ".dwg", True) 'For DWG's End If If (UserSelectedAction = 2) Then oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)'For PDF's End If If (UserSelectedAction = 3) Then oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)'For PDF's End If 'oDocument.SaveAs(oFolder & "\" & ThisDoc.ChangeExtension(".DWG"), True) 'For DWG's '------end of iLogic------- End Sub ' Modifica a legenda com base na informações fornecidas Sub Substitui_Legenda 'Read Title Block from Active Sheet Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oTB1 As TitleBlock oTB1 = oSheet.TitleBlock Dim titleDef As TitleBlockDefinition titleDef = oTB1.Definition Dim oPrompt1 As Inventor.TextBox Dim oPrompt2 As Inventor.TextBox Dim oPrompt3 As Inventor.TextBox Dim oPrompt4 As Inventor.TextBox Dim oPrompt5 As Inventor.TextBox Dim oPrompt6 As Inventor.TextBox Dim oPrompt7 As Inventor.TextBox Dim oPrompt8 As Inventor.TextBox 'make sure you declare all your prompts ' Find the Prompted Entry in the Title Block For Each defText As Inventor.TextBox In titleDef.Sketch.TextBoxes On Error Resume Next If defText.Text = "Obra / Desginacao Projecto" Then oPrompt1 = defText ElseIf defText.Text = "Nrº Obra" Then oPrompt2 = defText ElseIf defText.Text = "Codificação EQ" Then oPrompt3 = defText ElseIf defText.Text = "Nrº Série" Then oPrompt4 = defText ElseIf defText.Text = "Titulo" Then oPrompt5 = defText ElseIf defText.Text = "Area" Then oPrompt6 = defText ElseIf defText.Text = "Categoria" Then oPrompt7 = defText ElseIf defText.Text = "Numero" Then oPrompt8 = defText End If Next oTB1.SetPromptResultText(oPrompt2, SharedVariable("pNrº Obra")) oTB1.SetPromptResultText(oPrompt3, SharedVariable("pCodificação_EQ")) SharedVariable.Remove("pNrº Obra") SharedVariable.Remove("pCodificação_EQ") End Sub
Thanks in advance
Solved! Go to Solution.