Automatic dimensioning of arcs VBA

Automatic dimensioning of arcs VBA

basnederveen
Advocate Advocate
1,238 Views
12 Replies
Message 1 of 13

Automatic dimensioning of arcs VBA

basnederveen
Advocate
Advocate

Hi

 

I'm trying to do some automatic dimensioning in VBA. I want to give outer dimensions to a part, but not from a sketch. For this I will need to dimension parts from point to point. This is no problem when the points are on lines, since then I can use start, mid and end points which is always a corner. Sometimes its not a line but an arc and this is where my problem occurs. 

 

It seems like the snap points created when you activate the dimension command and hover your mouse over a point on the arc are not available through the API. So I am trying to use the midpoint of an arc to to create a dimension to another point. When I try this the dimension keeps being created at the centerpoint instead. 

 

Is it possible to create a dimension with VBA from an CircularArcCurve.midpoint to another point? 

And can you get a geometry intent just by giving a point2d and the curve? So I can dimension to any point?

 

this is the code i used to try it out, and i attached a screenshot, left is what i want right is what i get

Sub test()

Dim dwg As DrawingDocument
Set dwg = ThisApplication.ActiveDocument

Dim oview As DrawingView
Set oview = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Pick a view")

Dim arc As DrawingCurve
For Each arc In oview.DrawingCurves
    If arc.CurveType = kCircularArcCurve Then Exit For
Next

Dim crv As DrawingCurve
Set crv = oview.DrawingCurves.Item(2)

Dim int1 As GeometryIntent
Set int1 = dwg.ActiveSheet.CreateGeometryIntent(crv, crv.MidPoint)

Dim int2 As GeometryIntent
Set int2 = dwg.ActiveSheet.CreateGeometryIntent(arc, arc.MidPoint)

Call dwg.ActiveSheet.DrawingDimensions.GeneralDimensions.AddLinear(oview.Position, int2, int1, kHorizontalDimensionType)

End Sub

 

Accepted solutions (1)
1,239 Views
12 Replies
Replies (12)
Message 2 of 13

basnederveen
Advocate
Advocate

Does anyone know how to use the midpoint of an arc and add a dimension?

0 Likes
Message 3 of 13

dgreatice
Collaborator
Collaborator

Hi,

 

can you show by screenshot, result of dimension?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 13

basnederveen
Advocate
Advocate

It's included in my original post. Right is what I get, left is what I am trying to get. I'm taking the midpoint of an arc, but it always takes the centerpoint. I can use the midpoint of a straight line though..

0 Likes
Message 5 of 13

basnederveen
Advocate
Advocate

Hi dgreatice, do you know if this is possible at all?

0 Likes
Message 6 of 13

dgreatice
Collaborator
Collaborator

hi @basnederveen

 

I try to get midpoint, but same result, it always go to center point of arc.

 

maybe this bug, try to request answer from Autodesk.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 7 of 13

basnederveen
Advocate
Advocate

Yeah same here. Any suggestions on how to ask Autodesk apart from posting here in the forum? Posted a few times in here but with no success.

0 Likes
Message 8 of 13

dgreatice
Collaborator
Collaborator
Accepted solution

Hi, 

 

now I find out, how to get Mid Point Intent

 

use PointIntentEnum.kMidPointIntent

Set int1 = dwg.ActiveSheet.CreateGeometryIntent(crv, PointIntentEnum.kMidPointIntent)
Set int2 = dwg.ActiveSheet.CreateGeometryIntent(arc, PointIntentEnum.kMidPointIntent)
Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 9 of 13

basnederveen
Advocate
Advocate

Thanks! Strange that this is not necessary for a regular curve but it is for an 'kCircularArcCurve'

0 Likes
Message 10 of 13

dgreatice
Collaborator
Collaborator

the result of arc.midpoint is Double (position of x & y), and that is not intent object

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 11 of 13

dgreatice
Collaborator
Collaborator

You can find information about Geometry Intent Object :

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-86A7861A-F382-4DF9-BD9D-9526F290CDD1

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 12 of 13

basnederveen
Advocate
Advocate

Thanks alot! Do you know if it is also possible to create an intent on any location on an arc?

 

In specific it would be nice to be able to create an intent on the min/max x,y coordinates of an arc. These intents seem to be created when you hover your mouse over them.

0 Likes
Message 13 of 13

basnederveen
Advocate
Advocate

Found it!! Been looking for this for ages!! 

 

PointIntentEnum.kCircularRightPointIntent -> the kCircular....Intent gives the max x/y right left top bottom point!!!

0 Likes