view template "include"

view template "include"

Ning_Zhou
Advocate Advocate
3,140 Views
16 Replies
Message 1 of 17

view template "include"

Ning_Zhou
Advocate
Advocate
see attached JPG, is that "include" parameter available?
3,141 Views
16 Replies
Replies (16)
Message 2 of 17

jeremytammik
Autodesk
Autodesk

Dear Ning,

 

Thank you for your query. I passed it on to the development team and will let you know what I find out.

 

Cheers, 

 

Jeremy



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

0 Likes
Message 3 of 17

Revitalizer
Advisor
Advisor

Dear Ning_Zhou,

the View.GetNonControlledTemplateParameterIds() and View.GetTemplateParameterIds() methods may match your needings.

Best regards,
Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 4 of 17

Ning_Zhou
Advocate
Advocate
thanks Jeremy, as mentioned by Revitalizer, it may already be available but your confirmation will be very much appreciated. Ning
0 Likes
Message 5 of 17

Ning_Zhou
Advocate
Advocate
thanks Revitalizer for the hint, I noticed these 2 methods before but not quite sure and never tested, will give a try later. Ning
0 Likes
Message 6 of 17

Ning_Zhou
Advocate
Advocate
just curious, you can get parameter id from View.GetTemplateParameterIds() , but how can you know which is which, well, I may miss something very simple, how to get parameter from parameter id if it's negative "number"?
0 Likes
Message 7 of 17

Anonymous
Not applicable

negative parameter Id values are found in the BuiltInParameter enumeration. The underlaying values in the enumeration map directly to the interger value of the parameter Id.

0 Likes
Message 8 of 17

Ning_Zhou
Advocate
Advocate
got it, thanks Scott, managed to get list of template parameters, no luck in matching any one to that "include" guys
0 Likes
Message 9 of 17

jeremytammik
Autodesk
Autodesk

Dear Ning,

 

Thank you for your patience. I submitted a wish list item for this for you: CF-2158 [API: set 'include' toggle in view template list].

 

Cheers,

 

Jeremy



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

0 Likes
Message 10 of 17

Ning_Zhou
Advocate
Advocate
great! thanks Jeremy
0 Likes
Message 11 of 17

jeremytammik
Autodesk
Autodesk

Dear Ning and all others concerned,

 

Thank you for your patience, and I hope you noticed and voted for the associated wish list item:

 

 

This wish list item appears to be on the roadmap now, and the development team are requesting feedback on it.

 

The discussion forum threads, ADN cases and development tasks affected are:

 

 

Would you like to review the current draft of the plans below and let us know whether you think they will meet your needs?

 

We think the Acceptance Criteria listed below cover the customer wishes; please let us know if this is correct and if there are other requirements related to View Templates.

 

Draft Release Epic:

 

As an API developer, I need the ability to create, modify and apply view templates via the API, so that I don’t need to use Revit interface to create and manage my view templates.

 

Draft Acceptance Criteria:

 

  • Ability to edit and control all view template setting via the API (this may be available now?)
  • Ensure that the action of including parameters via the “Include” column in the view templates dialog is available through the API. (maybe this is the same as line #1?)
  • Create a new view template from scratch via the API
  • Duplicate an existing view template via the API
  • Create a view template from the current view and from existing views via the API
  • Allow Revit command “CreateTemplateFromCurrentView" to be called silently and with the required arguments. (Is this request redundant?)

 

Customer sentiment:

 

My goal is to create X views, each with a new view template that has filter variations which depend on parameter values. I managed (via the API) to associate each view with the correct template, but had to create the templates via the UI, before I could edit them with the API.

 

Does that sound as if it matches and covers all your requirements?

 

Thank you!

 

Cheers,

 

Jeremy

 



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

0 Likes
Message 12 of 17

Ning_Zhou
Advocate
Advocate

thanks Jeremy for this good news! i'm happy as long as that "Include" will be available via API. Ning

0 Likes
Message 13 of 17

teocomi
Explorer
Explorer

Hi all,

 

I've been able to get the "includes" with `viewTemplate.GetNonControlledTemplateParameterIds`.

The method returns a list of Parameter ids, and you can then use `viewTemplate.Parameters` to map them.

 

 

Same for setting them, see below an example:

 

//creating a list so that I can use linq
var viewparams = new List<Parameter>();
foreach (Parameter p in viewTemplate.Parameters)
viewparams.Add(p);

//getting parameters by name (safety checks needed)
var modelOverrideParam = viewparams.Where(p => p.Definition.Name == "V/G Overrides Model").First();
var viewScaleParam = viewparams.Where(p => p.Definition.Name == "View Scale").First();

//setting includes
viewTemplate.SetNonControlledTemplateParameterIds(new List<ElementId> { modelOverrideParam.Id, viewScaleParam.Id });

 cc @jeremytammik 

Message 14 of 17

jeremytammik
Autodesk
Autodesk

Thank you!

 

Preserved for posterity:

 

https://thebuildingcoder.typepad.com/blog/2018/11/view-template-include-setting.html

 

Cheers,

 

Jeremy

 



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

Message 15 of 17

Dale.Bartlett
Collaborator
Collaborator

That is useful information. Thanks. Can you tell me if this is only for Revit 2019 and later? Dale




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

teocomi
Explorer
Explorer

@Dale.Bartlett I have't tried with previous versions, but the same methods exist in the 2016 API, so it should work...

 

https://apidocs.co/apps/revit/2016/15617b2e-89a4-ddbe-5f93-7855c2994d79.htm

0 Likes
Message 17 of 17

Anonymous
Not applicable

@teocomi I was asked about this yesterday so it was funny to see your name appear so recently on this thread with a solution!

 

One comment though would be that by using the view.SetNonControlledTemplateParameterIds() method it takes the parameters of a view and sets them to true in the view template unless specified in the input. As a result you may wish to do a check first that gets all of the parameters currently not included and add them to the list of id's you feed in should you wish to stop them all defaulting to include.

0 Likes