- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I have created a rule to automate output of dwg files for varying sizes of the same part. The rule seems to work well, pulling the correct values from the embedded excel spreadsheet but the part doesnt update and rebuild. I have an update command in their, but it doesnt seem to work.
Part file attached. Appreciate any help.
Code is below.
Public Sub Main() Dim strPartDoc As Inventor.PartDocument = ThisApplication.ActiveDocument Dim strPath = ThisDoc.Path i = 1 ' the data starts in row 2 not row one, hence the counter start of 1 Do i = i + 1 If String.IsNullOrEmpty (GoExcel.CellValue("3rd Party:Embedding 1", "Sheet1","A" & i)) Then MessageBox.Show(i-2 & " Row(s) were read. Row " & i & " was blank", "Rule Completion") Return End If Length = GoExcel.CellValue("3rd Party:Embedding 1", "Sheet1","A" & i) Width = GoExcel.CellValue("3rd Party:Embedding 1", "Sheet1","B" & i) Height = GoExcel.CellValue("3rd Party:Embedding 1", "Sheet1","C" & i) iLogicVb.RunRule("Part Number & Description") ThisDoc.Document.Rebuild() InventorVb.DocumentUpdate() strConfigurationName = iProperties.Value("Project", "Description") strFileName = strPath & "\" & strConfigurationName & ".dwg" Q = MessageBox.Show("Parameters:" + vbCrLf + "Length = " & Length & "" + vbCrLf + "Width = " & Width & "" + vbCrLf + "Height = " & Height & "" + vbCrLf + "Filename: " & strFileName, "Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) If Q = vbNo Then MessageBox.Show("The rule will cancel", "Error Handling") Return End If ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") ' Get the active document. Can be either a part or assembly. Dim doc As Document doc = ThisApplication.ActiveDocument Dim transObjs As TransientObjects transObjs = ThisApplication.TransientObjects ' Set up the context to define an output file. Dim context As TranslationContext context = transObjs.CreateTranslationContext context.Type = kFileBrowseIOMechanism ' Get the available options from the translator. Dim options As NameValueMap options = transObjs.CreateNameValueMap If DWGAddIn.HasSaveCopyAsOptions(doc, context, options) Then ' Set the options for what types of data to write out. options.Value("Solid") = True ' Output solids. options.Value("Surface") = False ' Output surfaces. options.Value("Sketch") = False ' Output sketches. ' Set the DWG version. ' 23 = ACAD 2000 ' 25 = ACAD 2004 ' 27 = ACAD 2007 ' 29 = ACAD 2010 options.Value("DwgVersion") = 29 End If ' Set the output filename, using a DataMedium object. Dim oDataMedium As DataMedium oDataMedium = transObjs.CreateDataMedium oDataMedium.FileName = strFileName ' Call the SaveCopyAs method of the translator add-in. Call DWGAddIn.SaveCopyAs(doc, context, options, oDataMedium) Loop End Sub
Solved! Go to Solution.