Is there a way to export dimensions and tolerances from a dwg to an excel spreadsheet? I am currently entering every single dimension by hand into our inspection reports. I've tried looking up commands to do this automatically and couldn't find anything that fits our needs. The dimensions need to include diameter symbols, degrees, plus/minus symbols, max/min, etc. Whatever it calls out on the drawing.
I've tried adding this rule in the iLogic:
iLogicVb.Automation.ParametersXmlSave(ThisDoc.Document, "path\filename.xml")
While this gives every parameter, it doesn't include tolerances or any other symbols.
I've also tried writing some simple code with the VBA editor, but I'm not a programmer and am also not very familiar with the VBA editor.
If there is a simple solution, or if you perhaps help me with the code, that would be very helpful.
Thanks.
Well seems like you need a customized solution, so I'm afraid you will have to write it yourself or find somebody willing to do it for you. The way to achieve this would be to use the Inventor API to iterate through the dimensions in your drawing and based on the properties they expose - everything you see in the UI might not be available in the API - export that to an Excel sheet using the Excel API.
You may want to take a look at the Inventor API Help Files to see what's available and how to do it. For example all the dimensions in your drawing sheet are available through Sheet.DrawingDimensions collection. Iterate that collection, cast based on the dimension type and retrieve the properties you need. You will find samples in the help.
For the Excel API, you will easily find plenty of examples over the web on how to work with it. Here is how you can create a workbook from Inventor VBA:
Sub CreateExcelDoc() Dim AppXls As Excel.Application Dim wb As Excel.workbook Dim ws As Excel.WorkSheet Set AppXls = CreateObject("Excel.Application") Set wb = AppXls.Workbooks.Add Set ws = wb.Worksheets.item(1) 'Range is The Cell Address ws.Range("A1").value = "Cell A1" ws.Range("A2").value = "Cell A2" ws.Range("A3").value = "Cell A3" wb.SaveAs ("C:\Temp\TestCreate.xls") Call wb.Close End Sub
Regards,
Philippe.
Annnnnd here is an answer to a post that is a year and a half old!
The code below does not always export symbols.
I think Its based on the font or something, I do not fully understand. But this should be plenty to get you going.
you will have 3 columns Dimension value, Upper Tolerence, Lower Tolerence
Also remember to add a reference to excel in vba.
Option Explicit Sub Excel_Export() Dim oApp As Application Set oApp = ThisApplication Dim oDrwDoc As DrawingDocument Set oDrwDoc = oApp.ActiveDocument Dim excel_app As Excel.Application ' Create the Excel application. Set excel_app = CreateObject("Excel.Application") ' Uncomment this line to make Excel visible. excel_app.Visible = True 'Create new workbook Call excel_app.Workbooks.Add ' Get the collection of dimensions on the active sheet. Dim oDimensions As DrawingDimensions Set oDimensions = oDrwDoc.ActiveSheet.DrawingDimensions Dim oDrwDim As DrawingDimension With excel_app .Range("A1").Select .ActiveCell.Value = "Dimension Value" .Range("B1").Select .ActiveCell.Value = "Upper Tolerence (in.)" .Range("C1").Select .ActiveCell.Value = "Lower Tolerence (in.)" Dim i As Integer i = 1 For Each oDrwDim In oDimensions 'Write values to spreadsheet .Range("A" & i + 1).Select .Range("A" & i + 1).Font.Name = "AIGDT" .ActiveCell.Value = CStr(oDrwDim.Text.Text) .Range("B" & i + 1).Select .Range("B" & i + 1).Font.Name = "AIGDT" .ActiveCell.Value = CStr(oDrwDim.Tolerance.Upper * 0.393701) .Range("C" & i + 1).Select .Range("C" & i + 1).Font.Name = "AIGDT" .ActiveCell.Value = CStr(oDrwDim.Tolerance.Lower * 0.393701) i = i + 1 Next End With End Sub
Please accept as solution.