How to create a linear diameter dimension that is horizontal

How to create a linear diameter dimension that is horizontal

Anonymous
Not applicable
1,226 Views
4 Replies
Message 1 of 5

How to create a linear diameter dimension that is horizontal

Anonymous
Not applicable

Hi, all,

 

I want to create some dimensions with dimension style "linear diameter", and all of them should be horizontal. My problem is that as soon as the workpoints are not at the same elevation, then the dimension will no longer be horizontal, but become aligned instead. I tried to get around this by, instead of having a workpoint in the center of my cylinder, I put at workaxis there, and had that as one of my intent points, but I still got the same problem. The dimensions are aligned and not horizontal. How to solve this?? 

 

	oDim = oGeneralDims.AddLinear(
		oTG.CreatePoint2d(oView.Left+oView.Width,oView.Top+4),
		oGeometryIntent4(1),
		oGeometryIntent4(2),
		DimensionTypeEnum.kDiametricDimensionType)
		oDim.AttributeSets.Add("iLogic_Created")
0 Likes
1,227 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni

The fourth argument to the AddLinear method specifies the orientation of the dimension.  It's an optional argument and defaults to aligned if not specified.  The code below will create a horizontal dimension between two selected center marks (imported work points).

 

Public Sub HorizontalDim()
    Dim drawDoc As DrawingDocument
    Set drawDoc = ThisApplication.ActiveDocument
    
    Dim points(1) As Centermark
    Set points(0) = drawDoc.SelectSet.Item(1)
    Set points(1) = drawDoc.SelectSet.Item(2)
    
    Dim sht As Sheet
    Set sht = drawDoc.ActiveSheet
    
    Dim genDims As GeneralDimensions
    Set genDims = sht.DrawingDimensions.GeneralDimensions
    
    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
    
    Dim x As Double
    x = (points(0).Position.x + points(1).Position.x) / 2
    Dim y As Double
    Dim offset As Double
    offset = 1
    If points(0).Position.y > points(1).Position.y Then
        y = points(0).Position.y + offset
    Else
        y = points(1).Position.y + offset
    End If
        
    Dim textPstn As Point2d
    Set textPstn = tg.CreatePoint2d(x, y)
    
    Dim intents(1) As GeometryIntent
    Set intents(0) = sht.CreateGeometryIntent(points(0))
    Set intents(1) = sht.CreateGeometryIntent(points(1))
    Dim linDim As GeneralDimension
    Set linDim = genDims.AddLinear(textPstn, intents(0), intents(1), kHorizontalDimensionType)
End Sub

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5

Anonymous
Not applicable

Thank you for your reply. My problem is that I want the dimension type to be horizontal and a linear diameter (it is a diameter dimension for several grooves inside a detail view). If the the work points are on the same elevation, and I specify in the fourth argument:  "DimensionTypeEnum.kDiametricDimensionType", then I get the result I want. But, if the center work point is not on the same elevation, ilogic creates an aligned linear diameter dimension between the two points. I realize that putting the below line in the fourth argument would make it horizontal, but then it will no longer be a linear diameter. Do you know how I can achieve this =)?

 

DimensionTypeEnum.kHorizontalDimensionType

 

0 Likes
Message 4 of 5

perrysc
Enthusiast
Enthusiast

With the centerline as the central axis of the cylinder, the solution is possible. You must trick the system into dimensioning to a non-existent point on the centerline. For example:

 

Dim oCenterline As Centerline
Dim oCentermark As Centermark
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oIntentOne As GeometryIntent = oSheet.CreateGeometryIntent(oCentermark,oCentermark.Position)
Dim oIntentTwo As GeometryIntent = oSheet.CreateGeometryIntent(oCenterline,oTG.CreatePoint2d(oCenterline.StartPoint.X,oCentermark.Position.Y)) Dim oTextPoint As Point2d = oTG.CreatePoint2d((oCentermark.Position.X+oCenterline.StartPoint.X)*0.5,oCentermark.Position.Y + 1.5)
Dim oLinGenDim As LinearGeneralDimension = oDrawDoc.DrawingDimensions.GeneralDimensions.AddLinear(oTextPoint,oIntentOne,oIntentTwo,60166)

This should work for you, specifically for horizontal dimensions. Vertical dimensions require some rewriting, but you should be able to do it.

0 Likes
Message 5 of 5

dgreatice
Collaborator
Collaborator

Hi,

 

do you mean like this? Are any code can create this Dimension?

 

DiameterDimension.JPG

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