Reply

How to place a dimension on the middle of a line in sketch?

[ Edited ]

 

Hello everybody,

Maybay somebody can give me a hand.

Im trying to place a dimension on the midpoint of a line to the refplane in sketch mode. My code is as follows;

 

Dim

 

  refPlaneLineTop As Line2d = objProfile.ProjectRefPlane(objAssy.AsmRefPlanes(0))DimrefPlaneLineFrontAsLine2d =objProfile.ProjectRefPlane(objAssy.AsmRefPlanes(2))DimaLine2d(0 To 3)As SolidEdgeFrameworkSupport.Line2d

objRelations2d = objProfile.Relations2d

objDimensions = objProfile.Dimensions

objDimensions.Constraint = True

objDimensions.AxisMode = SolidEdgeFrameworkSupport.DimAxisModeConstants.igDimAxisModeDefault

objDimensions.Axis = refPlaneLineFront

For

aLine2d(l) = objLines2d.AddBy2Points(xyTable.Rows(l).Item(0) / 1000, xyTable.Rows(l).Item(1) / 1000, xyTable.Rows(l + 1).Item(0) / 1000, xyTable.Rows(l + 1).Item(1) / 1000)

 

 

 

 

The dimension which is placed after running the code has a keypoint  at the endpoint of the line

Thx for the help

 

Gr, Peter l = 0 To xyTable.Rows.Count - 2IfxyTable.Rows(l).Item(1) = xyTable.Rows(l + 1).Item(1)ThenobjRelation2d = objRelations2d.AddHorizontal(aLine2d(l))IfxyTable.Rows(l).Item(0) = xyTable.Rows(l + 1).Item(0)ThenobjRelation2d = objRelations2d.AddVertical(aLine2d(l))NextobjDimension = objDimensions.AddDistanceBetweenObjects(aLine2d(1), 0, 0, 0, KeypointIndexConstants.igLineMiddle, refPlaneLineTop, 0, 0, 0, KeypointIndexConstants.igLineMiddle)

 

Posted by: W.P. Verpalen
Post date: 5/12/2010 2:23:36 AM

2 REPLIES

RE: How to place a dimension on the middle of a line in sketch?

[ Edited ]

Peter,

 

I believe appearance of dimensions is controlled by the DimensionStyles.

 

Interactively (manually), when you create a dimension, the style used is picked from the 'Set all styles to' dropdown in DimensionStyle tab in Tools > Options. This is the default setting for that Document. However you can override the dimension style properties for individual dimensions (select dimension > rmb > Properties). Or you can change the dimension style in the ribbon bar when editing the dimension.

 

You can also modify a dimension style or create a new dimension style and make it 'active' in the settings before you create a dimension.

 

In the API, I do not find any active style property, or activate method for dimension style. So, I believe it is not possible to programatically change the 'current / active' dimension style for the document.

 

So, I believe you will have to individually change the appropriate property of each dimension. Or create a new dimension style and set it 'active' manually and run the program or change DimStyle property of each dimension to the required style if all dimensions can't be of the same style.

 

What I would do is I create a new dimension style, verify that it gives me what I require and then apply that syle programmatically to individual dimensions.

 

I hope I have understood your problem correctly and this response helps you in the right direction.

 

Posted by: Sanjay Kulkarni
Post date: 5/12/2010 7:49:52 PM

RE: How to place a dimension on the middle of a line in sketch?

[ Edited ]

Hello,

 

I see something went wrong by submitting the code.

The simplified code is as follows;

 

objProfile = sketch.Profile

Dim xyTable As DataTable

Dim refPlaneLineTop As Line2d = objProfile.ProjectRefPlane(objAssy.AsmRefPlanes(0))

Dim refPlaneLineFront As Line2d = objProfile.ProjectRefPlane(objAssy.AsmRefPlanes(2))

Dim aLine2d(0 To 3) As SolidEdgeFrameworkSupport.Line2d

Dim BaffleODArc As Arc2d

objRelations2d = objProfile.Relations2d

objDimensions = objProfile.Dimensions

objDimensions.Constraint = True

objLines2d = objProfile.Lines2d

For l = 0 To xyTable.Rows.Count - 2

aLine2d(l) = objLines2d.AddBy2Points(xyTable.Rows(l).Item(0) / 1000, xyTable.Rows(l).Item(1) / 1000, xyTable.Rows(l + 1).Item(0) / 1000, xyTable.Rows(l + 1).Item(1) / 1000)

If xyTable.Rows(l).Item(1) = xyTable.Rows(l + 1).Item(1) Then objRelation2d = objRelations2d.AddHorizontal(aLine2d(l))

If xyTable.Rows(l).Item(0) = xyTable.Rows(l + 1).Item(0) Then objRelation2d = objRelations2d.AddVertical(aLine2d(l))

Next

'objDimensions.AxisMode = SolidEdgeFrameworkSupport.DimAxisModeConstants.igDimAxisModeImplied ' diagonaal

'objDimensions.AxisMode = SolidEdgeFrameworkSupport.DimAxisModeConstants.igDimAxisModeExplicit 'dimension axis

'objDimensions.AxisMode = SolidEdgeFrameworkSupport.DimAxisModeConstants.igDimAxisModeExplicit

'objDimensions.Axis = refPlaneLineFront

'objDimensions.AngleCompliment = False

objDimension = objDimensions.AddDistanceBetweenObjects(aLine2d(1), 0, 0, 0, KeypointIndexConstants.igLineMiddle, refPlaneLineTop, 0, 0, 0, KeypointIndexConstants.igLineMiddle)

 

 

Sanjay,

thx for the reply,

 

Maybe the new code will give you a better idee of the problem.

because dimensionstyles can only be changed after the dimension is added.

 

Peter

 

Posted by: W.P. Verpalen
Post date: 5/16/2010 8:10:29 PM