<?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: DRAW LINE VISIBLE ON SCREEN in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11919165#M40456</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6961077"&gt;@Chuong.Ho&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Just wondering if you wouldn't mind sharing the isSamSide method?&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9528713"&gt;@l.virone&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this constant updating with the line make the Element ID climb during use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 01:37:35 GMT</pubDate>
    <dc:creator>BHamlet</dc:creator>
    <dc:date>2023-04-25T01:37:35Z</dc:date>
    <item>
      <title>DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8964665#M40445</link>
      <description>&lt;DIV class="tlid-input input"&gt;&lt;DIV class="source-wrap"&gt;&lt;DIV class="input-full-height-wrapper tlid-input-full-height-wrapper"&gt;&lt;DIV class="source-input"&gt;&lt;DIV class="source-footer-wrap source-or-target-footer"&gt;&lt;DIV class="character-count tlid-character-count"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="source-footer"&gt;&lt;DIV class="src-tts left-positioned ttsbutton jfk-button-flat source-or-target-footer-button jfk-button"&gt;&lt;DIV class="jfk-button-img"&gt;&lt;SPAN style="font-family: inherit;"&gt;Hello friends&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="tlid-results-container results-container"&gt;&lt;DIV class="tlid-result result-dict-wrapper"&gt;&lt;DIV class="result tlid-copy-target"&gt;&lt;DIV class="text-wrap tlid-copy-target"&gt;&lt;DIV class="result-shield-container tlid-copy-target"&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN&gt;is there any way to create a line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when the first point appears&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;then click on the second point&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the following code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;with which I **** the first point and then the second&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and the line is drawn.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Public&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;CrealineaPickpoint()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;doc&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;Document =&amp;nbsp;&lt;SPAN&gt;Me&lt;/SPAN&gt;.Application.ActiveUIDocument.Document&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;uidoc&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;UIDocument =&amp;nbsp;&lt;SPAN&gt;Me&lt;/SPAN&gt;.Application.ActiveUIDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;startPoint&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;XYZ = uidoc.Selection.PickPoint("PickPoint One")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;directionPt&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;XYZ = uidoc.Selection.PickPoint("PickPoint Two")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;detailline&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;DetailLine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;t&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;Transaction =&amp;nbsp;&lt;SPAN&gt;New&lt;/SPAN&gt;&amp;nbsp;Transaction(doc,&amp;nbsp;"Create Detail Line")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;If&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;True&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Then&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.Start()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Dim&lt;/SPAN&gt;&amp;nbsp;line&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;Line = Line.CreateBound(startPoint, directionPt)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;detailline =&amp;nbsp;&lt;SPAN&gt;TryCast&lt;/SPAN&gt;(doc.Create.NewDetailCurve(doc.ActiveView, line), DetailLine)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.Commit()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;If&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TaskDialog.Show("Length", detailline.id.tostring)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 426px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/666654iBD5B415C990C0EC0/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the idea is to create the line&lt;BR /&gt;as the detail line command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 759px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/666655i3A51E4E919E468FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in this way the user can interact&lt;BR /&gt;with the application to see the direction of the line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was looking at information in several places&lt;BR /&gt;even in SDK but nothing appears&lt;/P&gt;&lt;P&gt;I appreciate the help.&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 02:11:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8964665#M40445</guid>
      <dc:creator>rodrigohbm</dc:creator>
      <dc:date>2019-08-14T02:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8964800#M40446</link>
      <description>&lt;P&gt;What you are asking for is called a 'rubber band' or 'rubber banding'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nope, sorry, afaik the Revit API does currently not provide access to this functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can raise a wish for it in the Revit Idea Station, if you like, or vote for an existing wish, if one exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 05:12:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8964800#M40446</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-08-14T05:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8974197#M40447</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;analyzing the subject&lt;BR /&gt;you can take care of the family&amp;nbsp;&amp;nbsp;Detail Item line based&lt;BR /&gt;since it is requesting the insertion point&lt;BR /&gt;and then the second point to end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there will be some example using&lt;BR /&gt;the family&amp;nbsp;&amp;nbsp;Detail Item line based&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:50:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/8974197#M40447</guid>
      <dc:creator>rodrigohbm</dc:creator>
      <dc:date>2019-08-19T16:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11776328#M40448</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the same UI problem and I've used these two functions inside a loop which create a line where the mouse is, refresh, and delete the line every 0.1 seconds until the user choose the second point. A little Tricky but it worked fine for me and Revit seems to execute these 2 functions very fast.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;uidoc.RefreshActiveView();&lt;BR /&gt;doc.Regenerate();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 15:25:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11776328#M40448</guid>
      <dc:creator>l.virone</dc:creator>
      <dc:date>2023-02-23T15:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11776641#M40449</link>
      <description>&lt;P&gt;Wow, thank you very much for the interesting suggestion. Do you use a model line or a detail line? Could you share a bit more of the code? This is an interesting approach to creating transient graphics. Other approaches use the&amp;nbsp; IDirectContext3DServer functionality or the temporary InCanvas graphics API:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2020/10/onbox-directcontext-jig-and-no-cdn.html" target="_blank"&gt;Onbox, DirectContext Jig and No CDN&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2021/01/transient-graphics-humane-ai-basic-income-and-lockdown.html" target="_blank"&gt;Transient Graphics, Humane AI, BI and Lockdown&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2021/05/flip-mirror-transform-and-transient-graphics.html" target="_blank"&gt;Flip, Mirror, Transform and Transient Graphics&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:14:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11776641#M40449</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-02-23T17:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11778165#M40450</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't use it to create a line, but this trick will work with anything. I's like creating elements each mouse movement, refresh, delete the created elements and replace them with new ones. It can technically works with anything, model or detail elements and it's easy to implement because you just need to call the two methods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool done = false;
List&amp;lt;ElementId&amp;gt; temp = new List&amp;lt;ElementId&amp;gt;();

While(!done)
{
    doc.Delete(temp);
    temp = new List&amp;lt;ElementId&amp;gt;(); //prevent try to delete elements previously deleted
    //Create your temp elements and put their IDs in "temp"
    //Don't forget to set "done" at "True" when the user has finished
    doc.regenerate();
    uidoc.RefreshActiveView();
    Thread.Sleep(500); //You can change the amount of refresh time (milliseconds)
}

//Your final elements are in "temp"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: "Thread.Sleep()" works fine, but I prefer to use events to choose when refresh the result so I have more control and I don't reload if the user didn't do anything.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 14:22:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11778165#M40450</guid>
      <dc:creator>l.virone</dc:creator>
      <dc:date>2023-03-08T14:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803236#M40451</link>
      <description>&lt;P&gt;Thank you for your nice explanation. Shared it on the blog:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2023/03/lookup-ideas-jigs-and-acc-docs-access.html#3" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2023/03/lookup-ideas-jigs-and-acc-docs-access.html#3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 05:02:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803236#M40451</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-03-07T05:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803459#M40452</link>
      <description>&lt;P&gt;hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm happy for my first publication in your blog!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your information, I used this method to allow my colleagues to print quickly at different scales and formats in a dynamic way. For this I temporarily drew a titleblock (using DetailLine and Text) with the project information, then I exported to PDF, and finally I never committed the transaction. It's a lot more complex than one signle line, but thanks this method works with any Revit element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Virone Lorenzo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 07:41:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803459#M40452</guid>
      <dc:creator>l.virone</dc:creator>
      <dc:date>2023-03-07T07:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803701#M40453</link>
      <description>&lt;P&gt;It can be work with DirectShape &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using Line = Autodesk.Revit.DB.Line;
using Point = Autodesk.Revit.DB.Point;
var Doc = commandData.Application.ActiveUIDocument.Document;
using TransactionGroup trang = new TransactionGroup(Doc, "test");
        trang.Start();
        XYZ a = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
        SetPoint(a);
        XYZ b = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
        SetPoint(b);
        SetLine(a,b);
        XYZ p1 = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
        SetPoint(p1);
        XYZ p2 = UIDoc.Selection.PickPoint(ObjectSnapTypes.None);
        SetPoint(p2);
        bool isSamSide = IsSamSide(p1, p2, a, b);
        MessageBox.Show(isSamSide.ToString());
        trang.Assimilate();
// visualize a point        
void SetPoint(XYZ xyz)
        {
            using (Transaction tran = new Transaction(Doc, "Add point"))
            {
                tran.Start();
                Point point1 = Point.Create(xyz);
                DirectShape ds =
                    DirectShape.CreateElement(Doc, new ElementId(BuiltInCategory.OST_GenericModel));
                ds.SetShape(new List&amp;lt;GeometryObject&amp;gt;() {point1});
                tran.Commit();
            }
        }
// visualize a line
void SetLine(XYZ x1,XYZ x2)
{
    using (Transaction tran = new Transaction(Doc, "Add line"))
    {
        tran.Start();
        Line line = Line.CreateBound(x1, x2);
        DirectShape ds =
            DirectShape.CreateElement(Doc, new ElementId(BuiltInCategory.OST_GenericModel));
        ds.SetShape(new List&amp;lt;GeometryObject&amp;gt;() {line});
        tran.Commit();
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChuongHo_0-1678182712128.gif" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1185479i73FE8B933A8E9B4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChuongHo_0-1678182712128.gif" alt="ChuongHo_0-1678182712128.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 09:52:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803701#M40453</guid>
      <dc:creator>Chuong.Ho</dc:creator>
      <dc:date>2023-03-07T09:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803833#M40454</link>
      <description>&lt;P&gt;Hi&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6961077"&gt;@Chuong.Ho&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, but I think your method only works with simple geometric shapes, am I wrong ? Can your method be used to create elements like Text, Wall, Dimension, etc. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 10:55:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11803833#M40454</guid>
      <dc:creator>l.virone</dc:creator>
      <dc:date>2023-03-07T10:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11804150#M40455</link>
      <description>&lt;P&gt;Brilliant! Added that as well! Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 13:30:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11804150#M40455</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-03-07T13:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11919165#M40456</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6961077"&gt;@Chuong.Ho&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Just wondering if you wouldn't mind sharing the isSamSide method?&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9528713"&gt;@l.virone&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this constant updating with the line make the Element ID climb during use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 01:37:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11919165#M40456</guid>
      <dc:creator>BHamlet</dc:creator>
      <dc:date>2023-04-25T01:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11922946#M40457</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1228146"&gt;@BHamlet&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right, one solution I think to prevent anything wrong is to divide the problem into 2 transactions :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First one to view things, this transaction will never be committed.&lt;/LI&gt;&lt;LI&gt;Second one to create the Elements which need to stay into the model (will be committed).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;But it seems the Elements created but never commited in the first transaction have increased the ElementId value &lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;... I don't know what happen if a Revit model reach the max Integer value and if Autodesk have a way to prevent problems. However, the int 32 limit is 2,147,483,647 and 64 limit is 9,223,372,036,854,775,807 so with Int64 we have some space to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT :&lt;/STRONG&gt; A solution which works is to create one line and update the coordinate of it's points using the same view update method. You can edit the geometry of an existing DetailLine or ModelLine like this : myDetaiLine.GeometryCurve = Line.CreateBound(new XYZ(1,0,0), new XYZ(0,1,0));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My solution is to see the "Element ghost" while interacting but take care using it. The DirectShape method prevent the ElementId increase BUT it'll not allow you to see the "line ghost" while moving your mouse. Differents methods with differents results and problems, it depends of what you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1228146"&gt;@BHamlet&lt;/a&gt; for your thought !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;maybe you should add this warning in your blog. I don't know if ElementId are Int64 in the 2024 API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can check those 2 links to know more about ElementId size limit in Revit :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/is-there-a-maximum-integer-value-of-an-element-id-in-revit/td-p/9747220" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/revit-api-forum/is-there-a-maximum-integer-value-of-an-element-id-in-revit/td-p/9747220&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2022/11/64-bit-element-ids-maybe.html" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2022/11/64-bit-element-ids-maybe.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 12:08:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11922946#M40457</guid>
      <dc:creator>l.virone</dc:creator>
      <dc:date>2023-04-26T12:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11922998#M40458</link>
      <description>&lt;P&gt;This is method issamside :&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;bool IsSamSide(XYZ p1, XYZ p2, XYZ a, XYZ b)
    {
        XYZ cp1 = (p1 - a).CrossProduct(b - a);
        XYZ cp2 = (p2 - a).CrossProduct(b - a);
        return cp1.DotProduct(cp2) &amp;gt;= 0;
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Apr 2023 12:00:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11922998#M40458</guid>
      <dc:creator>Chuong.Ho</dc:creator>
      <dc:date>2023-04-26T12:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11923016#M40459</link>
      <description>&lt;P&gt;The What's New in the Revit 2024 API document includes the official statement about 64 bit element ids in Revit 2024:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2023/04/whats-new-in-the-revit-2024-api.html#4.1.2" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2023/04/whats-new-in-the-revit-2024-api.html#4.1.2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I totally agree that it is better to try to reuse your transient geometry if possible rather than recreating it from scratch and consuming element ids for nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 12:08:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11923016#M40459</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-04-26T12:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11923088#M40460</link>
      <description>&lt;P&gt;Interesting observation on consuming the element id space even when the transaction is not committed. I &lt;A href="https://autodesk.slack.com/archives/C0SR6NAP8/p1682512568340939" target="_blank"&gt;asked&lt;/A&gt; the development team for their thoughts on that for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 12:38:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/11923088#M40460</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-04-26T12:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: DRAW LINE VISIBLE ON SCREEN</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/12259130#M40461</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I almost got the solution for you i think with the help of "DirectContext3DService and the "DuplicateGraphics" SDK sample. The only thing i'm not happy with is that the first point is picked with "uidoc.Selection.PickPoint("Pick First Point:")" So you have the Revit Snap options but the second point is with a custom made "Click" code as you can see below. It would be nicer if the second point also can be done with a&amp;nbsp;"uidoc.Selection.PickPoint("Pick Second Point:")"&amp;nbsp; but if you use that the "transient" line doesn't update anymore in the while loop. Maybe&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp; or&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6961077"&gt;@Chuong.Ho&lt;/a&gt;&amp;nbsp;got a solution to make this last step work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#region Namespaces
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using Autodesk.Revit.UI.Events;
using Autodesk.Revit.DB.ExternalService;
using System.Runtime.InteropServices;
using PointW = System.Drawing.Point;
using windowsForms = System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Windows.Interop;
using System.ComponentModel;
using System.Reflection;


#endregion

namespace SharpLion_BIM_Toolbar
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class DuplicateGraphics : IExternalCommand
    {
        List&amp;lt;RevitElementDrawingServer&amp;gt; m_servers;
        HashSet&amp;lt;Document&amp;gt; m_documents;
        UIDocument m_UIdoc;
        UIApplication m_uiApp;

        private IntPtr rWindow = IntPtr.Zero;
        XYZ m_P1;
        private List&amp;lt;Line&amp;gt; LineList = new List&amp;lt;Line&amp;gt;();

        public Result Execute(
        ExternalCommandData commandData,
        ref string message,
        ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

            m_servers = new List&amp;lt;RevitElementDrawingServer&amp;gt;();
            m_documents = new HashSet&amp;lt;Document&amp;gt;();
            m_UIdoc = uidoc;
            m_uiApp = uiapp;
                        
            this.rWindow = GetActiveWindow();
            
            try
            {                
                m_P1 = uidoc.Selection.PickPoint("Pick First Point:");

            }
            catch (Exception ex)
            {
                
            }

            try
            {
                bool done = false;

                while (!done) 
                {
                    windowsForms.Cursor.Current = windowsForms.Cursors.Cross;

                    AddRevitElementServer(m_UIdoc, m_P1);

                    var revitHandle = Process
                   .GetCurrentProcess().MainWindowHandle;

                    SetStatusText(revitHandle, "Pick Last Point:");

                    if (GetLeftMousePressed()|| GetEscPressed())
                    {
                        i++;

                        if (i == 2)
                        {
                            i = 0;

                            done = true;

                            unregisterServers(doc, true);
                        }
                    }
                }                
            }
            catch { }         

            return Result.Succeeded;
        }

        private int i = 0;

        public void AddRevitElementServer(UIDocument uidoc,XYZ p1)
        { 
            LineList.Clear();           

            XYZ p2 = GetMousePosition();

            if (p1.DistanceTo(p2) &amp;gt; 0.01)
            {
                LineList.Add(Line.CreateBound(p1, p2));
               
                m_uiApp.ActiveUIDocument.RefreshActiveView();

               // XYZ p3 = m_UIdoc.Selection.PickPoint("Pick Last Point:");

                // Create the server and register it with the DirectContext3D service.
                ExternalService directContext3DService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.DirectContext3DService);
                RevitElementDrawingServer revitServer = new RevitElementDrawingServer(uidoc, LineList);
                directContext3DService.AddServer(revitServer);
                m_servers.Add(revitServer);

                MultiServerService msDirectContext3DService = directContext3DService as MultiServerService;

                IList&amp;lt;Guid&amp;gt; serverIds = msDirectContext3DService.GetActiveServerIds();

                serverIds.Add(revitServer.GetServerId());

                // Add the new server to the list of active servers.
                msDirectContext3DService.SetActiveServers(serverIds);

                m_documents.Add(uidoc.Document);
                uidoc.UpdateAllOpenViews();
           }
        }

        public void unregisterServers(Document document, bool updateViews)
        {            
            ExternalServiceId externalDrawerServiceId = ExternalServices.BuiltInExternalServices.DirectContext3DService;
            var externalDrawerService = ExternalServiceRegistry.GetService(externalDrawerServiceId) as MultiServerService;
            if (externalDrawerService == null)
                return;

            foreach (var registeredServerId in externalDrawerService.GetRegisteredServerIds())
            {
                var externalDrawServer = externalDrawerService.GetServer(registeredServerId) as RevitElementDrawingServer;
                if (externalDrawServer == null)
                    continue;
                if (document != null &amp;amp;&amp;amp; !document.Equals(externalDrawServer.Document))
                    continue;
                externalDrawerService.RemoveServer(registeredServerId);
            }

            if (document != null)
            {
                m_servers.RemoveAll(server =&amp;gt; document.Equals(server.Document));

                if (updateViews)
                {
                    UIDocument uidoc = new UIDocument(document);
                    uidoc.UpdateAllOpenViews();
                }

                m_documents.Remove(document);
            }
            else
            {
                m_servers.Clear();

                if (updateViews)
                    foreach (var doc in m_documents)
                    {
                        UIDocument uidoc = new UIDocument(doc);
                        uidoc.UpdateAllOpenViews();
                    }

                m_documents.Clear();
            }
        }


        private XYZ GetMousePosition()
        {
            UIView uiview = GetActiveUiView(m_UIdoc);

            Rectangle rect = uiview.GetWindowRectangle();

            PointW p = windowsForms.Cursor.Position;

            double dx = (double)(p.X - rect.Left)
              / (rect.Right - rect.Left);

            double dy = (double)(p.Y - rect.Bottom)
              / (rect.Top - rect.Bottom);

            IList&amp;lt;XYZ&amp;gt; corners = uiview.GetZoomCorners();
            XYZ a = corners[0];
            XYZ b = corners[1];
            XYZ v = b - a;

            XYZ q = a
              + dx * v.X * XYZ.BasisX
              + dy * v.Y * XYZ.BasisY;

            return q;
        }

        static UIView GetActiveUiView(UIDocument uidoc)
        {
            Document doc = uidoc.Document;
            View view = doc.ActiveView;
            IList&amp;lt;UIView&amp;gt; uiviews = uidoc.GetOpenUIViews();
            UIView uiview = null;

            foreach (UIView uv in uiviews)
            {
                if (uv.ViewId.Equals(view.Id))
                {
                    uiview = uv;
                    break;
                }
            }
            return uiview;
        }


        [DllImport("user32.dll")]
        static extern short GetAsyncKeyState(int VirtualKeyPressed);

        public static bool GetLeftMousePressed()
        {
            if (GetAsyncKeyState(0x01) == 0)
                return false;
            else
                return true;
        }

        public static bool GetEscPressed()
        {
            if (GetAsyncKeyState(0x1B) == 0)
                return false;
            else
                return true;
        }        

        //Set custom bottom text
        [DllImport("user32.dll")]
        static extern IntPtr GetActiveWindow();

        [DllImport("user32.dll",
            SetLastError = true,
            CharSet = CharSet.Auto)]
        private static extern int SetWindowText(
            IntPtr hWnd,
            string lpString);

        [DllImport("user32.dll",
            SetLastError = true)]
        private static extern IntPtr FindWindowEx(
            IntPtr hwndParent,
            IntPtr hwndChildAfter,
            string lpszClass,
            string lpszWindow);

        public static void SetStatusText(
            IntPtr mainWindow,
            string text)
        {
            var statusBar = FindWindowEx(
                mainWindow, IntPtr.Zero,
                "msctls_statusbar32", "");

            if (statusBar != IntPtr.Zero) SetWindowText(statusBar, text);
        }
    }
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And Second Class:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.ExternalService;
using Autodesk.Revit.DB.DirectContext3D;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace SharpLion_BIM_Toolbar
{
    class RevitElementDrawingServer : IDirectContext3DServer
    {
        public RevitElementDrawingServer(UIDocument uiDoc, List&amp;lt;Line&amp;gt; line)
        {
            m_guid = Guid.NewGuid();

            m_uiDocument = uiDoc;
            // m_element = elem;
            m_lines = line;
        }

        public System.Guid GetServerId() { return m_guid; }
        public System.String GetVendorId() { return "ADSK"; }
        public ExternalServiceId GetServiceId() { return ExternalServices.BuiltInExternalServices.DirectContext3DService; }
        public System.String GetName() { return "Revit Element Drawing Server"; }
        public System.String GetDescription() { return "Duplicates graphics from a Revit element."; }

        // Corresponds to functionality that is not used in this sample.
        public System.String GetApplicationId() { return ""; }

        // Corresponds to functionality that is not used in this sample.
        public System.String GetSourceId() { return ""; }

        // Corresponds to functionality that is not used in this sample.
        public bool UsesHandles() { return false; }

        public bool CanExecute(Autodesk.Revit.DB.View view)
        {
            return true;
            //var doc = view.Document;
            //return doc.Equals(this.Document);
        }

        // Reports a bounding box of the geometry that this server submits for drawing.
        public Outline GetBoundingBox(Autodesk.Revit.DB.View view)
        {
            return null;
        }

        // Indicates that this server will submit geometry during the rendering pass for transparent geometry.
        public bool UseInTransparentPass(Autodesk.Revit.DB.View view) { return true; }

        // Submits the geometry for rendering.
        public void RenderScene(Autodesk.Revit.DB.View view, DisplayStyle displayStyle)
        {
            try
            {
                // Populate geometry buffers if they are not initialized or need updating.
                if (m_nonTransparentFaceBufferStorage == null || m_nonTransparentFaceBufferStorage.needsUpdate(displayStyle) ||
                    m_transparentFaceBufferStorage == null || m_transparentFaceBufferStorage.needsUpdate(displayStyle) ||
                    m_edgeBufferStorage == null || m_edgeBufferStorage.needsUpdate(displayStyle))
                {

                    CreateBufferStorageForElement(m_lines, displayStyle);
                }  

                // Conditionally submit line segment primitives.
                if (displayStyle != DisplayStyle.Shading &amp;amp;&amp;amp;
                    m_edgeBufferStorage.PrimitiveCount &amp;gt; 0)
                    DrawContext.FlushBuffer(m_edgeBufferStorage.VertexBuffer,
                                            m_edgeBufferStorage.VertexBufferCount,
                                            m_edgeBufferStorage.IndexBuffer,
                                            m_edgeBufferStorage.IndexBufferCount,
                                            m_edgeBufferStorage.VertexFormat,
                                            m_edgeBufferStorage.EffectInstance, PrimitiveType.LineList, 0,
                                            m_edgeBufferStorage.PrimitiveCount);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }

        // Initialize and populate buffers that hold graphics primitives, set up related parameters that are needed for drawing.
        private void CreateBufferStorageForElement(List&amp;lt;Line&amp;gt; transientLines, DisplayStyle displayStyle)
        {
            m_edgeBufferStorage = new RenderingPassBufferStorage(displayStyle);

            foreach (var edge in transientLines)
            {
                // if (edge.Length &amp;gt; 1e-06)
                {
                    IList&amp;lt;XYZ&amp;gt; xyzs = edge.Tessellate();

                    m_edgeBufferStorage.VertexBufferCount += xyzs.Count;
                    m_edgeBufferStorage.PrimitiveCount += xyzs.Count - 1;
                    m_edgeBufferStorage.EdgeXYZs.Add(xyzs);
                }
            }

            ProcessEdges(m_edgeBufferStorage);
        }
        

        // A helper function, analogous to ProcessFaces.
        private void ProcessEdges(RenderingPassBufferStorage bufferStorage)
        {
            List&amp;lt;IList&amp;lt;XYZ&amp;gt;&amp;gt; edges = bufferStorage.EdgeXYZs;
            if (edges.Count == 0)
                return;

            // Edges are encoded as line segment primitives whose vertices contain only position information.
            bufferStorage.FormatBits = VertexFormatBits.Position;

            int edgeVertexBufferSizeInFloats = VertexPosition.GetSizeInFloats() * bufferStorage.VertexBufferCount;
            List&amp;lt;int&amp;gt; numVerticesInEdgesBefore = new List&amp;lt;int&amp;gt;();
            numVerticesInEdgesBefore.Add(0);

            bufferStorage.VertexBuffer = new VertexBuffer(edgeVertexBufferSizeInFloats);
            bufferStorage.VertexBuffer.Map(edgeVertexBufferSizeInFloats);
            {
                VertexStreamPosition vertexStream = bufferStorage.VertexBuffer.GetVertexStreamPosition();
                foreach (IList&amp;lt;XYZ&amp;gt; xyzs in edges)
                {
                    foreach (XYZ vertex in xyzs)
                    {
                        vertexStream.AddVertex(new VertexPosition(vertex));
                    }

                    numVerticesInEdgesBefore.Add(numVerticesInEdgesBefore.Last() + xyzs.Count);
                }
            }
            bufferStorage.VertexBuffer.Unmap();

            int edgeNumber = 0;
            bufferStorage.IndexBufferCount = bufferStorage.PrimitiveCount * IndexLine.GetSizeInShortInts();
            int indexBufferSizeInShortInts = 1 * bufferStorage.IndexBufferCount;
            bufferStorage.IndexBuffer = new IndexBuffer(indexBufferSizeInShortInts);
            bufferStorage.IndexBuffer.Map(indexBufferSizeInShortInts);
            {
                IndexStreamLine indexStream = bufferStorage.IndexBuffer.GetIndexStreamLine();
                foreach (IList&amp;lt;XYZ&amp;gt; xyzs in edges)
                {
                    int startIndex = numVerticesInEdgesBefore[edgeNumber];
                    for (int i = 1; i &amp;lt; xyzs.Count; i++)
                    {
                        // Add two indices that define a line segment.
                        indexStream.AddLine(new IndexLine((int)(startIndex + i - 1),
                                                          (int)(startIndex + i)));
                    }
                    edgeNumber++;
                }
            }
            bufferStorage.IndexBuffer.Unmap();


            bufferStorage.VertexFormat = new VertexFormat(bufferStorage.FormatBits);
            bufferStorage.EffectInstance = new EffectInstance(bufferStorage.FormatBits);
        }

        public Document Document
        {
            get { return (m_uiDocument != null) ? m_uiDocument.Document : null; }
        }

        private Guid m_guid;

        private Element m_element;
        private List&amp;lt;Line&amp;gt; m_lines;
        private XYZ m_offset;
        private UIDocument m_uiDocument;

        private RenderingPassBufferStorage m_nonTransparentFaceBufferStorage;
        private RenderingPassBufferStorage m_transparentFaceBufferStorage;
        private RenderingPassBufferStorage m_edgeBufferStorage;

        #region Helper classes

        
        // A class that brings together all the data and rendering parameters that are needed to draw one sequence of primitives (e.g., triangles)
        // with the same format and appearance.
        class RenderingPassBufferStorage
        {
            public RenderingPassBufferStorage(DisplayStyle displayStyle)
            {
                DisplayStyle = displayStyle;
                EdgeXYZs = new List&amp;lt;IList&amp;lt;XYZ&amp;gt;&amp;gt;();
            }

            public bool needsUpdate(DisplayStyle newDisplayStyle)
            {
                if (newDisplayStyle != DisplayStyle)
                    return true;

                if (PrimitiveCount &amp;gt; 0)
                    if (VertexBuffer == null || !VertexBuffer.IsValid() ||
                        IndexBuffer == null || !IndexBuffer.IsValid() ||
                        VertexFormat == null || !VertexFormat.IsValid() ||
                        EffectInstance == null || !EffectInstance.IsValid())
                        return true;

                return false;
            }

            public DisplayStyle DisplayStyle { get; set; }

            public VertexFormatBits FormatBits { get; set; }

            public List&amp;lt;IList&amp;lt;XYZ&amp;gt;&amp;gt; EdgeXYZs { get; set; }

            public int PrimitiveCount { get; set; }
            public int VertexBufferCount { get; set; }
            public int IndexBufferCount { get; set; }
            public VertexBuffer VertexBuffer { get; set; }
            public IndexBuffer IndexBuffer { get; set; }
            public VertexFormat VertexFormat { get; set; }
            public EffectInstance EffectInstance { get; set; }
        }

        #endregion
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 13:35:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/draw-line-visible-on-screen/m-p/12259130#M40461</guid>
      <dc:creator>vanlion</dc:creator>
      <dc:date>2023-09-22T13:35:33Z</dc:date>
    </item>
  </channel>
</rss>

