06-14-2023
03:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-14-2023
03:22 AM
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.