How to get vertices of a revit edge along with unique id for each vertex?

Chintan.Shah
Participant
Participant

How to get vertices of a revit edge along with unique id for each vertex?

Chintan.Shah
Participant
Participant

Hello,

 

I am trying to query the end points i.e. vertices of an edge in revit.

 

I tried using edge.AsCurve().GetEndPoint(0/1), which is returning the correct endpoints as an object of XYZ class.

 

But I also want a unique identifier of each vertex so that I can eliminate the overlapping vertices from my processing while creating Boundary Represenation of a revit body.

 

I tried using Edge.GetHashCode() which works good for Revit Edges i.e the hash code for an edge queried from one face is same when we get the same edge in another face.

But XYZ.GetHashCode() is not returning same code for end points that are common for different edges/faces.

 

Am I querying the end points correctly?

Is there any other way to query a unique identifier for the revit vertices and even edges?

 

Thanks & Regards,

Chintan

0 Likes
Reply
Accepted solutions (1)
2,400 Views
3 Replies
Replies (3)

jeremytammik
Autodesk
Autodesk
Accepted solution
Dear Chintan,

In general, defining any kind of stable identifier for geometry that is dynamically generated and can change at any time is very hard.

In the Revit API, you can request so-called references to geometry objects. To do so, you set ComputeReferences to true when querying an element for its geometry.

These references can be converted to a stable string representation for storage and later retrieval using the Reference.ConvertToStableRepresentation method.

I suggest a much simpler approach here that may be of interest to you, creating your own key based on geometric location:

http://thebuildingcoder.typepad.com/blog/2012/03/great-ocean-road-and-creating-your-own-key.html#2

That will obviously not be stable either, but it might provide what you need.

I hope this helps.

Cheers,

Jeremy


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

Chintan.Shah
Participant
Participant

Hi Jeremy,

 

Using Dicionary for assigning unique ids to curve endpoints (XYZ) worked for me.

 

Thanks a lot!!!

 

~Chintan

0 Likes

jeremytammik
Autodesk
Autodesk

Dear Chintan,

 

Thank you for your confirmation and marking the issue as solved.

 

I recapitulate our discussion on The Building Coder for future reference:

 

http://thebuildingcoder.typepad.com/blog/2015/03/state-of-the-view-and-data-api-va3c-and-edge-ids.ht...

 

Cheers,

 

Jeremy



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

0 Likes