- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All
I am currently updating a lot of old drawings and updating our standard template.
I have done a ilogic to create a pdf and dxf file on close set as extrernal
oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'query user question = MessageBox.Show("Create PDF?", "Create PDF?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) 'set condition based on answer If question = vbYes Then '------start of iLogic------- If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 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 = oPath & "\" & "PDFDXF" '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 & "\" & oFileName & _ " rev" & oRevNum & ".pdf" MessageBox.Show("PDF SAVED TO: " & oDataMedium.FileName, "PDF Saved", MessageBoxButtons.OK) 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '------end of iLogic------- Else If question = vbNo Then End If 'query user question = MessageBox.Show("Create DXF?", "Create DXF?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) 'set condition based on answer If question = vbYes Then 'get DXF target folder path oFolder = oPath & "\" & "PDFDXF" 'Check for the DXF 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 DXF target file name oDataMedium.FileName = oFolder & "\" & oFileName & _ " rev" & oRevNum & ".dxf" MessageBox.Show("DXF SAVED TO: " & oDataMedium.FileName, "DXF Saved", MessageBoxButtons.OK) 'Publish document oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '------end of iLogic------- Else If question = vbNo Then End If
I have also got a ilogic to update an old drawing title block and styles to what is in the template. The issue is when I run it it then wants to run the dxf and pdf ilogic aswell?
Option Explicit Sub Main Dim oTargetDoc, oSourceDoc As DrawingDocument Dim oTBdef As TitleBlockDefinition Dim oTBdefs As TitleBlockDefinitions Dim oBorderDef As BorderDefinition Dim oBorderDefs As BorderDefinitions Dim oSymbol As SketchedSymbolDefinition Dim oSymbols As SketchedSymbolDefinitions Dim oPrompt As String If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then MsgBox("This rule may only be run on drawing documents!",vbOKOnly,"Update Titleblocks") Exit Sub End If oTargetDoc = ThisDrawing.Document oPrompt = MsgBox("Update Titleblocks and Styles?",vbYesNo,"Update Titleblocks") Select Case oPrompt Case vbNo Exit Sub Case vbYes oSourceDoc = ThisApplication.Documents.Open("C:\_Vault\Inventor Templates\Standard.idw", False) oTargetDoc.StylesManager.ActiveStandardStyle.UpdateFromGlobal End Select oTBdefs = oSourceDoc.TitleBlockDefinitions oBorderDefs = oSourceDoc.BorderDefinitions oSymbols = oSourceDoc.SketchedSymbolDefinitions For Each oTBdef In oTBdefs Try If oTBdef.Name <> "ANSI - Large" Then oTBdef.CopyTo(oTargetDoc, True) End If Catch MsgBox("Unknown error in copy title block for " & Chr(34) & oTBdef.Name & Chr(34),vbOKOnly,"Error") End Try Next For Each oBorderDef In oBorderDefs Try If oBorderDef.Name <> "Default Border" Then oBorderDef.CopyTo(oTargetDoc, True) End If Catch MsgBox("Unknown error in copy border definition for " & Chr(34) & oBorderDef.Name & Chr(34),vbOKOnly,"Error") End Try Next For Each oSymbol In oSymbols Try oSymbol.CopyTo(oTargetDoc, True) Catch MsgBox("Unknown error in copy sketched symbol for " & Chr(34) & oSymbol.Name & Chr(34),vbOKOnly,"Error") End Try Next oSourceDoc.Close() End Sub
Is it possible to get it not to do this?
In the update title block ilogic can I get it to also add the create pdf and dxf to a trigger automatically?
The last thing I would like to do is set the drawing Iproperties to match the model iproperties.
Currently I have to manually go Tools -> Document settings -> Drawings -> Copy Model iProperty settings and tick copy all.
Can this be done automatically?
And update on open of drawing and save eg
I have this code
Dim oControlDef as ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateCopiedModeliPropertiesCmd") oControlDef.Execute2(True)
Sorry for the long winded msg
Thanks,
Matt
Solved! Go to Solution.