Discretize space or area into m*n grid

Discretize space or area into m*n grid

Anonymous
Not applicable
824 Views
4 Replies
Message 1 of 5

Discretize space or area into m*n grid

Anonymous
Not applicable

Dear all,

 

I'm doing some research on path planning and I want to discretize space or area into grids via Revit API so that path planning algorithm can be applied. In addition, certain cells of this grid can be adjusted according to some object likes walls so that these can be unwalkable. Just like the following graph, the room area is discretized and some cells which aren't walkable become black.GRID.png

 

Also, I noticed some similar function in Dynamo which is a visualized software for Revit.

In this software, by applying sepecified array of UVs, it will form a delaunay diagram of given area. In this graph, u and v are both float between 0 and 1 in the same interval to form a 20*50 metric. By taking this parameter and the surface. this software forms a dalaunay diagram.

 

Delaunary.png

 

 

 

 

So, does Revit can provide similar function to discretize area into grids via some give parameters, like UV ?

0 Likes
Accepted solutions (1)
825 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk
Accepted solution

All Revit API surfaces are parameterised using UV coordinates.

 

The Revit API provides a built-in tessellation method to triangulate a surface.

 

Delaunay triangulation is not built in to the Revit API.

 

Normally, however, you can access the source code of any Dynamo node and explore how it does its job.

 

Cheers,

 

Jeremy



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

Message 3 of 5

GZ1178
Participant
Participant

Dear Jeremytammik,

 

I'm so sorry for misusing the private message function. I will never do that again.

 

I tried to use a collection of triangles to form a polyhedron as an approximation of a very complicated solid, the triangles are collected by calling the Face.Triangluate() method of each of the solid's face. However, I found no normal information are included in the mesh triangles.

 

I tried to use the following method to recalculete the normal of a triangle 

 

var tri = mesh.get_Triangle(i);
XYZ pt0 = tri.get_Vertex(0);
XYZ pt1 = tri.get_Vertex(1);
XYZ pt2 = tri.get_Vertex(2);
XYZ vec1 = pt1 - pt0;
XYZ vec2 = pt2 - pt0;
XYZ normal1 = vec1.CrossProduct(vec2);

 

After testing on one of my revit project, I found that in this way the direction of any triangle always points outward, which is what I need. I'm wondering if Revit has taken into consideration the normal directions of the mesh triangles when desinging the API. I've learned from other book that the normals of mesh triangles are used for rendering purpose. and the way to get a vertice of a triangle in Revit API is: tri.Get_Verex(i) instead of Tri.Vertes[i], so I guess maybe something like rearranging the vertice counterclockwisely happenes in the Get_Vertex() method. I'm wondering if my guess is right.

 

Thank you so much!

 

With kind regards,

 

Zeng

 

 

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Dear Zeng,

 

Thank you for moving your query out here into the public space for all to enjoy and contribute to.

 

Orienting triangles so that their vertices are oriented counterclockwise when viewed 'from outside' the solid that they define is indeed standard practice.

 

As far as I know, there is no official guarantee nor documentation that the Revit API will always implement this.

 

Therefore, I would suggest that you add an assertion to your code to check whether it is always the case in all the models and situations of interest. 

 

I hope this helps.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 5 of 5

GZ1178
Participant
Participant

Dear Jeremy,

 

Thank you for this answer!

 

With kind regards,

 

Zeng Guo

0 Likes