Create View Types - none to duplicate

I have a list of views with all kinds of parameters from a seed file. I want to duplicate them in a new file and set the parameters from the seed file settings. I have exported a schedule with all the information I need.
I have most things working so far, but I cannot set up the view type. I have no view types in the project I am working on. All of the view types return a null or empty list.
Is there a way to create a View Type without having one in the project?

Hi,

See if this code helps? (based on work by @Ron_Allen) I think there must be the inbuilt types, so you can duplicate one of those…

Cheers,

Mark

image

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
strVIEW_TYPE_Name  = IN[0]
strNew_VIEW_TYPE_Name = IN[1]


# Place your code below this line
fec_ViewFamilyType = FilteredElementCollector(doc).OfClass(ViewFamilyType)


view_Type_List = []
for viewFamilyType in fec_ViewFamilyType:
    name = doc.GetElement(viewFamilyType.Id).get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()
    if name == strVIEW_TYPE_Name:
        view_Type_List.append(viewFamilyType)

TransactionManager.Instance.EnsureInTransaction(doc)
new_v  = view_Type_List[0].Duplicate(strNew_VIEW_TYPE_Name)
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = new_v 

Since I know absolutely nothing about Python, I am at a complete loss here.

VIEW LIST- WORKING View Family and Type.xlsx (11.6 KB)

I have an excel file with the View Family and View Type that I need to create. I don’t know if this will help or not.

Hey,

I’m a bit confused by your language I think, sorry…

So I’m interpretting that you want to create a view, but all you have is the name? So you want to create a Ceiling Plan, at level 00? And you’ve got parameters to push in?

So is your task to read the excel, group the views by type and generate them in various ways?

If so, we can perhaps assist :slight_smile:

Kind regards,

Mark

The only type I have, for a RCP for example, is Ceiling Plan, the names in the first column. I would like the names in the second column to duplicate the existing, first column, to View Types to have the name 00.1- RCP- Coordination (Find Things Here). for example.

Heya,

Sorry I don’t understand apologies.

Can you break it down into steps?

Kind regards,

Mark

If I were in Revit, the steps would be to duplicate Ceiling Plan and give it the name like: 00.1- RCP- Coordination (Find Things Here)

Then I could assign that Type to other views I am creating.

I found this in another thread so I guess I am going to try this:

Brendan_Cassidy

Jan '17

You are limited to the view types that revit gives you, but as a work around add a new parameter and set this parameter to what you want for each view(working/internal/etc/etc). You can also set this via a view template.).

Then in your browser organisation you tell it to group by this parameter as a sub filter after view type.

Something like this may work

I used the @Brendan_Cassidy option to add Sub Type and sort my views in my browser. I took what had been the type name and assigned it to Sub Type. It worked.
I had a lot in my schedule from the previous template. I had them all broken down into a setting. When I realized that some were taken care of in the View Template, I just Froze them here.

1 Like

@donnia.tabor-hanson - Sorry for the late reply.

The code in the window goes into a Python node. The “View types” are one of the most underutilized elements in Revit! Using them to sort and manage view types and auto-apply view templates eliminated the need for parameters that are manually set and often wrong : )

To use it you would need to add a “Python script” node, then press the “+” to add another “IN”

Double click the node to open the editor,

Then copy-paste the code in the Python Script.

The rest shoudl be handled by the script - @Mark.Ackerley showed the image with the “String” which is the type name and the 2nd string which is the new type name…

It would be great if more people utilized types!

1 Like