Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

Placing a note with VBA. Resultant element is a "Dimension" not a "Note".

$
0
0

Placing a note with VBA. Resultant element is a "Dimension" not a "Note".

The code below is the best I can come up with to emulate the "Place Note" tool. However:

1. The element it places is a dimension element, essentially a leader with some text. This behaves differently to the elements placed by the "Place Note tool". Examining the properties of the element reveals it to be a "dimension" whereas a true Note has the property element type: "Note".

2. The text part of it is limited to 79 characters. Any more do not show.

3. There seems to be no way to get it run the text over two lines.

I would really like to know how to access the "Place Note" tool, it should be something like

CreateNoteElement1(.......)

If this is not possible I'd be grateful for any suggestions to sort the text out for the code I have below.

I know this question has been asked in various forms over the years but nobody seems to have come up with a proper answer.

Best wishes,
N.


'---------------------------------------------------------

Public Sub PlaceNote()

Dim oStartPoint As Point3d
Dim oEndPoint As Point3d
Dim oThirdPoint As Point3d

Dim TXTstl As TextStyle
Dim TXTstls As TextStyles
Dim TXTEl As TextElement
Dim LabelText As String
Dim SecondLabelText As String

Dim DimElem As DimensionElement
Dim oDimStyle As DimensionStyle
Dim oDimensionStyles As DimensionStyles

Dim NoteElem As TextNodeElement

Dim oCell As CellElement
Dim CellRotation As Matrix3d
Dim CellScale As Point3d
Dim rotation As Matrix3d

oStartPoint.X = 434171.9798
oStartPoint.Y = 352483.3104
oStartPoint.Z = 0
oEndPoint.X = oStartPoint.X + 2
oEndPoint.Y = oStartPoint.Y + 2
oEndPoint.Z = 0
oThirdPoint.X = oEndPoint.X + 2
oThirdPoint.Y = oEndPoint.Y
oThirdPoint.Z = Elevation

rotation = Matrix3dFromAxisAndRotationAngle(2, Radians(45))

CellRotation = Matrix3dFromAxisAndRotationAngle(2, Radians(0))


'Create and add the arrow and note.


'Get the existing dimension style from the file.
Set oDimensionStyles = ActiveDesignFile.DimensionStyles
Set oDimStyle = oDimensionStyles.Item(1)


'Set some dimension attributes.  I've set a lot here, not all might be relevant.

oDimStyle.TerminatorArrowhead = msdDimTerminatorArrowheadFilled
oDimStyle.NoteHorizontalAttachment = msdDimNoteHorizontalAttachmentAuto
oDimStyle.DisplayNoteInlineLeader = True
oDimStyle.DimWithLeaderType = msdDimBallAndChainChainTypeLine
oDimStyle.DimWithLeaderAlignment = msdDimBallAndChainAlignmentLeft
oDimStyle.EnableDimWithLeader = True
oDimStyle.TextJustification = msdDimTextJustificationLeft
oDimStyle.TextOrientation = MsdDimTextOrientationHorizontal
oDimStyle.OverrideAnnotationScale = True
oDimStyle.AnnotationScale = 3
oDimStyle.NoteInlineLeaderLength = 1255
oDimStyle.ShowSecondaryText = True
oDimStyle.NoteTextFrameType = msdDimMLNoteFrameTypeBox

ActiveSettings.DimensionStyle = oDimStyle

'Set DimElem = CreateDimensionElement1(Nothing, CellRotation, msdDimTypeNote)
Set DimElem = CreateDimensionElement1(Nothing, CellRotation, MsdDimType.msdDimTypeNote)


DimElem.InsertReferencePoint ActiveModelReference, 1, oStartPoint
DimElem.InsertReferencePoint ActiveModelReference, 2, oEndPoint
'DimElem.InsertReferencePoint ActiveModelReference, 3, oThirdPoint


' Set the dimension element's style object

DimElem.DimensionStyle = oDimStyle

LabelText = "My lovely label that is quite long. I would like it to be much more than 80 characters"   '(86 characters)
SecondLabelText = "Some more lovely words. I thank you."

DimElem.PrimaryText = LabelText & vbLf & SecondLabelText
'DimElem.SecondaryText = SecondLabelText   'commented out, I'm not sure this even means "Second line of text", it might refer to secondary units.

DimElem.Redraw


ActiveModelReference.AddElement DimElem
End Sub


Viewing all articles
Browse latest Browse all 7260

Trending Articles