Create Views from Groups and Isolate the Corrosponding Group in the View

Here’s a potential solution, at least to the part of creating the isolated views. I don’t see a reason to crop the view if everything has been isolated, so it might just be an extra step that you can eliminate.

So I have a model with some groups in in. They are not rooms, but they are on different levels etc.

image

As you can see there are some array groups in there so i will filter these out:

Once we have that we can do what you were doing and create a floor plan from Level, then simply rename it. So far so good.

Then we can use this custom code, to isolate a group in a view. Since Groups contain multiple elements, the way the Isolate method works in the API, we actually have to isolate every member of the group so the code would like this:

# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System
from System import Array
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

try:
	errorReport = None
	
	TransactionManager.Instance.EnsureInTransaction(doc)
	for e, v in zip(IN[0], IN[1]):
		view = UnwrapElement(v)
		view.IsolateElementsTemporary(UnwrapElement(e).GetMemberIds())
		view.ConvertTemporaryHideIsolateToPermanent()
	TransactionManager.Instance.TransactionTaskDone()
except:
	import traceback
	errorReport = traceback.format_exc()	

if errorReport == None:
	OUT = IN[1]
else:
	OUT = errorReport

The lines of code to pay attention to are: view.IsolateElementsTemporary(UnwrapElement(e).GetMemberIds()) where I am isolating all of the group memebers, and then in the next line we convert the temporary isolation into a pernament one: view.ConvertTemporaryHideIsolateToPermanent(). The result is something like this:

Here’s the definition:

2_viewByGroup2.dyn (52.2 KB)

As you can see the only thing visible is the group, so I don’t think you will have to crop that view. Give it a try. It might save you a step.

Cheers!

4 Likes