<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dimension created with API switches from linear to aligned in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7976738#M50406</link>
    <description>&lt;P&gt;My answer to a related question might help&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/how-can-i-create-dimension-line-that-is-not-parallel-to-detail/m-p/6801271" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/how-can-i-create-dimension-line-that-is-not-parallel-to-detail/m-p/6801271&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 09:42:34 GMT</pubDate>
    <dc:creator>FAIR59</dc:creator>
    <dc:date>2018-05-03T09:42:34Z</dc:date>
    <item>
      <title>Dimension created with API switches from linear to aligned</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7975394#M50405</link>
      <description>&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;when&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I try to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;adjust&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;it manually afterwards it switches to an aligned dimension.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;        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)) &amp;lt; 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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="iframe-container"&gt;&lt;IFRAME width="640" height="590" src="https://screencast.autodesk.com/Embed/Timeline/a4deac85-bb29-49d9-94ac-59edf856beff" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 19:21:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7975394#M50405</guid>
      <dc:creator>JJamesHillGrp</dc:creator>
      <dc:date>2018-05-02T19:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dimension created with API switches from linear to aligned</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7976738#M50406</link>
      <description>&lt;P&gt;My answer to a related question might help&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/how-can-i-create-dimension-line-that-is-not-parallel-to-detail/m-p/6801271" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/how-can-i-create-dimension-line-that-is-not-parallel-to-detail/m-p/6801271&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 09:42:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7976738#M50406</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2018-05-03T09:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dimension created with API switches from linear to aligned</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7977453#M50407</link>
      <description>&lt;P&gt;I updated my code with the information from the other post and it worked perfectly, thank you&lt;/P&gt;&lt;PRE&gt;        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)) &amp;lt; pDist Then
            measurePnt2ref = ln2.GetEndPointReference(1)
            measurePnt2 = ln2.GetEndPoint(1)
        Else
            measurePnt2ref = ln2.GetEndPointReference(0)
            measurePnt2 = ln2.GetEndPoint(0)
        End If

        Dim dummyLn As Line = Line.CreateBound(XYZ.Zero, XYZ.BasisX)
        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 dummy As DetailLine = m_rvtDoc.Create.NewDetailCurve(m_rvtDoc.ActiveView, dummyLn)

            Dim refs As New ReferenceArray
            refs.Append(dummy.GeometryCurve.Reference)
            refs.Append(measurePnt1ref)
            refs.Append(measurePnt2ref)

            Dim dimension As Dimension = m_rvtDoc.Create.NewDimension(m_rvtDoc.ActiveView, mLine, refs)
            m_rvtDoc.Delete(dummy.Id)
            Transaction.Commit()
        End Using&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 14:45:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimension-created-with-api-switches-from-linear-to-aligned/m-p/7977453#M50407</guid>
      <dc:creator>JJamesHillGrp</dc:creator>
      <dc:date>2018-05-03T14:45:25Z</dc:date>
    </item>
  </channel>
</rss>

