- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dimensions calculator
I am asking you for help. Is it possible to create a calculator that will export, for example, an excel list with the dimensions of a rectangle circumscribed by an ellipse? I have created a layout as shown in the picture below. I have an outlined rectangle on an ellipse. The only controlled value is the angle of the ellipse. I want to be able to get the width and height values of the rectangle for this layout, depending on the inclination of the ellipse. In the range of 0 to 90 degrees. It can be a list in excel, a text file, etc.
Thank you for help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @p.kaminskiG7KX4 . Here is an example of code that searches all sketches for ellipses and measures their dimensions along the X and Y axes:
Private Sub Main()
Dim oDoc As Document = ThisApplication.ActiveDocument
If Not TypeOf oDoc Is PartDocument Then Exit Sub
Dim oPDoc As PartDocument = oDoc
Dim oUOfM As UnitsOfMeasure = oPDoc.UnitsOfMeasure
Dim oSketches As PlanarSketches = oPDoc.ComponentDefinition.Sketches
Dim dMinX, dMinY, dMaxX, dMaxY As Double
For Each oSketch As PlanarSketch In oSketches
If oSketch.SketchEllipses.Count = 1 Then
Dim oEllipse As SketchEllipse = oSketch.SketchEllipses.Item(1)
dMinX = oUOfM.ConvertUnits(oEllipse.RangeBox.MinPoint.X, kCentimeterLengthUnits, oUOfM.LengthUnits)
dMinY = oUOfM.ConvertUnits(oEllipse.RangeBox.MinPoint.Y, kCentimeterLengthUnits, oUOfM.LengthUnits)
dMaxX = oUOfM.ConvertUnits(oEllipse.RangeBox.MaxPoint.X, kCentimeterLengthUnits, oUOfM.LengthUnits)
dMaxY = oUOfM.ConvertUnits(oEllipse.RangeBox.MaxPoint.Y, kCentimeterLengthUnits, oUOfM.LengthUnits)
MessageBox.Show("X = " & Abs(Round(dMaxX - dMinX, 3)), oSketch.Name & ", Size X")
MessageBox.Show("Y = " & Abs(Round(dMaxY - dMinY, 3)), oSketch.Name & ", Size Y")
End If
Next
End SubYou can see how to create an excel file and write information in it here.
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim a As Inventor.PartDocument = ThisDoc.Document
Dim b As Inventor.PartComponentDefinition = a.ComponentDefinition
Dim c As Inventor.Sketch = b.Sketches.Item(1)
Dim b2d As Inventor.Box2d = c.SketchEllipses.Item(1).RangeBox
MsgBox(b2d.MinPoint.X)
MsgBox(b2d.MinPoint.Y)
MsgBox(b2d.MaxPoint.X)
MsgBox(b2d.MaxPoint.Y)
Dim dX As Double = b2d.MaxPoint.X - b2d.MinPoint.X
Dim dy As Double = b2d.MaxPoint.Y - b2d.MinPoint.Y
MsgBox(dX * 10 & " " & dy * 10)'
'AND WRITE THESE TO EXCEL??
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you, that is what I want. I think about find position of point crossing rectangle and ellipse. Can we add dimensions of the point, as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report