Hello, I’m working on a utlity and could use some advice if anyone has a few minutes to spare, and thanks in advance.
What we want to do is set up spaces on one level, say level 2 and have the utility either replicate those spaces at other designated levels or copy level properties up.
It’s quick for us to set up the spaces so I’ve been focused on just copying properties, and really all we care about is the room name and number.
- room name is a straight copy across
- room number is a copy but with the first digit adjusted for the level, i.e. 202 becomes 302 when it goes in the corresponding space for level 3.
As a starting point I’ve extracted a rounded coordinate out of each space and driven it into the comments field for the space. I can see in my space schedule matching pairs and figure this is the easiest path to helping dyanamo match spaces up.
so the basic algorithm I am thinking of looks like this:
allow the user to define the source level and the target levels
loop through all spaces on the source level.
…for each space
…loop through all other spaces and look for matching coordinates.
…if the space is on a target level then copy space.name and space.number
adusting the space number for the level could be done in the loop or as a separate operation.
I’m fairly well versed in building graphs using nodes but am not well versed in python.
- does the basic approach seem reasonable?
- Can I built this graphically or do I need to get into coding?
- or, skirting the entire question - is there an existing utlity or graph that can do something like this?
Thanks a bunch for any thoughts and hints,
You may not even need to loop through space by space. You could take the space location and round it within Dynamo, break down the location components, remove the Z component, and then group spaces by X and Y pairs. This should give you all spaces grouped by X,Y coordinates (stacked spaces). Then you could filter out the source level spaces and the targeted level spaces. From there you just modify the list of target spaces based on the corresponding source space.
Ok, excellent, I like this.
I’ll have a few challenges figuring out the execution details but I’m used to working through that.
Ok, I’m making good progress on this but I’ve discovered that stacked spaces have some variation in their X,Y coordinate even though they were created by adding a space into the same set of walls, just on different levels.
I can round these off but the risk is that one space might round down and the space above round up. I’ll need to sleep on that one.
I think you should computationally drive the space creation. By placing them manually you will get too much variation.
Look into the ‘NewSpaces2’ method shown here: NewSpaces2 Method (Level, Phase, View)
This can also take into account the phase of that is something you need, although if memory serves it may not necessarily work as the method shows - I think I solved this awhile back by messing with document refresh and transactions, but I forgot how and can’t find it in my post history (if there is interest let me know and I’ll dig into it).
Thanks. We’ve discovered that by selecting spaces and space tags on the source level, then COPY, ALIGN TO LEVEL generates new spaces with identical coordinates. This effectively solves the problem and puts our space tags in the right position as a bonus.
Yikes, I spoke too soon. Copy space carries over the comment field which is where i am stuffing the x,y coordinates so I can see what is going on. It turns out that copied spaces return NULL out of space. location. I saw a null value earlier and added a filter to get rid of them, not realizing that this led to copied spaces not updating with actual x,y.
Any ideas why copied spaces have no valid location info?
A workaround - as long as we run the script that gets x,y and stuffs it into the comment field BEFORE we copy the spaces then the script can use that comment field as the grouping key.
See if this helps:
Create Spaces in View and assocaite with given level.dyn (27.9 KB)
Start with a view with no spaces in it, all spaces will be created and the associated space from the source level will be returned. Associated space parameters can then be pushed to the new space. As a sample I moved an altered version of the space number.
This could readily be modified to work for creating or associating rooms as well, or to use existing spaces. The Python code is heavily edited to permit such edits (in fact I didn’t reduce the list of imported Revit API classes to facilitate such edits).
Over the weekend I worked out an acceptable workflow using some simple steps and scripts. Goes something like this
- create spaces on the reference floor (typically 2nd level)
- name and number them properly
- run a script to copy the space number to the comment field
- select all the spaces, copy to clipboard
- paste using align to level (or align to view if you want tags also)
- repeat paste for all upper floors
( now we have the spaces in the right places with the right names but the numbers are all wrong.)
- run a script to copy the space comment field back to the number field
(now suite 201 has a stack of other suite 201s above it, ditto for other 2nd floor spaces)
- run a script to renumber all spaces using the level number as a prefix
This is good enough for us for now but I’m looking forward to learning what you’ve done here. I had a look at the python code and appreciate the detailed internal comments explaining each line of code!
I have other scripts that name panels based on the suite number and set panel and load types based on the suite name. We see our MDP loads show realistic loads with demand factors so it’s pretty cool. If anyone is working in electrical and wants copies of this stuff let me know.
Sounds like you have some great content for a ‘share’ topic!
I might put up a video blog about it eventually.