Finding a line inside a family instance (in the project environment)

Finding a line inside a family instance (in the project environment)

Anonymous
Not applicable
3,178 Views
5 Replies
Message 1 of 6

Finding a line inside a family instance (in the project environment)

Anonymous
Not applicable

Hi All,

 

I have a little bit of issue with finding a model line inside a family instance. So I have created a family that contains a model line. I load it into a Revit project and I want to access the model line inside it by using API. 

I have already tried this post:

https://thebuildingcoder.typepad.com/blog/2011/08/retrieving-lines-within-a-family-instance.html

 

def model_line_extractor(list_of_elements):
     modelline_references = ReferenceArray()
     for l in list_of_elements:
           geos = l.get_Geometry(opt)
           print(geos.Objects)

 

it doesn't work. The error is GeometryInstance or GeometryElement does not have Objects attribute. So I was wondering if anyone can help me with this. 

by the way, I want to find the ''direction'' of this model line later in the project so I think accessing the family editor directly doesn't help me (I mean this post)

https://forums.autodesk.com/t5/revit-api-forum/get-elements-inside-a-family-instance/td-p/7583858

 

and just to let you know, I want to use this ''direction'' for dimensioning purposes. You may ask why am I not using reference line instead of model line, the reason is when I extract the direction from the reference line, it always gives me the constant direction in which the family was originally created, not matter how much the family has been rotated inside the project, the direction is always constant (for my case it is always (1,0,0)).

0 Likes
Accepted solutions (1)
3,179 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

For the situation you describe, you will indeed need to enter and analyse the family definition using EditFamily, as suggested in the second post.

 

Alternatively, you might also retrieve the geometry of the family instance that you have placed and navigate through that. However, that will not give you the original model line element in the family definition, just the curve geometry object generated by the family instance to visualise it.

 

You may well be able to use that curve object to determine the direction you are interested in, though.

 

You can explore the family instance geometry and see how to reach that curve by snooping it with RevitLookup.

 



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

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Jeremy,

 

Thanks for the suggestions. I actually tried the family editor method, it didn't work as well, so it always gives me (1,0,0) for the direction of those model lines or even reference lines (I actually expected this to happen because the orientation of the that reference line is (1,0,0) inside the original family that I created.) So I tried to extract a stable reference to those lines inside family editor, and then find them inside the revit project. It didn't work.

 

Panel.PNG

 

 

Please look at the attachment to find out what I want to achieve. 

 

Thanks for the help,

Dave

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Yes, of course the direction within the family is constant. That is how it was modelled. If you know that the direction is (1,0,0) in the family, there is no need to look. Next, you obviously need to apply the family instance transformation to that direction to determine the resulting direction in the project environment. There are various way to get that. One is again by traversing the element geometry and looking at the geometry instance and its transform:

 

https://www.revitapidocs.com/2020/99cb4580-9b59-6564-8181-6082f275a869.htm

 

The affine transformation from the local coordinate space of the symbol into the coordinate space of the instance.
 
Apply that to (1,0,0) and Bob's your uncle.
 


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

0 Likes
Message 5 of 6

jeremytammik
Autodesk
Autodesk
Accepted solution

Another way is to the the FamilyInstance element Location property. If it is a curve, that gives you a direction. If it is a point, it gives you a normal vector and a rotation. Maybe the rotation is what you are after in your situation:

 

 

All of these properties can be explored interactively using RevitLookup.

 

Have you snooped your model at all to discover where the required data is located and what it looks like?

 



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

0 Likes
Message 6 of 6

Anonymous
Not applicable

Hi Jeremy,

 

The location property actually worked, thanks for the suggestion. So I just worte a simple line of code as you suggested and it gave me the angle of the family instance (I mean how much it has been rotated inside the project environment).

So if the angle is PI/2 it means it is vertical, if it is 3*PI/2 it is still vertical but facing down. if it is PI, it is horizontal, 2*PI horizontal but facing left.

 

for f in family_list:

      print(f.Location.Rotation)

 

Thanks for the help.

0 Likes