Assign Scope Box to existing views by view name

Hi all, I’m trying to create a script which will change the parameter called Scope Box of existing views.
I’m trying to filter all the views by view names and find the scope boxes with similar names (e.g. View Name “First_Floor_Block 1” needs Scope Box called “Block 1”)

I’ve been filtering a lot with the script and got kind of confused along the way, so there might be some unnecessary filtering happening in there :sweat_smile:. Could someone check the file and give me some feedback on how to progress from here? I believe that I’m quite close to achieve my goal. Assign Scope Box to View by View Name.dyn (49.8 KB)

1 Like

Hi,

I have made a script somewhat similar to this.
It does the following:

  1. Filter out all the views which cannot have a scopebox (reduce proces time)
  2. Check if a view Contains the name of a Scopebox (“First_Floor_Block 1” --> “Block 1”)
  3. Always get the First scopebox it finds and assign to the View.

Check it out and let me know if it is any helpScopeboxByViewName.dyn (41.1 KB)

2 Likes

Hi Joel,

Thanks for your fast response but I didn’t get your script to work in my situation. The way I filtered everything in my script is exactly how I want to assign the scope boxes to the views, just the very last step is somehow not working and I think it’s an issue of me lacking knowledge about lacing and making use of the levels.

If a sample project is required in order to get a better understanding of what I’m trying to achieve, please let me know.

If you could provide a sample project, i’ll take a look!

So I made a sample project. As you can see the views have either a wrong scope box or are assigned to none. I need them all, assigned to the scope box “Block 12” but only because the View Names are ending with “block12”. So in my situation there are several views ending with “block(number)” and several Scope Boxes named “Block(space)(number)”
I think I got the filtering part right in my script this far though?

Using Revit 2019 btw.
Sample_Project_ScopeBox_by_viewname.rvt (1.5 MB)

I tried your file with your script, but it seems you have used a Custom Node List.RemoveNull. From which package is this one?

Also, by changing some things in the Revit model, I could make my old script work.
I changed the name of the Scopebox from Block 12 to Block12, now it works fine.

If you have control over the naming of views & scopeboxes in your project, I recommend aligning these before trying to automate this process.

e.g. changing view names from “100_front_elevation_block12” to “100_front_elevation_block 12” (Adding a space between Block and 12. Now it matches with the name of the Scopebox.

Or you can change the name of the Scopebox from “Block 12” to “Block12”.

But if you don’t have control over naming things in Revit, you can fix it with Dynamo. You can remove spaces in the naming of the Scopeboxes or te views

I added the removing of spaces to my script so it works for the Test project.

If you could let me know from which package the “List.RemoveNull” node is, I would like to make your script work as wellScopeboxByViewName.dyn|attachment (54.9 KB)

It’s from the package called RootNodes.

I appreciate your help a lot, I will look into it later today or tomorrow!
So your previous script is working if I only get to match the naming of the scope box and views with eachother by removing (or adding for the viewnames) the space after “Block”?
I think changing the name of the scope boxes should be no problem, I will try the method you are showing with Dynamo since most projects going on right now are already using the standard naming for views and scope boxes like in the sample project.

Much appreciated! Will come back to it once I have time to dive into Dynamo again!

I have just changed some of the filtering in your script to only get the views and scope boxes that contain ‘Block’ in it’s name. Also changed the name of the scope boxes by removing the space after “Block”…

Now the script is working… But only untill Block 9, because when view name contains “block10” it finds two matching scope box names: Block1 & Block10, both of these values are now considered ‘true’. And since the script you made uses the node ‘list.firstItem’ it assigns the views with the name “block10” to the scope box called “Block1”. How do I fix this? It’s almost done!

EDIT: Nevermind, listing last item instead of first seems to do the trick :smiley:

Thank you for the script and all the help mate, wouldn’t have been able to do it without it! @Joelmick

Nice that you already fixed it! Yes, it can happen that it will find 2 matching scopeboxes with this kind of filtering. That is why I placed the List.FirstItem there, it will always take the first scopebox it finds. :slight_smile:

1 Like

Exactly, by filtering it by only taking views and scope boxes that contain the word “blok” it will always get the right scope box for the views if you choose the last item instead of the first. (in my situation)

The problem happened because the first item labeled as ‘true’ for the scope box called “Blok1” was a viewname ending with the name “blok10”, same with viewnames ending with “blok11” “blok12” etc.
So basically anything that starts with the number 1 and is followed with another digit. The last item in the list will always be the right scope box to assign to the view.