Get room from furniture

Get room from furniture

mike
Enthusiast Enthusiast
1,243 Views
2 Replies
Message 1 of 3

Get room from furniture

mike
Enthusiast
Enthusiast

I have a c# function that simply populates a parameter with the room number for a furniture object.  On some of my custom families.  The room property is null and my function will not work.  This is the code that retrieves the data:

 

ofurn.get_Parameter("FurnRoom").Set(ofurn.Room.Number.ToString());

 

I;m pretty sure that the families are collected in the selection set properly.  If I do a Revit Lookup into an object that works and one that fails, I can see that the property is missing.  Some of these families work and some don't.  These happen to be different families but are adjacent to each other in the model.  How can this happen?  What do I need to do differently?  All the "stock" families are fine so maybe it is something with my families, but whay do some contain data and others do not?  I've attached screenshots of a good one and a bad one.  Note the "Room" parameter.  Thanks for any help.

0 Likes
1,244 Views
2 Replies
Replies (2)
Message 2 of 3

Revitalizer
Advisor
Advisor

Dear Mike,

 

you could use your FamilyInstances' Location (either LocationPoint.Point or, if the Family is Line based, a point on this Line); after getting this XYZ, use Document.GetRoomAtPoint(XYZ) to get the Room.

Note that you might add a little bit to the XYZ's Z value to make sure the point is inside the room volume.

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

Dear Mike and Revitalizer,


Thank you for your query, Mike, and good suggestion, Rudi.


I cannot really say whether your users are doing something bad to generate this situation.


You should consult with an application engineer or product usage expert to find out why this is happening and how it can be avoided.


Happily, though, you may be relieved to hear that other people have run into similar issues in the past, and several suggestions besides Rudi's have been made to work around issues similar to what you describe:



I hope these help in your case as well.


Please let us know what you find out and how you end up resolving this.


Thank you!


Best regards,


Jeremy




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

0 Likes