Create a view template

Create a view template

michele.verda
Participant Participant
1,368 Views
3 Replies
Message 1 of 4

Create a view template

michele.verda
Participant
Participant

It's possible to create a view template?

 

I noticed that there is a property IsTemplate but is read-only.

 

A view templates is not tied to a level but if I try to use the NewViewPlan() method passing a null value as a level, Revit throw an exception.

 

0 Likes
1,369 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Michele,

I am afraid this is currently not possible. At least I see an open wish list item in ur database for this functionality. I added a note of your wish to it.

Cheers, Jeremy.
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

Dale.Bartlett
Collaborator
Collaborator

Has there been any development on Creating View Template in 2014/2015? Or is it possible to copy any existing View Template and then adjust properties to suit requirements? I have only just started looking so have not done a lot of research yet. Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 4 of 4

ABuschmann
Explorer
Explorer

Please note that this is very probably very unsupported - at least it feels very weird to me. But it works, so I thought I might as well share it:

 

 

public View duplicateTemplate(View template, string newName)
{
if (template == null || !template.IsTemplate) return null;
Document doc = template.Document; var newIds = ElementTransformUtils.CopyElement(doc, template.Id, XYZ.Zero); ElementId newId = newIds.FirstOrDefault(); View newTemplate = doc.GetElement(newId) as View; if (newTemplate != null) newTemplate.Name = newName; return newTemplate; }

 

I have tested this in Revit 2015 and 2016.

Duplicate a view: View.Duplicate

Duplicate a view that is a template: ElementTransformUtils.CopyElement(doc, id, XYZ.Zero)

 

 

0 Likes