Anyone knows how to collect room angle with dynamo?
I am trying to get length and width of room. For tagging.
I am creating bounding box with room geometry then cuboid.
I will upload my script by tomorrow.
The object you’ve labeled as ‘BoundingBox’ is actually the room element. Bounding boxes do not show up angled - by definition they are always on the global coordinate system.
Thanks for reply @JacobSmall .
I have converted bounding box to geometry. But any suggestions for getting angle. Or can we rotate cuboid with same size and angle of bounding box?
At last I need to create cuboid and get length and width.
In cases shown above maybe it is easier to collect room boundaries and then check the direction of the first one’s curve? (angle to Vector(1,0,0) for instance).
Can you give an example?
One possible method:
- Room.Boundaries in the clockwork package (or similar - you have options in many packages here) to get the bounding curves.
- Convert any arcs / splines / not-a-line to aline or lines by your method of choice (line by best fit through 3 equally spaced points is one option).
- Then convert the lines to a vector.
- Then adjust all the vectors by rotating them so they are within the XY positive quadrants.
- Then find the angle from the global X axis to each vector.
- Then round those values off to the desired tolerance.
- Then group the values.
- Pull the length of each vector.
- Sum the values.
- The one with the most is Most likely your primary angle (see note below).
- Then rotate all the original curves by The inverse of that value (so you are parallel to the X axis with at least some of your walls, and some being perpendicular, and others (which aren’t on the primary angle) will nkt Align to anything.
- Then put a bounding box around that.
- You can now pull the X and Y measurements of the bounding box.
When this should work for most rooms/spaces (Including all the ones you show above), but know that space is generally Inconsistent and non-conforming. As such you might want to test other methods as well. Off the top of my head some other options would be:
- Working with the most common angle by count.
- Working with the average angle
- Working with the longest overall curve
Oddly enough NONE of the options I list above work for the hotel room I am currently in as it’s just too oddOh shaped (it’s one of those rooms at an angle in the hallway so I have no parallel walls, and the longest is the off-axis one along the bathroom), so you may want to test for a complete non-conformance and tell the designer to manually add those ones.
Dear @JacobSmall again thank you very much for guiding me.
i think i have done this Script.
files are below.
Revit : 2019
i have tried my best to complete this.
can you please check once if its correct or not.
just Dynamo preview is not match with Results in Revit Don’t know Why(Blue Lines in Revit).
still i am beginner in Dynamo. so what are your suggestions for This.
I am at a conference all week and will have some significant ‘catch up’ to do on my return. Remind me next week if you haven’t heard from me first.
hi @JacobSmall Reminder.
Thanks for the reminder.
Took a look at yours and the lack of documentation made it hard for me to wrap my head around which direction you took, so I started fresh based on my original idea. Hope you don’t mind.
Instead of using vector rotation I took the angle tangent vector at the midpoint and found the angle with the X axis about the global Z, and then used a modulo function to find how far off 90 degrees each value was. This gave me the ‘set to one quadrant’ in one function (I did wrap it in a Math.Round though).
I then grouped the curves, summed the lengths, and found the longest to get the ‘most common angle’ within the room. Rotating the entire polycurve and use that to set the boundingbox from which you can pull the X and Y dimensions which become the parameter values for length and width is pretty straightforward from there.
The result got every one of your dimensions correctly and a few of my own tests too.
Give it a shot rebuilding and let me know if you have questions and I’ll do my best to get you a response.
Dear @JacobSmall , Thank you very much for giving your time.
and yes your method is very easy to learn.
and best thing is we didn’t use any Custom Nodes
i understand all process. just one i didn’t get first Code block with List.Clean i have tried with only nodes but didn’t understand how to use nodes to get same result as yours.
and here Final Dyn file if someone needs.
ROOM With Length & Width.dyn (52.7 KB)
This is what I strive for in my posts like this. I tend to stick to out of the box nodes where I can do anyone with Dynamo installed can follow along. It’s really good to hear this so thanks.
That is another way to filter a list using design script, leveraging a List.Clean method and an of statement. In plain English it is doing this:
If the area of the room is greater than 0 return the room and if not return null. When you’re done clean the list of items by discarding any null values or empty lists.
Alternatively You can use a
Room.Area node, and a
> node to get a boolean for each room having an area greater than 0. Then use a
List.FilterByBoolMask node to filter out items with areas that are not larger than 0.
Now I get it I will definitely try.
Thanks for your help.
I think we can close this Topic.
See you in another Topic.