Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DRAW LINE VISIBLE ON SCREEN

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
rodrigohbm
2827 Views, 16 Replies

DRAW LINE VISIBLE ON SCREEN

is there any way to create a line
when the first point appears
then click on the second point
I have the following code
with which I **** the first point and then the second
and the line is drawn.

 

  Public Sub CrealineaPickpoint()
      Dim doc As Document = Me.Application.ActiveUIDocument.Document
      Dim uidoc As UIDocument = Me.Application.ActiveUIDocument
      
      Dim startPoint As XYZ = uidoc.Selection.PickPoint("PickPoint One")
      Dim directionPt As XYZ = uidoc.Selection.PickPoint("PickPoint Two")      
   
        Dim detailline As DetailLine        
        Dim t As Transaction = New Transaction(doc, "Create Detail Line")
        If True Then
            t.Start()
            Dim line As Line = Line.CreateBound(startPoint, directionPt)
            detailline = TryCast(doc.Create.NewDetailCurve(doc.ActiveView, line), DetailLine)
            t.Commit()
        End If
        TaskDialog.Show("Length", detailline.id.tostring)     
     End Sub  

 

image.png

 

the idea is to create the line
as the detail line command

 

image.png

 

in this way the user can interact
with the application to see the direction of the line

 

I was looking at information in several places
even in SDK but nothing appears

I appreciate the help.

regards

 

16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: rodrigohbm

What you are asking for is called a 'rubber band' or 'rubber banding'.

 

Nope, sorry, afaik the Revit API does currently not provide access to this functionality.

 

You can raise a wish for it in the Revit Idea Station, if you like, or vote for an existing wish, if one exists.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17
rodrigohbm
in reply to: jeremytammik

Hello
analyzing the subject
you can take care of the family  Detail Item line based
since it is requesting the insertion point
and then the second point to end

 

there will be some example using
the family  Detail Item line based

regards

Message 4 of 17
l.virone
in reply to: rodrigohbm

Hi,

 

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.

 

uidoc.RefreshActiveView();
doc.Regenerate();

 

Good Luck

Message 5 of 17
jeremy_tammik
in reply to: l.virone

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  IDirectContext3DServer functionality or the temporary InCanvas graphics API:

   

   

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 6 of 17
l.virone
in reply to: jeremy_tammik

Hi @jeremy_tammik,

 

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.

 

It looks like:

 

bool done = false;
List<ElementId> temp = new List<ElementId>();

While(!done)
{
    doc.Delete(temp);
    temp = new List<ElementId>(); //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"

 

 

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.

Message 7 of 17
jeremy_tammik
in reply to: l.virone

Thank you for your nice explanation. Shared it on the blog:

  

https://thebuildingcoder.typepad.com/blog/2023/03/lookup-ideas-jigs-and-acc-docs-access.html#3

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 8 of 17
l.virone
in reply to: jeremy_tammik

hi @jeremy_tammik 

 

I'm happy for my first publication in your blog!

 

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.

 

Best regards,

Virone Lorenzo

 

 

 

Message 9 of 17
Chuong.Ho
in reply to: rodrigohbm

It can be work with DirectShape

 

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<GeometryObject>() {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<GeometryObject>() {line});
        tran.Commit();
    }
}

 

ChuongHo_0-1678182712128.gif

 

 

Chuong Ho

EESignature

Message 10 of 17
l.virone
in reply to: Chuong.Ho

Hi@Chuong.Ho 

 

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. ?

 

Thank you

Message 11 of 17
jeremy_tammik
in reply to: Chuong.Ho

Brilliant! Added that as well! Thank you!

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 12 of 17
BHamlet
in reply to: Chuong.Ho

@Chuong.Ho

Just wondering if you wouldn't mind sharing the isSamSide method?

@l.virone 

Does this constant updating with the line make the Element ID climb during use?

 

Bob

Message 13 of 17
l.virone
in reply to: BHamlet

Hello @BHamlet,

 

You are right, one solution I think to prevent anything wrong is to divide the problem into 2 transactions :

  1. First one to view things, this transaction will never be committed.
  2. Second one to create the Elements which need to stay into the model (will be committed).

But it seems the Elements created but never commited in the first transaction have increased the ElementId value 😢... 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. 

 

EDIT : 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));

 

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.

 

Thanks @BHamlet for your thought !

 

@jeremy_tammikmaybe you should add this warning in your blog. I don't know if ElementId are Int64 in the 2024 API.

 

 

 

 

You can check those 2 links to know more about ElementId size limit in Revit :

 

https://forums.autodesk.com/t5/revit-api-forum/is-there-a-maximum-integer-value-of-an-element-id-in-...

 

https://thebuildingcoder.typepad.com/blog/2022/11/64-bit-element-ids-maybe.html

Message 14 of 17
Chuong.Ho
in reply to: BHamlet

This is method issamside :

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) >= 0;
    }

Chuong Ho

EESignature

Message 15 of 17
jeremy_tammik
in reply to: l.virone

The What's New in the Revit 2024 API document includes the official statement about 64 bit element ids in Revit 2024:

  

https://thebuildingcoder.typepad.com/blog/2023/04/whats-new-in-the-revit-2024-api.html#4.1.2

  

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.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 16 of 17
jeremy_tammik
in reply to: l.virone

Interesting observation on consuming the element id space even when the transaction is not committed. I asked the development team for their thoughts on that for you.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 17 of 17
vanlion
in reply to: jeremy_tammik

Hi,

 

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 "uidoc.Selection.PickPoint("Pick Second Point:")"  but if you use that the "transient" line doesn't update anymore in the while loop. Maybe @jeremy_tammik  or @Chuong.Ho got a solution to make this last step work?

 

#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<RevitElementDrawingServer> m_servers;
        HashSet<Document> m_documents;
        UIDocument m_UIdoc;
        UIApplication m_uiApp;

        private IntPtr rWindow = IntPtr.Zero;
        XYZ m_P1;
        private List<Line> LineList = new List<Line>();

        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<RevitElementDrawingServer>();
            m_documents = new HashSet<Document>();
            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) > 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<Guid> 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 && !document.Equals(externalDrawServer.Document))
                    continue;
                externalDrawerService.RemoveServer(registeredServerId);
            }

            if (document != null)
            {
                m_servers.RemoveAll(server => 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<XYZ> 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<UIView> 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);
        }
    }
}

 

And Second Class:

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<Line> 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 &&
                    m_edgeBufferStorage.PrimitiveCount > 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<Line> transientLines, DisplayStyle displayStyle)
        {
            m_edgeBufferStorage = new RenderingPassBufferStorage(displayStyle);

            foreach (var edge in transientLines)
            {
                // if (edge.Length > 1e-06)
                {
                    IList<XYZ> 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<IList<XYZ>> 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<int> numVerticesInEdgesBefore = new List<int>();
            numVerticesInEdgesBefore.Add(0);

            bufferStorage.VertexBuffer = new VertexBuffer(edgeVertexBufferSizeInFloats);
            bufferStorage.VertexBuffer.Map(edgeVertexBufferSizeInFloats);
            {
                VertexStreamPosition vertexStream = bufferStorage.VertexBuffer.GetVertexStreamPosition();
                foreach (IList<XYZ> 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<XYZ> xyzs in edges)
                {
                    int startIndex = numVerticesInEdgesBefore[edgeNumber];
                    for (int i = 1; i < 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<Line> 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<IList<XYZ>>();
            }

            public bool needsUpdate(DisplayStyle newDisplayStyle)
            {
                if (newDisplayStyle != DisplayStyle)
                    return true;

                if (PrimitiveCount > 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<IList<XYZ>> 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
    }
}

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community