Export Drawing dimension to excel

Export Drawing dimension to excel

eladm
Collaborator Collaborator
4,009 Views
34 Replies
Message 1 of 35

Export Drawing dimension to excel

eladm
Collaborator
Collaborator

Hi

 

I need help with ilogic rule to export all drawing dimensions to Excel

Not VBA , some of the dimeson  have tolerance

regards

0 Likes
4,010 Views
34 Replies
Replies (34)
Message 21 of 35

eladm
Collaborator
Collaborator

Hi 

Can the code not will be :

1.png

The desire :

2.png

0 Likes
Message 22 of 35

bradeneuropeArthur
Mentor
Mentor

Sure hang on!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 23 of 35

bradeneuropeArthur
Mentor
Mentor
AddReference "Microsoft.Office.Interop.Excel.dll" Imports exe = Microsoft.Office.Interop.Excel 'Dim oXLFile As String = "C:\TEMP\DrawingDimensions.xlsx" Dim oSheet As String = "Sheet1" Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.add'.Open(oXLFile) Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet) Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells 'oCells.item(2,1).value= b.Text.Text.ToString Dim a As Inventor.DrawingDocument = ThisDrawing.Document Dim s As Inventor.Sheet = a.ActiveSheet Dim i As Integer = 1 For Each b As Inventor.DrawingDimension In s.DrawingDimensions 	i = i + 1 'MsgBox (b.Text.Text & " " & b.Tolerance.ToleranceType) 	 	If b.Tolerance.ToleranceType = 31236 Then 		oCells.item(i,1).value = b.Text.Text 		oCells.item(i,2).value = b.Tolerance.Upper*10 		oCells.item(i,3).value = b.Tolerance.Lower*10 	 		oCells.item(1,1).value = "Dimension" 		oCells.item(1,2).value = "Tolerance Upper" 		oCells.item(1,3).value = "Tolerance Lower" 		End If If b.Tolerance.ToleranceType = 31233 Then 		oCells.item(i,1).value = b.Text.Text 		oCells.item(i,2).value = b.Tolerance.Upper*10 		oCells.item(i,3).value = b.Tolerance.Lower*10 	 		oCells.item(1,1).value = "Dimension" 		oCells.item(1,2).value = "Tolerance Upper" 		oCells.item(1,3).value = "Tolerance Lower" 		End If If b.Tolerance.ToleranceType = 31235 Then 		oCells.item(i,1).value = b.Text.Text 		oCells.item(i,2).value = "" & b.Tolerance.Upper*10 		oCells.item(i,3).value = "" &b.Tolerance.Lower*10.ToString 	 		oCells.item(1,1).value = "Dimension" 		oCells.item(1,2).value = "Tolerance Upper" 		oCells.item(1,3).value = "Tolerance Lower" 		End If 	Next 	oWB.saveas("C:\TEMP\"& a.DisplayName & ".xlsx") oWB.close

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 24 of 35

eladm
Collaborator
Collaborator

sorry , the min value is zero

3.png

0 Likes
Message 25 of 35

bradeneuropeArthur
Mentor
Mentor
Accepted solution

We are Coming closer!

AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel

'Dim oXLFile As String = "C:\TEMP\DrawingDimensions.xlsx"
Dim oSheet As String = "Sheet1"

Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.add'.Open(oXLFile)
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet)

Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells

'oCells.item(2,1).value= b.Text.Text.ToString

Dim a As Inventor.DrawingDocument = ThisDrawing.Document
Dim s As Inventor.Sheet = a.ActiveSheet


Dim i As Integer = 1
For Each b As Inventor.DrawingDimension In s.DrawingDimensions
	i = i + 1
'MsgBox (b.Text.Text & " " & b.Tolerance.ToleranceType)
	
	If b.Tolerance.ToleranceType = 31236 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10
	
		oCells.item(1,1).value  = "Dimension"
		oCells.item(1,2).value = "Tolerance Upper"
		oCells.item(1,3).value = "Tolerance Lower"
		End If
If b.Tolerance.ToleranceType = 31233 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10
	
		oCells.item(1,1).value  = "Dimension"
		oCells.item(1,2).value = "Tolerance Upper"
		oCells.item(1,3).value = "Tolerance Lower"
		End If
If b.Tolerance.ToleranceType = 31235 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = "+" & b.Tolerance.Upper*10
		oCells.item(i,3).value  = "-" &b.Tolerance.Lower*10.ToString
	
		oCells.item(1,1).value  = "Dimension"
		oCells.item(1,2).value = "Tolerance Upper"
		oCells.item(1,3).value = "Tolerance Lower"
		End If


	Next
	oWB.saveas("C:\TEMP\"& a.DisplayName & ".xlsx")
oWB.close

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 26 of 35

eladm
Collaborator
Collaborator

same result

4.png

0 Likes
Message 27 of 35

_dscholtes_
Advocate
Advocate

@bradeneuropeArthur Why are you setting the column headers with each dimension?

Message 28 of 35

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Modified:

Heading

and the minus sign added.

AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel

'Dim oXLFile As String = "C:\TEMP\DrawingDimensions.xlsx"
Dim oSheet As String = "Sheet1"

Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.add'.Open(oXLFile)
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet)

Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells

'oCells.item(2,1).value= b.Text.Text.ToString

Dim a As Inventor.DrawingDocument = ThisDrawing.Document
Dim s As Inventor.Sheet = a.ActiveSheet


Dim i As Integer = 1
		oCells.item(1,1).value  = "Dimension"
		oCells.item(1,2).value = "Tolerance Upper"
		oCells.item(1,3).value = "Tolerance Lower"
For Each b As Inventor.DrawingDimension In s.DrawingDimensions
	i = i + 1
'MsgBox (b.Text.Text & " " & b.Tolerance.ToleranceType)
	
	If b.Tolerance.ToleranceType = 31236 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10
	

		End If
If b.Tolerance.ToleranceType = 31233 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10

		End If
If b.Tolerance.ToleranceType = 31235 Then
	Dim du As Double = "+" & (b.Tolerance.Upper * 10)
	Dim dl As Double = "-" & (b.Tolerance.Upper * 10)
	'MsgBox("+"&(b.Tolerance.Upper*10).ToString)
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = du '"="+"" &(b.Tolerance.Upper*10)'"p"'"+" & b.Tolerance.Upper*10
		oCells.item(i,3).value  = dl'"-" &(b.Tolerance.Lower*10)'"q"'"-" &b.Tolerance.Lower*10

		End If


	Next
	oWB.saveas("C:\TEMP\"& a.DisplayName & ".xlsx")
oWB.close

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 29 of 35

eladm
Collaborator
Collaborator

Hello

This is great , but why it not detect ref. / basic / limit dimension ?

5.png

0 Likes
Message 30 of 35

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Try this.

AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel

'Dim oXLFile As String = "C:\TEMP\DrawingDimensions.xlsx"
Dim oSheet As String = "Sheet1"

Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.add'.Open(oXLFile)
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet)

Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells

'oCells.item(2,1).value= b.Text.Text.ToString

Dim a As Inventor.DrawingDocument = ThisDrawing.Document
Dim s As Inventor.Sheet = a.ActiveSheet


Dim i As Integer = 1
		oCells.item(1,1).value  = "Dimension"
		oCells.item(1,2).value = "Tolerance Upper"
		oCells.item(1,3).value = "Tolerance Lower"
For Each b As Inventor.DrawingDimension In s.DrawingDimensions
	i = i + 1
'MsgBox (b.Text.Text & " " & b.Tolerance.ToleranceType)
	
	If b.Tolerance.ToleranceType = 31236 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10
	

		End If
If b.Tolerance.ToleranceType = 31233 Then
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10

		End If
If b.Tolerance.ToleranceType = 31235 Then
	Dim du As Double = "+" & (b.Tolerance.Upper * 10)
	Dim dl As Double = "-" & (b.Tolerance.Upper * 10)
	'MsgBox("+"&(b.Tolerance.Upper*10).ToString)
		oCells.item(i,1).value = b.Text.Text
		oCells.item(i,2).value = du '"="+"" &(b.Tolerance.Upper*10)'"p"'"+" & b.Tolerance.Upper*10
		oCells.item(i,3).value  = dl'"-" &(b.Tolerance.Lower*10)'"q"'"-" &b.Tolerance.Lower*10

		End If
If b.Tolerance.ToleranceType = 31246 Then
		oCells.item(i,1).value = (Replace((Replace(b.Text.Text.ToString,"(","")),")",""))'Replace(b.Text.Text.ToString,"-","")
		oCells.item(i,2).value = b.Tolerance.Upper*10
		oCells.item(i,3).value  = b.Tolerance.Lower*10

		End If

	Next
	oWB.saveas("C:\TEMP\"& a.DisplayName & ".xlsx")
oWB.close

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 31 of 35

eladm
Collaborator
Collaborator

thank you very much

0 Likes
Message 32 of 35

eladm
Collaborator
Collaborator

Hello

 

Do you know , why instead to get the diameter symbol , the excel get the letter n ?

eladm_0-1652241868525.png

regards

0 Likes
Message 33 of 35

chuck.bardsley
Advocate
Advocate

Is there a way to do this for ordinate dimensions.  Where each dim would export as X,Y?

Chuck B.
0 Likes
Message 34 of 35

bradeneuropeArthur
Mentor
Mentor
You mean if horizontal then there is an x dimension
and if vertical there is an Y dimension?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 35 of 35

chuck.bardsley
Advocate
Advocate

@bradeneuropeArthur wrote:
You mean if horizontal then there is an x dimension
and if vertical there is an Y dimension?

That is correct

Chuck B.
0 Likes