Message 1 sur 3
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Lien permanent
- Imprimer
- Signaler
Bonjour,
je trouvé sur forum une code pour imprimer tous les dessin relier au assamblage.
je le addapte a mes besoin et tout marche bien.
un seul bemol est que a cause que les fichier sont enregistré dans vault, chaque fois a ouverture d'une dessin une message de Extraction est apparu. Celui la empeched'executer en mode automatique la regle.
je ne veux pas les extraire.
Avez vous une solution pour ignorer le message de Vault ou message de mettre a jour je fichier aussi.
Merci.
Voici le code:
' This is print all the associated idws of an assembly to PDF. 'This Is similar To the "Print all Ref idw" macro functionality, but' it is now converted into a iLogic rule. 'This assumes that the idw Is teh same File name As the part Or the assembly. 'There are a few changes to the orginal Macro: ' 1. Now have an option to print in color or B/W. ' 2. The ilogic code also prints the top level assembly. ' ----------------------------------------------------------------Kirk Arthur 8/30/2016 Sub Main () 'check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic"): Exit Sub: End If 'Common to all drawings Dim oWSPath As String = ThisDoc.Path' ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath Dim oDrawingsFolder As String = Left(oWSPath, InStrRev(oWSPath, "\")) & "Dessins" pdffilePath = Left(oWSPath, InStrRev(oWSPath, "\")) & "PDF" Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oDrgPrintMgr As DrawingPrintManager 'get user input RUsure = MessageBox.Show ( _ "This will create a PDF file for all of the assembly components that have" _ & vbLf & "drawings files. This rule expects that the drawing file shares the same" _ & vbLf & " name and location as the component." _ & vbLf & "", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo) If RUsure = vbNo Then:Return:Else:End If '- - - - - - - - - - - - -PDF setup - - - - - - - - - - - - 'Dim oPrintMgr As PrintManager = ThisApplication.ActiveDocument.PrintManager 'If MsgBox("Using Printer " & oPrintMgr.Printer & ", Best Fit, 11x17 paper, Landscape Mode." _ '& vbLf & " " _ '& vbLf & " Do you want to continue?" _ ', vbYesNo + vbQuestion, "System Printer Settings ") = vbNo Then: Exit Sub: End If ' ----Determine if the prints should be in color or B/W ------ oColorAsBlack="False" RUsure = MessageBox.Show ( "Do you want to print this in COLOR?"& vbLf & "", "Color or B/W Prints",MessageBoxButtons.YesNo) If RUsure = vbNo Then oColorAsBlack="True" : Else: End If Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments Dim numFiles As Integer = 0 '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -'look at the files referenced by the assembly For Each oRefDoc As Document In oRefDocs Dim oRefFileName As String = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName) Dim oRefDrawingFile As String = oDrawingsFolder & "\" & oRefFileName & ".idw" 'oRevNum = iProperties.Value("Project", "Revision Number") '[Gets drawing file name from assembly/part filename 'strips path DrawFileName = Right(oRefDrawingFile, Len(oRefDrawingFile) -InStrRev(oRefDrawingFile, "\")) 'strips extension DrawName = Left(DrawFileName, Len(DrawFileName) -4) 'adds drawing path and extension '] 'Vault(oRefDrawingFile) If (System.IO.File.Exists(oRefDrawingFile)) Then numFiles = numFiles + 1 Dim oDrawDoc As DrawingDocument = ThisApplication.Documents.Open(oRefDrawingFile, True) oDrawDoc.Activate RevNum = oDrawDoc.PropertySets.Item(1).Item("Revision Number").Value PrintBG(DrawName,oDrawDoc, pdffilePath, RevNum) oDrawDoc.Close (True) End If Next ' MsgBox ("There are " & numFiles & " sent to printer.") '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - Dim oAssyFileName As String = System.IO.Path.GetFileNameWithoutExtension(oAsmDoc.FullFileName) Dim oAssyDrawingFile As String = oDrawingsFolder & "\" & oAssyFileName & ".idw" 'Vault(oAssyDrawingFile) If (System.IO.File.Exists(oAssyDrawingFile)) Then Dim oAsmDrawDoc As DrawingDocument = ThisApplication.Documents.Open(oAssyDrawingFile, True) oAsmDrawDoc.Activate RevNum = oAsmDrawDoc.PropertySets.Item(1).Item("Revision Number").Value DocName = ThisDoc.FileName(False) 'without extension PrintBG(DocName,oAsmDrawDoc,pdffilePath, RevNum) oAsmDrawDoc.Close (True) numFiles = numFiles + 1 Else MessageBox.Show (" No IDW of the Top level file found!" _ & vbLf & " " _ & vbLf & "There were " & numFiles & " files sent to the printer.", " Job Complete ") Return End If MessageBox.Show ("There were " & numFiles & " files sent to the printer."," Job Complete ") 'MessageBox.Show("New Files Created in: " & vbLf & idwpathname, "iLogic")'open the folder where the new ffiles are saved'Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Private Sub Vault(oOtherDocPath) 'Dowload From Vault Dim oRuleArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() oRuleArguments.Add("oFilePath",oOtherDocPath) iLogicVb.RunExternalRule("Get From Vault Function", oRuleArguments) 'this returns True/False depending on whether download was successful or not. Dim oFileDownloadedSuccessfully As String = oRuleArguments.Item("Success") 'MessageBox.Show(oFileDownloadedSuccessfully,oFilePath) 'use this line before checking For other files oRuleArguments.Clear End Sub Sub Child(oAssyDoc As AssemblyDocument, ParentItemNumber As String, DrawingPath As String) Dim oBOM As BOM = oAssyDoc.ComponentDefinition.BOM Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured") Dim oBOMRow As BOMRow 'Prints Fabrication Drawings and additional assembly drawings that exist in the BOM. 'Checks each item in BOM with greater than 0 qty for drawing with matching filename in the given directory, opens, prints, and closes. For Each oBOMRow In oBOMView.BOMRows If oBOMRow.ItemQuantity > 0 Then '[Gets drawing file name from assembly/part filename FullFileName = oBOMRow.ComponentOccurrences.Item(1).Definition.Document.FullFileName 'strips path FileName = Right(FullFileName, Len(FullFileName) -InStrRev(FullFileName, "\")) 'strips extension Name = Left(FileName, Len(FileName) -4) 'adds drawing path and extension DrawingFileName = DrawingPath & Name & ".idw" '] 'If a drawing with the same filename from the BOM is found, it is opened and printed 'Determines if drawing is an assembly drawing that may have children drawings Try oDrawDoc = ThisApplication.Documents.Open(DrawingFileName, True) ItemNumber = ParentItemNumber & "." & oBOMRow.ItemNumber ' PrintBG(oDrawDoc, ItemNumber) If InStr(oDrawDoc.PropertySets.Item("Inventor User Defined Properties").Item("Drawing Type").Value, "Assembly") > 0 Then MsgBox("Running child from child" & vbNewLine & oBOMRow.ItemNumber) Child(oBOMRow.ComponentOccurrences.Item(1).Definition.Document, ParentItemNumber & "." & oBOMRow.ItemNumber, DrawingPath) End If oDrawDoc.Close(True) Catch 'If nothing is found, nothing is done End Try End If Next End Sub Sub PrintBG(oFileName,oDoc, oPath,RevNum) oDrgPrintMgr = oDoc.PrintManager oDrgPrintMgr.AllColorsAsBlack = oColorAsBlack oDrgPrintMgr.ScaleMode = kPrintBestFitScale oPrintMgr = ThisApplication.ActiveDocument.PrintManager ' Printer setup, default printer 'oPrintMgr.ColorMode = kPrintDefaultColorMode ' Set to default. Uses printer settings oPrintMgr.PrintRange = kPrintAllSheets 'Prints all sheets in the idw. oPrintMgr.NumberOfCopies = 1 ' Set to print one copies. oPrintMgr.Orientation = kLandscapeOrientation ' Set to print using landscape orientation. oPrintMgr.PaperSize = kPaperSizeTabloid 'Set the paper size. oPrintMgr.PrintToFile(oPath & "\" & oFileName & "-Rev." & RevNum & ".pdf") ' oPrintMgr.SubmitPrint ' Submit the print. ' oPrintMgr.PrintToFile(pdffilePath+"\"+DrawName+"-Rev."+oRefRevNum+".pdf") End Sub
Résolu ! Accéder à la solution.