With the help of the page http://inventortrenches.blogspot.com.es/, I have the following code that prints pdf a rule, the problem I have is that some of the computers where the rule throws the whole process runs but the end product has not pdf.
Imports System.IO Sub Main () Dim jpg_filename As String Dim html_filename As String Dim i As Integer Dim oAsmDoc As AssemblyDocument Dim ofolder As String Dim oDrawDoc As DrawingDocument Dim CadenaLibreria As String Dim oPath As String Dim RUser As String Dim oRefDocs As DocumentsEnumerator Dim oRefDoc As Document html_filename = ThisDoc.PathAndFileName(False) & ".html" 'Define el documento actual como ensamblaje oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'Chequea si el documento activo es un ensamblaje If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'Entrada de usuario para proceder RUser = MessageBox.Show ( _ "Se van a crear ficheros PDF de todos los ensamblajes." _ & vbLf & " " _ & vbLf & "Este proceso llevara algun tiempo.", "Salida Pdf",MessageBoxButtons.YesNo) If RUser = vbNo Then Return Else End If 'Funciones de prerparación de informe VisibilidadPlanos VistaModeloFront CreaFicheroInforme(html_filename) CabeceraInforme(html_filename) CuerpoInforme(html_filename,"kit con incidencias:") ' 'Start PDF setup ' oPath = ThisDoc.Path PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets End If 'get PDF target folder path oFolder = oPath & "\" & "PDF Kits" 'Chequea la carpeta Pdf y si no existe la crea If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If ' 'Start Component Drawings ' 'look at the files referenced by the assembly oRefDocs = oAsmDoc.AllReferencedDocuments 'work the the drawing files for the referenced models 'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs LongitudRefDoc = Len (Left(orefDoc.FullDocumentName, Len (orefDoc.FullDocumentName)-3) ) ExtenRefDoc = Right(orefDoc.FullDocumentName, Len (orefDoc.FullDocumentName)-LongitudRefDoc) If ExtenRefDoc = "iam" Then idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" iamPathname = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "iam" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) 'oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -3) oFileName = Left(oDrawDoc.DisplayName, Len(oDrawDoc.DisplayName) -3) 'MessageBox.Show(odrawdoc.displayname, "Title") On Error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) 'close the file oDrawDoc.Close Else Cadenalibreria = "C.\LIBRERIA" Dim eval as Boolean = Not idwPathname.toUpper.contains("\AIP\") If Not idwPathname.toUpper.contains (Cadenalibreria.toUpper) And eval Then jpg_filename = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "jpg" oIamDoc = ThisApplication.Documents.Open(iamPathName, True) VisibilidadPlanos() VistaModeloIso SalvarBitmap(jpg_filename, 1680, 1650) oIamDoc.Close idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "iam" Dim Linea As String = idwPathName DatosInforme(html_filename, jpg_filename, Linea) End If End If Else End If Next FinalInforme(html_filename) MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new ffiles are saved 'Shell("explorer.exe " & oFolder,vbNormalFocus) VisualizarInforme(html_filename) End Sub
Hi,
It looks the iLogic code missed some other functions. Could you make sure to provide a runable code?
In addition, it will very hard for Autodesk employees or outside peers to jump into such case if it is involved within a complex code logic. It is more helpful to isolate and post a simple code demo. e.g. in this case, are the missing functions related with this problem? Have you tried to commentined out them?
iLogic editor is not able to debug, so in general, a developer would use VB.NET to produce some codes, where the debugging is available. After it works, copy the code from VB.NET to iLogic and make a little modification. This is the most efficient way to write a complex code.