DISTANCE BETWEEN ELEMENTS

DISTANCE BETWEEN ELEMENTS

rodrigohbm
Advocate Advocate
2,532 Views
5 Replies
Message 1 of 6

DISTANCE BETWEEN ELEMENTS

rodrigohbm
Advocate
Advocate

Hello friends
I write to ask a question
it is possible through APIs to find
the distance between two elements
and get characteristics of
Selected items such as width and height?

attached reference image.

 

I appreciate the help.

 

regards

 

image.png

 

 

 

0 Likes
2,533 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Yes.

 

You seem to be new to the Revit API, so first of all I welcome you to this discussion group.

 

Before anything else, please work through the getting started material:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will answer these questions of yours, and many more besides.

  

Secondly, obviously, please always search for existing answers before raising new questions here.

  

Many Revit element properties such and with are height are available through the parameters that you see in the user interface in the element property panel.

 

You should install RevitLookup to explore the Revit database, its elements, their properties and relationships interactively through the API:

 

https://github.com/jeremytammik/RevitLookup

 

You can also query an element for its geometry and then calculate these properties yourself from that.

 

The distance could also be determined from the two elements' geometry, and in other ways as well.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 6

rodrigohbm
Advocate
Advocate

thanks for your reply.
but I have already reviewed its start link several times
but the truth that shows nothing technical just words
I'm really sorry that a forum of this magnitude
only resolved by users and the help of autodesk staff
does not contribute much to solve simple queries
Although the SDK is very helpful, it does not contribute to the development of simple questions.
It is not the first time that I have come across this answer. I am very sorry for this situation.
regards

0 Likes
Message 4 of 6

BenoitE&A
Collaborator
Collaborator

Hi Roberto,

Correct me if I'm wrong but it looks like you are working with Walls and only walls. The solution would clearly be different if you would work with, say, Lightning Element and Wall.

Walls are determined mainly by their LocationCurve (myWall.Location as LocationCurve, and situated at the middle of the wall thickness) and their Width (myWall.WallType.Width). So you can retrieve the locationCurve of each wall. Then a simple solution would be to project both ends of wall1 on wall2, then project again both solutions on wall1 and take the shorter. The syntax is locCurve.Project(myPoint). Then take care of the thickness of the wall.

But if your walls are not facing, you will have a problem (your projection will find the shortest distance between the 2 segments that are your LocationCurve, not the distance between the 2 infinite lines that contain them. A solution could be to create an infinite Line containing each wall's LocationCurve (Line.CreateUnbound) and project one point of the first on the second, after checking that they are parallel. And then take accound of wall's thickness.

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 5 of 6

rodrigohbm
Advocate
Advocate

thanks for your reply
but in general they are different elements
for this case, wall (element 1) and beam (element 2) are combined

 

I will test your indication.


regards

0 Likes
Message 6 of 6

BenoitE&A
Collaborator
Collaborator

It works as long as both of your elements have a CurveLocation as Location. If it is a Point, it is much easier...


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes