View Family Types selection

Is there a way to select all views from a specific View Family Type. (not a view type or view family)
There is a Node to select one View Family Type but it appears that there is nothing I can do with it.
Anybody knows if there is nodes I can use along with this one ?

I would like to simply select all views from a specific View Family Type.
In Revit alone it is called View Type, as opposed to View Family.

image

image

1 Like

Does anybody know the answer to the original question in this thread? I think the answer above is not the answer. How do we get the views that belong to a specific view type (as shown in the original question).

Does this get you what you need?

#Sean Page, 2020
import clr

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

clr.AddReference('System')
from System.Collections.Generic import List

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Use a Collector and class to get the types
ViewFamTypes = FilteredElementCollector(doc).OfClass(ViewFamilyType).WhereElementIsElementType().ToElements()

OUT = ViewFamTypes

Hello, @SeanP , I am very grateful with you for trying to help me. However, I think this does not answer the original question, because the question is how to get the views that have a certain view type, but not a higher level view type such as Floor Plan or Ceiling Plan, but a view type of those main types. Notice on the image of the original question that the user has a type of floor plan that he has created, with the name “A100-FIRE PROTECTION PLAN” which is a custom type of floor plan. Then the user wants to isolate quickly the views that belong to that custom type of floor plan, to do something with those views. In my case I have several of those custom floor plans, and I want to add a different prefix to the view names, as per the name of the custom view type. So, as the OP, I thought the “ViewFamilyTypes” node would isolate those views for me, but that is not the case. The output of the node is just the type, not the views that are assigned to that type.

I believe this will get what you are asking for.

Or here is a consolidated version in Python:

#Sean Page, 2020
import clr

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

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
typeName = IN[0]

views = []

#Get all views and check thier type name against the input
AllViews = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).ToElements()

for v in AllViews:
	if not v.IsTemplate:
		if (doc.GetElement(v.GetTypeId())).get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString() == typeName:
			views.Add(v)

OUT = views

image

3 Likes

Thank you very much. I will try your script later.
I just see you message now (end of the day for me), so this morning I ended up using a workaround. I created a project parameter for views, named “#”, then I selected from the project browser groups of sheets from a certain view type, then I entered something in that parameter, such as “01”, then using that value i was able to isolate from the long list only the views that have that value “01” using List.FilterByBoolMask ; then I was able to rename all those views quickly in groups. Then I moved to the next group. After a few repetitions of the same, I was able to rename all the views by their view type. Thanks so much again for your help.

1 Like

Alfredo,
How would I rename views with a “Custom Text” + Parameter?
I want to name my millwork elevations “Millwork” Detail Number

Hey Sean, In this tread, it seems you created a custom node to select viewfamilytypes. What about if I wanted to set viewfamilytype?

I need to change the view type but it doesnt seem to accept any parameter name.

image

What you need to use is the ChangeTypeId method. This is a very simple version to change all Views going in to a single ViewFamilyType.

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0])
type = UnwrapElement(IN[1])
changed = []

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for elem in elements:
	changed.append(elem.ChangeTypeId(type.Id))

TransactionManager.Instance.TransactionTaskDone()

OUT = changed
4 Likes

Hi All,

I am experiencing a similar problem - i am trying to list all Views and check it agains a specific ViewFamilyType and then add that VFT as a prefix to the current View Name.
It looks like i am going in circles as, depending on a used source (Categories/Views or Element Types/View or Element Types/ViewFamilyType) views end up with a either Type or View Type parameter describing the same value.

I simply cant make it work and i am sure i am missing something here.
Anyway, ive attached the graph and hoping that someone may now a solution.

My sneaky plan is:

View Type reflect drawing series: 5400
Vie Template reflect the above + description: 5400.FireStrategy

Browser Organiser reflect both parameters and groups views under View Type first and then View Template.

The graph i am trying to create is supposed to read View Type and add it as a suffix to a View Name of a drawing grouped under this View Type - hope it makes sense.

Any help greatly appreciated.

MTEST.View.Type.dyn (56.0 KB)

Does this get you headed in the right direction? Note that I am filtering out View Templates in the python, so if you want those for naming you will need them from somewhere else or edit the code.

#Sean Page
import clr

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

clr.AddReference('System')
from System.Collections.Generic import List

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
views = UnwrapElement(IN[0])
vTypes = []
vOut = []

#Do some action in a Transaction
for v in views:
	if v is not None:
		if v.IsTemplate == False:
			vTypes.append(doc.GetElement(v.GetTypeId()))
			vOut.append(v)

OUT = vTypes,vOut

Hi Sean,

Nice python script!

Is it possible to get the ViewFamilyType with a input of a name.
I want to combine those two scripts but I need the ViewFamilyType as output and a name as input.

Thanks!

This should get you going.

image

#Sean Page, 2021
import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
names = IN[0]
results = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
ViewFamilyTypes = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
for name in names:
    for VFT in ViewFamilyTypes:
        nm = VFT.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()
        if  name == nm:
            results.append(VFT)
TransactionManager.Instance.TransactionTaskDone()

OUT = results
4 Likes

No need to put this inside a transaction. It is just collecting information - not changing elements.

Yes, I always use that default template because typically changes are coming, but not always. Several of the imports could also be removed if you wanted.

Understand. My template is way worse. 123 lines before I start doing anything. :wink:
image

1 Like

This is really nice! :upside_down_face:
Thank you very much!

Hey Sean,
I found this thread as I am working with 3dViews. I am trying to access the 3d Views with a doc loaded in the background (For .nwc export). I cannot seem to see all the 3D views in the doc when using this code. The green block is me investigating the open model. The red block is trying to get the views in the background. I have 11 3D views (“PDX8…”) that do not seem to come in. They have view templates applied to them in the model. I tried setting view template to none and still did not see them.

Anything help would be appreciated!

Thanks,
Phillip