- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
iLogic Parts List & Opening Drawings
We have created parts lists with all the sorting that we want. Now we would like to go through each line of the parts list an open each individual part print through iLogic. We know how to do everything but get the drawings to open. We can retrieve information from the part iProperties, but we can't retrieve part path (either through iProperties or by other means).
We are using oPartList.PartsListRows.Count to run a loop through our sorted parts list. Any help would be greatly appreciated. Again we are reading the part numbers from the parts list and want to open the associated part drawings.
Thanks,
Allen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi allen.knapp,
I think this can be done but not directly through the the parts list. Can you post the iLogic code you have so far?
Basically, you should be able to itereate through the assembly and use the FullFileName propety to get the path of each occurence, and then match it to the part number in the parts list and write it to that row.
You might give a description of the "big picture" goal as well, as currently the idea of adding the file path to the parts list seems like a unique request, and there might simply be another altenative approach.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So the big picture is that we want to take a sorted parts list and make PDF of every drawing in order as they appear on the parts list (for manufacturing purposes). I actually was able to get this accomplished this morning with more research and looking in the Community Resources and Programming Help. This is the method that I found worked for what we need to do... It does assume that a parts list is in the drawing and that each part print is in the same location as the part model. Both of which work fine for us. I have some programming background, but am by no means a programmer. There might be other ways to get the task accomplished, but this is working for us now.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oDrawingView As DrawingView Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oPartList As PartsList oPartList = oSheet.PartsLists(1) oDrgPrintMgr = oDrawDoc.PrintManager oDrgPrintMgr.Printer = "PDFCreator" oDrgPrintMgr.PrintRange = kPrintAllSheets oDrgPrintMgr.AllColorsAsBlack = False oDrgPrintMgr.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel oDrgPrintMgr.ColorMode = kPrintDefaultColorMode oDrgPrintMgr.PaperSize = SizeActiveSheet oDrgPrintMgr.SubmitPrint Dim drawBomRow As DrawingBOMRow Dim refDoc As Document For Each oPartListRow In oPartList.PartsListRows If oPartListRow.Visible = "True" And oPartListRow.Custom = "False" Then Try drawBomRow = oPartListRow.ReferencedRows.Item(1) refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document FilePath = refDoc.FullFileName() FilePath = Left(FilePath,Len(FilePath)-3) & "idw" ThisApplication.Documents.Open(FilePath,True) Dim oDrawDoc2 As DrawingDocument = ThisApplication.ActiveDocument oDrgPrintMgr2 = oDrawDoc2.PrintManager oDrgPrintMgr2.Printer = "PDFCreator" oDrgPrintMgr2.PrintRange = kPrintAllSheets oDrgPrintMgr2.AllColorsAsBlack = False oDrgPrintMgr2.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel oDrgPrintMgr2.ColorMode = kPrintDefaultColorMode oDrgPrintMgr2.PaperSize = SizeActiveSheet oDrgPrintMgr2.SubmitPrint ThisApplication.ActiveDocument.Close(True) Catch drawBomRow = oPartListRow.ReferencedRows.Item(1) refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document FilePath = refDoc.FullFileName() FilePath = Left(FilePath,Len(FilePath)-3) & "idw" MessageBox.Show(FilePath, "File Not Found") End Try End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I thought I would expand a little further in case someone in the future comes across this and wants to do something similar. Some of our drawings are on different size sheets (Letter, 11x17, ANSI D) so i'm reading the sheet size from each drawing file and converting that according to the PaperSize Enumerator from the programming help. The code isn't perfect - if anything in the "Try" section fails, it will say "File Not Found" even if it actually did find the file. But this is a very good start to what we need to accomplish.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oDrawingView As DrawingView Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oPartList As PartsList oPartList = oSheet.PartsLists(1) oDrgPrintMgr = oDrawDoc.PrintManager oDrgPrintMgr.Printer = "PDFCreator" oDrgPrintMgr.PrintRange = kPrintAllSheets oDrgPrintMgr.AllColorsAsBlack = False oDrgPrintMgr.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel oDrgPrintMgr.ColorMode = kPrintDefaultColorMode oDrgPrintMgr.PaperSize = SizeActiveSheet oDrgPrintMgr.SubmitPrint Dim drawBomRow As DrawingBOMRow Dim refDoc As Document For Each oPartListRow In oPartList.PartsListRows If oPartListRow.Visible = "True" And oPartListRow.Custom = "False" Then Try drawBomRow = oPartListRow.ReferencedRows.Item(1) refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document FilePath = refDoc.FullFileName() FilePath = Left(FilePath,Len(FilePath)-3) & "idw" ThisApplication.Documents.Open(FilePath,True) Dim oDrawDoc2 As DrawingDocument = ThisApplication.ActiveDocument 'use PaperSizeEnum from inventor programming help PageSize = oDrawDoc2.ActiveSheet.Size If PageSize = 9990 Then PageSize = 14347 End If If PageSize = 9987 Then PageSize = 14353 End If If PageSize = 9988 Then PageSize = 14338 End If oDrgPrintMgr2 = oDrawDoc2.PrintManager oDrgPrintMgr2.Printer = "PDFCreator" oDrgPrintMgr2.PrintRange = kPrintAllSheets oDrgPrintMgr2.AllColorsAsBlack = False oDrgPrintMgr2.ScaleMode = kPrintBestFitScale 'oDrgPrintMgr.ScaleMode = kPrintModel oDrgPrintMgr2.ColorMode = kPrintDefaultColorMode oDrgPrintMgr2.PaperSize = PageSize oDrgPrintMgr2.SubmitPrint ThisApplication.ActiveDocument.Close(True) Catch drawBomRow = oPartListRow.ReferencedRows.Item(1) refDoc = drawBomRow.BOMRow.ComponentDefinitions.Item(1).Document FilePath = refDoc.FullFileName() FilePath = Left(FilePath,Len(FilePath)-3) & "idw" MessageBox.Show(FilePath, "File Not Found") End Try End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If you're just trying to save a pdf file honoring the papersizes and the PDFCreator printer isn't adding anything special to the pdfs you can use the builtin pdf exporter in Inventor.
Here's code to export a drawing document as a pdf excluding non printing sheets.
ThisDoc.Document can be replaced by oDrawDoc2 in your code.
SyntaxEditor Code Snippet
Dim ctx As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext() ctx.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim nvp As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim dm As DataMedium = ThisApplication.TransientObjects.CreateDataMedium() Dim _pdfAddin As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") If _pdfAddin.HasSaveCopyAsOptions(dwgDoc, ctx, nvp) Then nvp.Value("Launch_Viewer") = 0 nvp.Value("All_Color_AS_Black") = 1 nvp.Value("Remove_Line_Weights") = 0 nvp.Value("Vector_Resolution") = 600 nvp.Value("Publish_3D_Models") = 0 nvp.Value("Override_Sheet_Color") = 1 nvp.Value("Sheet_Color") = &HFFFFFF nvp.Value("Publish_All_Sheets") = 0 nvp.Value("Publish_Mode") = DWFPublishModeEnum.kCustomDWFPublish nvp.Value("Sheet_Range") = PrintRangeEnum.kPrintSheetRange Dim sheets As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim sheetInfo As NameValueMap = Nothing Dim cSheet As Integer = 1 For Each sheet As Sheet In ThisDoc.Document.Sheets 'Include If Not excluded Or include no Print Is checked. If Not sheet.ExcludeFromPrinting sheetInfo = ThisApplication.TransientObjects.CreateNameValueMap() sheetInfo.Value("Name") = sheet.Name cSheet = cSheet + 1 sheets.Value("Sheet" & cSheet) = sheetInfo End If Next nvp.Value("Sheets") = sheets End If Dim fileName = ThisDoc.Document.FullFileName dm.FileName = String.Format("{0}\\{1}.pdf", System.IO.Path.GetDirectoryName(fileName), System.IO.Path.GetFileNameWithoutExtension(fileName)) _pdfAddin.SaveCopyAs(ThisDoc.Document, ctx, nvp, dm)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
yes I have used the PDF add in with the SaveCopyAs command... however, printing all sheets to our printer called PDFCreator allows us to merge all of the individual sheets into a single document.
The PDFCreator waits while the iLogic code opens and prints every part drawing. When the code is finished, it leaves open a PDF Creator window showing all the documents. We can select merge to make the separate documents into one document with multiple pages. It works well for our needs.