Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

view template "include"

16 REPLIES 16
Reply
Message 1 of 17
Ning_Zhou
2112 Views, 16 Replies

view template "include"

see attached JPG, is that "include" parameter available?
16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: Ning_Zhou

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

Message 3 of 17
Revitalizer
in reply to: Ning_Zhou

Dear Ning_Zhou,

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

Best regards,
Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 17
Ning_Zhou
in reply to: jeremytammik

thanks Jeremy, as mentioned by Revitalizer, it may already be available but your confirmation will be very much appreciated. Ning
Message 5 of 17
Ning_Zhou
in reply to: Revitalizer

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

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"?
Message 7 of 17
Anonymous
in reply to: Ning_Zhou

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.

Message 8 of 17
Ning_Zhou
in reply to: Anonymous

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

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

Message 10 of 17
Ning_Zhou
in reply to: jeremytammik

great! thanks Jeremy
Message 11 of 17
jeremytammik
in reply to: Ning_Zhou

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

Message 12 of 17
Ning_Zhou
in reply to: jeremytammik

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

Message 13 of 17
teocomi
in reply to: Ning_Zhou

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
in reply to: teocomi

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
in reply to: teocomi

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




______________
Yes, I'm Satoshi.
Message 16 of 17
teocomi
in reply to: Dale.Bartlett

@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

Message 17 of 17
mark.thorley
in reply to: teocomi

@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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community