Draw few thousands of lines quickly

Draw few thousands of lines quickly

Anonymous
Not applicable
1,316 Views
9 Replies
Message 1 of 10

Draw few thousands of lines quickly

Anonymous
Not applicable

I have been trying to draw few thousands of linea at once. But, using CreateModelLine is too slow. It takes more than a minute to load up all the lines.

 

I tried using PointCloud too by putting bunch of points in between to make it appear like a line. But, it exceeds the maximum number of Points you can draw using a PointCloud.

 

Is there any way where I can draw a legit line time efficiently?

I want to draw few thousands of lines within few seconds.

0 Likes
1,317 Views
9 Replies
Replies (9)
Message 2 of 10

jeremytammik
Autodesk
Autodesk

On one hand, you must be aware that Revit is an end user tool, designed with an end user interface to be driven by a human end user.

 

Therefore, it is not designed for the task you describe.

 

Are you using the right tool for the job?

 

What are you trying to achieve?

 

That said, I do not see why it should not be possible to draw a few thousand lines within a second or two.

 

Are they all in one single 2D plane, or are they all over the 3D space?

 

If they are in one single plane, you can place them all on one single sketch plane and save a lot of overhead by doing so.

 

In any case, if you pack the entire creation of all those lines into one single transaction, it should not take too long.

 



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

0 Likes
Message 3 of 10

Anonymous
Not applicable

So, I have a 3D model of a building, and I have a database where I've an Edge tables, each edges have start point and the end point. These edges are not associated to any element, they are individual.

 

What I am trying to do it, when a user clicks a button, I want to highlight all the edges form the DB and highlight them in the model. The whole DB has more than 100,000 edges. So, is it possible to do this with Revit API? and is Revit made for this?

 

These edges are all over the 3D model, so I can't keep one single sketchplane. I've to create a new sketch plane every time. Maybe that's why it's taking too long.

 

 

 

0 Likes
Message 4 of 10

TripleM-Dev.net
Advisor
Advisor

Missing some details regarding the code used.

As Jeremy suggested try to reduce the amount of created sketchplanes; sort the edges first by direction/position and draw all the line in order of the sketchplane they need. (Did a Test arraying 200 lines 200x, also takes a minute or so to generate, so not much optimalization possible i think)

 

Said that, does the DB with edges change or is it static (where does it come from, purpose ed).

Do the lines stay in the model (transaction committed / RolledBack)

Why not generate the line in a empty revit project file and link it, then show when needed

Or a Family with the lines and load/show when needed (loading the family also takes a minute or two, so it already should be loaded in the project to display fast)

 

Also I don't think Revit is meant to use 2D lines to create a WireModel, as it being a 3D modelling software.

Message 5 of 10

jeremytammik
Autodesk
Autodesk

Sounds tricky indeed, and possibly doable.

 

Creating model lines might make sense.

 

It would be nice if you could just highlight the existing edges. You can highlight existing elements by setting their element ids in the current selection class using Selection.SetElementIds:

 

https://www.revitapidocs.com/2020/cf8c11bb-f0c7-6d50-cbdf-41d0a010d9d6.htm

 

Unfortunately, that will only highlight the entire element, not a subelement such as an edge.

 

For creating the model lines, I would suggest that you include some benchmarking in your code to find out how much time is required for each of the steps.

 

If the creation of sketch planes consumes a significant amount of time, you can probably cut down on that quite substantially by implementing a global sketch plane lookup dictionary like this:

 

  • Implement a comparison operator for 2D planes in 3D space. Such a comparison operator can be implemented taking into account the X, Y and Z of the normal vector and the signed distance D of the plane from the origin.
  • For each sketch plane you create, assign it a name or other identifying characteristic that will enable you to retrieve it again later so that you can clean up the model again after polluting it with all your stuff.
  • Each time you want to create a new model line, use the naming convention and the comparison operator to check whether you can reuse one of your existing sketch planes to create it on.

  

I discussed this idea somewhere sometime several years ago in the context of The Building Coder samples Creator class:

  

https://www.google.com/search?q=Creator&as_sitesearch=thebuildingcoder.typepad.com

  

I hope this is clear enough and helps you speed up your task.

  

Cheers,

  

Jeremy

   

 



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

Message 6 of 10

Anonymous
Not applicable

Thank you for the nice explanation.

 

So I temporary got it working with PointClouds.

Actually, we figured out a way to create more instance of our PointCloud engine with different inputs.

So, let's say if the limit of PointClouds is let' say x points, and right now I have 100x points to show for lines, then I am creating 100 different PointCloudInstances with different inputs. And this all is happening within 10 seconds. Because, our main concern was speed, and fast load up.

 

But, we still want to keep alternatives, too. So, now we will try drawing/importing lines with the suggestions mentioned above. 

Thank you.

 

I just want to mention that I loved working with PointClouds, I hope they don't deprecate it in the future versions of Revit.

Message 7 of 10

Kennan.Chen
Advocate
Advocate

Let's go back to what you really need.

 

Do you really need to model all those lines in Revit or you just need to see how many lines there are from your current view port.

 

If it's the former, point cloud may be the choice.

 

If it's the latter, I suggest to create a transparent mask window right upon the Revit sketch area and put a canvas in it. By reading the camera info from the current view, you can create the same coordinate system in that canvas. The last thing is to pick out a small part of the lines which are visible from the current view port and draw them on the canvas. By syncing with the current view, you can clear the canvas and draw different lines per frame. I think this can significantly boost the performance. In WPF, the Adorner is something based on similiar mechanism.

 

You can also try to replace the canvas with any 3D engine to make this happen.

Message 8 of 10

jeremytammik
Autodesk
Autodesk

Great suggestion! This sounds like an extremely elegant and performant solution that would certainly be of interest to many other add-in developers as well.

  



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

0 Likes
Message 9 of 10

Anonymous
Not applicable

It's the former case. So, I think I can go ahead with PointClouds.

I am new to Revit, so I am just curious and want to know.

Can you explain a bit more about what is a transparent mask window, its usage and how to work with it/create it, or you can also provide a link to some good documentation?

Thank You.

0 Likes
Message 10 of 10

Anonymous
Not applicable

Can you explain how can I use transparent mask window in this case, and since I do not know anything about it, can you provide some documentation/link to Getting Started guide for using transparent mask window, and adding items to it. Thank You.

0 Likes