Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have two points that are at different elevations that I need to annotate with a linear dimension. I am able to add the dimension correctly in my view through the API, but when I try to adjust it manually afterwards it switches to an aligned dimension.
When adding this same linear dimension manually I don't have this problem. Could this be a bug or am I doing something incorrectly when creating the dimension?
The code below is a test of what I've been doing. It creates a linear dimension between the end points of two selected model lines. The screencast attached shows what happens when the dimension is moved manually after being created.
Dim dir As XYZ = New XYZ(0, 0, 1)
Dim r1 As Reference = _uiDoc.Selection.PickObject(ObjectType.Element, "Select one element")
Dim e1 As Element = _uiDoc.Document.GetElement(r1)
Dim Line1 As ModelLine = TryCast(e1, ModelLine)
Dim r2 As Reference = _uiDoc.Selection.PickObject(ObjectType.Element, "Select one element")
Dim e2 As Element = _uiDoc.Document.GetElement(r2)
Dim Line2 As ModelLine = TryCast(e2, ModelLine)
Dim ln1 As Line = Line1.GeometryCurve
Dim ln1Normal As XYZ = ln1.Direction.Normalize
Dim ln1Cross As XYZ = ln1Normal.CrossProduct(dir)
Dim ln2 As Line = Line2.GeometryCurve
Dim measurePnt1ref As Reference = ln1.GetEndPointReference(0)
Dim measurePnt1 As XYZ = ln1.GetEndPoint(0)
Dim measurePnt2ref As Reference = Nothing
Dim measurePnt2 As XYZ = Nothing
Dim pDist As Double = measurePnt1.DistanceTo(ln2.GetEndPoint(0))
If measurePnt1.DistanceTo(ln2.GetEndPoint(1)) < pDist Then
measurePnt2ref = ln2.GetEndPointReference(1)
measurePnt2 = ln2.GetEndPoint(1)
Else
measurePnt2ref = ln2.GetEndPointReference(0)
measurePnt2 = ln2.GetEndPoint(0)
End If
Dim refs As New ReferenceArray
refs.Append(measurePnt1ref)
refs.Append(measurePnt2ref)
Dim pointStart As XYZ = measurePnt1 + ln1Cross.Multiply(2)
Dim pointEnd As XYZ = pointStart - ln1Normal.Multiply(1)
Dim mLine As Line = Line.CreateBound(New XYZ(pointStart.X, pointStart.Y, 0), New XYZ(pointEnd.X, pointEnd.Y, 0))
Using Transaction As Transaction = New Transaction(m_rvtDoc)
Transaction.Start("Create dimensions")
Dim dimension As Dimension = m_rvtDoc.Create.NewDimension(m_rvtDoc.ActiveView, mLine, refs)
'm_rvtDoc.Create.NewDetailCurve(m_rvtDoc.ActiveView, mLine)
Transaction.Commit()
End Using
Solved! Go to Solution.