Dimension - Place Note


The VBA method .CreateDimensionElement1 can be used to create dimension elements.

The syntax for this method is:
Set DimensionElement = object.CreateDimensionElement1 (Template, Rotation, Type [, TextOrientationView])

where Type is a MsDimType expression and allows to create dimension elements of different types.

The MsDimType enum includes the following list:

msdDimTypeUseActive -1 (&HFFFFFFFF)  
msdDimTypeNone 0 (&H0)  
msdDimTypeSizeArrow 1 (&H1)  
msdDimTypeSizeStroke 2 (&H2)  
msdDimTypeLocateSingle 3 (&H3)  
msdDimTypeLocateStacked 4 (&H4)  
msdDimTypeAngleSize 5 (&H5)  
msdDimTypeArcSize 6 (&H6)  
msdDimTypeAngleLocation 7 (&H7)  
msdDimTypeArcLocation 8 (&H8)  
msdDimTypeAngleLines 9 (&H9)  
msdDimTypeAngleAxis 10 (&HA)  
msdDimTypeRadius 11 (&HB)  
msdDimTypeDiameter 12 (&HC)  
msdDimTypeDiameterPara 13 (&HD)  
msdDimTypeDiameterPerp 14 (&HE)  
msdDimTypeCustomLinear 15 (&HF)  
msdDimTypeOrdinate 16 (&H10)  
msdDimTypeRadiusExtended 17 (&H11)  
msdDimTypeDiameterExtended 18 (&H12)  
msdDimTypeCenter 19 (&H13)  
msdDimTypeAngleAxisX 50 (&H32)  
msdDimTypeAngleAxisY 51 (&H33)  
msdDimTypeLabelLine 52 (&H34)  
msdDimTypeNote 53 (&H35) 

Here a small VBA code example using the type msdDimTypeNote to place a Note:

Option Explicit

Sub placeNoteExample()
Dim oDim As DimensionElement
Dim oDimStyle As DimensionStyle
    
    ' Create a new DimensionElement of type Note:
    Set oDim = CreateDimensionElement1(Nothing, Matrix3dIdentity, msdDimTypeNote)
    oDim.AddReferencePoint ActiveModelReference, Point3dZero
    oDim.AddReferencePoint ActiveModelReference, Point3dFromXYZ(10, 20, 0)
    oDim.AddReferencePoint ActiveModelReference, Point3dFromXYZ(20, 20, 0)
    
    ' if required use a specific available dimensionstyle:
    Set oDimStyle = ActiveDesignFile.DimensionStyles("teststyle")
    oDim.DimensionStyle = oDimStyle
    
    ' Define note text:
    oDim.PrimaryText = "test"
    
    ' Place element into active model:
    ActiveModelReference.AddElement oDim
End Sub