Change of dimension type on a drawing - arc length, diameter, radius...

Change of dimension type on a drawing - arc length, diameter, radius...

Anonymous
Not applicable
818 Views
3 Replies
Message 1 of 4

Change of dimension type on a drawing - arc length, diameter, radius...

Anonymous
Not applicable

Hi Guys,

In my job common situation is when I need to make arc length dimension on a drawing. (type "D" ->click on a line-> right click-> dimesnion type -> arc length).

I was wondering if there is an option to do macro or something to make this steps faster. Maybe there is an option to make custom button or short key that will instantly choose dimension type of arc length.

0 Likes
Accepted solutions (1)
819 Views
3 Replies
Replies (3)
Message 2 of 4

YuhanZhang
Autodesk
Autodesk
Accepted solution

You can follow below steps to create a button with the sample macro for you to create arc length dimension:

 

1. Copy below macro to a VBA module(in the ApplicationProject).

 

Sub ArcLengthDim()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    Dim oCurveSeg As DrawingCurveSegment
    Set oCurveSeg = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select an arc drawing curve")
    
    Dim oCurve As DrawingCurve
    Set oCurve = oCurveSeg.Parent
    
    If oCurve.CurveType <> kCircularArcCurve Then
        MsgBox "The selected drawing curve is not an arc curve!"
        Exit Sub
    End If
    
    Dim dPosX As Double, dPosY As Double
    If oCurve.MidPoint.X <= oCurve.CenterPoint.X Then
        dPosX = oCurve.MidPoint.X * 3 / 2 - oCurve.CenterPoint.X / 2
    Else
        dPosX = oCurve.MidPoint.X / 2 + oCurve.CenterPoint.X / 2
    End If
    If oCurve.MidPoint.Y <= oCurve.CenterPoint.Y Then
        dPosY = oCurve.MidPoint.Y * 3 / 2 - oCurve.CenterPoint.Y / 2
    Else
        dPosY = oCurve.MidPoint.Y / 2 + oCurve.CenterPoint.Y / 2
    End If
    
    Dim oPos As Point2d
    Set oPos = ThisApplication.TransientGeometry.CreatePoint2d(dPosX, dPosY)
    
    Dim oIntent As GeometryIntent
    Set oIntent = oSheet.CreateGeometryIntent(oCurve)
    
    Dim oArcLenDim As LinearGeneralDimension
    Set oArcLenDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPos, oIntent, , kArcLengthDimensionType)
End Sub

 

2. In Inventor ribbon, right click and choose "Customize User Commands...".

3. In the Ribbon tab, select "ArcLengthDim" macro in the commands, and send it to the "Drawing | Annotate" tab:

ArcLenCommand1.pngArcLenCommand2.png

 

4. Now in the drawing, activate the Annotate tab, and find the macro command:

ArcLenCommand3.png

 

5. Click it and select an arc curve to see the result.

 

This is a sample for you to get starting on this. Hope it helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 4

Anonymous
Not applicable

Thanks yuhanzhangit works perfect!

Maybe, do You can help me with this... when I want to stop the program ArcLengthDim and press "Esc" this window appear:
ArcError.JPG

I want skip this window. I guess it is a matter of one line code to stop by pressing "Esc"

 

 

0 Likes
Message 4 of 4

YuhanZhang
Autodesk
Autodesk

Sorry for late response, you can add a check in the VBA code to exit the sub if user cancels the selection:

 

Dim oCurveSeg As DrawingCurveSegment
    Set oCurveSeg = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select an arc drawing curve")
    
    If oCurveSeg Is Nothing Then
        Exit Sub
    End If


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes