I am trying to create dimensions programatically using MicroStation VBA. I can create the dimensions and vary the properties, but I cannot make the witness line move from the edge of the square it is dimensioning. I have tried seemingly everything combination of dimension properties that I can think of. Obviously there is one more (the correct one) that I have not found yet.
Here are the results I am getting at the moment. There have been many other variations on the extension line, but the witness line stubbornly refuses to move at all.
Here is a snippet of the code as it stands at this moment. I just drew the box using a shape connecting the vertices in the first section. Since it was easiest, I grabbed those same vertices for the dimension reference points. I tried using different values for the two extension line properties, but that wasn't helping me find a solution either. (There are three distances on an extension line: the gap between the reference point and the extension line; the distance of the witness line from the reference points; and the length of extension line beyond the witness line. Which properties control each of these distances?)
'Draw plate plan outline
moaShape_Points(0).X = moOrigin_PL_Plan.X: moaShape_Points(0).Y = moOrigin_PL_Plan.Y: moaShape_Points(0).Z = Z
moaShape_Points(1).X = moaShape_Points(0).X + Lb: moaShape_Points(1).Y = moaShape_Points(0).Y: moaShape_Points(1).Z = Z
moaShape_Points(2).X = moaShape_Points(1).X: moaShape_Points(2).Y = moaShape_Points(1).Y + Wb: moaShape_Points(2).Z = Z
moaShape_Points(3).X = moaShape_Points(0).X: moaShape_Points(3).Y = moaShape_Points(2).Y: moaShape_Points(3).Z = Z
Set moCurrent_Shape = CreateShapeElement1(Nothing, moaShape_Points, msdFillModeNotFilled)
ActiveModelReference.AddElement moCurrent_Shape
'Dimension Plate
Dim moRot_Dim As Matrix3d
moRot_Dim = Matrix3dIdentity
Dim moCurrent_Dimension As DimensionElement
Dim moCurrent_Dimension_Style As DimensionStyle
Dim mdDim_Extension As Double
'Create horz dimension and add end points
Set moCurrent_Dimension = CreateDimensionElement1(Nothing, moRot_Dim, msdDimTypeSizeArrow)
moCurrent_Dimension.AddReferencePoint ActiveModelReference, moaShape_Points(2)
moCurrent_Dimension.AddReferencePoint ActiveModelReference, moaShape_Points(3)
'Read Dimension style, adjust dimension property, write dimension style back.
mdDim_Extension = 2.5 '2.5*40mm text height = 100mm offset
Set moCurrent_Dimension_Style = moCurrent_Dimension.DimensionStyle
moCurrent_Dimension_Style.ExtensionLineOffset = mdDim_Extension
moCurrent_Dimension_Style.ExtensionLineExtend = mdDim_Extension
Set moCurrent_Dimension.DimensionStyle = moCurrent_Dimension_Style
ActiveModelReference.AddElement moCurrent_Dimension
'Create vert dimension and add end points
moRot_Dim = Matrix3dFromAxisAndRotationAngle(2, Pi() / 2)
moCurrent_Dimension.AddReferencePoint ActiveModelReference, moaShape_Points(0)
mdDim_Extension = 100 'try 100mm offset directly
I have looked at these other posts, but they weren't able to sort me out.
Dimension Offset:
http://communities.bentley.com/products/programming/microstation_programming/f/343173/p/81326/225229.aspx#225229
Dimension Text Rotation:
http://communities.bentley.com/products/programming/microstation_programming/f/343173/p/79118/217531.aspx#217531
Sample Code for CreateDimensionElement1 Function:
http://communities.bentley.com/products/programming/microstation_programming/f/19569/p/25991/59809.aspx
Thanks,
Dave
Before adding dimension element to active model, you should set dimension height by following line:
moCurrent_Dimension.DimHeight = 2
Thus, you will set the length of extension line to 2 in master working unit.
HTH, Yongan
Thank you. I knew there must be a simple setting somewhere to control that. I just couldn't find it in the list of dimension properties.