By Adam Nagy
When you want to use the value of a dimension from another dimension, then you actually need to use the Parameter of that dimension. If you click on a dimension which is referencing another dimension's value, then you can see that both dimensions have an associated parameter, and the equation is based on those. Both dimensions are just simple dimensions based on a Parameter: in this case one is based on d5 and the other on d6:
If I wanted to recreate the above highlighted dimension then I could do it like this in VBA. Before running the code you need to go to the Sketch environment in the Part document, then select the dimension you want to reference from the new dimension and then shift-select the sketch line you want to dimension:
Sub AddDimension() Dim pd As PartDocument Set pd = ThisApplication.ActiveDocument Dim dc As DimensionConstraint Set dc = pd.SelectSet(1) Dim sl As SketchLine Set sl = pd.SelectSet(2) Dim sk As PlanarSketch Set sk = sl.Parent Dim tg As TransientGeometry Set tg = ThisApplication.TransientGeometry Dim pt As Point2d Set pt = tg.CreatePoint2d( _ (sl.StartSketchPoint.Geometry.x + _ sl.EndSketchPoint.Geometry.x) / 2, _ sl.StartSketchPoint.Geometry.y + 0.5) Dim dc2 As TwoPointDistanceDimConstraint Set dc2 = sk.DimensionConstraints.AddTwoPointDistance( _ sl.StartSketchPoint, _ sl.EndSketchPoint, _ kAlignedDim, _ pt) dc2.Parameter.Expression = dc.Parameter.name + " * 2 ul"' If the sketch is consumed by a feature' this will get the lines updated Call sk.Solve End Sub