Center Room reference point

Hey

A bit new to the programming of Dynamo with Revit but absolutely loving it. Managed to create a sequence to alert all mirrored objects in a project which was great fun.

Now i am trying to get all references of the rooms in the project to center in the room. Kinda like the CASE-apps used to do… I managed to collect the room data but i have no idea how to continue. Can anyone give me a hint?

Element.SetLocation from clockwork will set it for you. Now obtaining the actual center of the room is a little more involved.

get room boundaries, create polygon, get polygon center. of course with rooms that have multiple loops in them, it will be a little tricky. :slight_smile:

1 Like

There is a component called ‘room location centering’ in the Modelical package. I haven’t tried it but it might be what you are after.

1 Like

Nice Paul! Thanks for sharing.

Thank you!

You’ve all been great help! Paul, thats exactly what I’m looking for :slight_smile:

Hello Johan,

I’m trying the same thing you’ve done. Getting the mirrored status of door families and than setting an instance parameter of that door with a value.

Can You help me getting started?

tnx in advance

Hey guys
When I’m trying to use the script Paul_Wintour refers to “Room Location Centering” in Revit 2016 with Dynamo 1.0, the last part of the script gives me a warning/failure.


If I then change the indentation for line 30, run the script it fails and change the indentation back again it works - but I don’t see whats diffrent.

Remove the indent on line 30 should work, make sure it’s all tabs or 4 spaces, depending on what’s used in the rest of the code

@T_Pover

Yes it works one time, but then if I has to use it once again, I need to use the indent again - run it, make it fail and then remove the indent again in order to make the script work again.

So the issue isn’t that I don’t know what to do in order to make the script work from time to time, the problem is that the script isn’t reliable/stabil.

But still thanks for what you saw :slight_smile:

You don’t have to “break” it to make it work again. Just put the whole thing inside of an “If” statement and add a boolean toggle input to refresh it. Python node WILL NOT RUN if none of the inputs to it changed. Example:

runIt = IN[2]

if runIt:
    #do something
else:
    #do nothing 
2 Likes

Technically you don’t need to wrap the code in an IF statement. Just having an aditional port IN[2] for a Boolean toggle will do the trick. No need to tie in with code and will work on either true or false values, just need to switch once before you run again. This just triggers the Nodes input changed event and adds to the list of nodes to re-execute.

Same goes for custom nodes, chuck an “input” node within the parent node named refresh which will just add a new port to a the custom node but the input node doesn’t need to be connected to anything downstream in the parent node.

@Konrad_K_Sobon’s solution works nicely for nodes that you don’t want to execute every time and only until you want them to, good for exporting or model updating type nodes. So go with his if that’s the functionality you’re after.

Cheers,
Dan

3 Likes