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
Dear Ning_Zhou,
the View.GetNonControlledTemplateParameterIds() and View.GetTemplateParameterIds() methods may match your needings.
Best regards,
Revitalizer
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.
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
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:
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
thanks Jeremy for this good news! i'm happy as long as that "Include" will be available via API. Ning
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 });
Thank you!
Preserved for posterity:
https://thebuildingcoder.typepad.com/blog/2018/11/view-template-include-setting.html
Cheers,
Jeremy
That is useful information. Thanks. Can you tell me if this is only for Revit 2019 and later? Dale
@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
@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.