Message 1 of 5
Remove Parameters from view template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am working on a tool that requires that certain text parameters removed from a view template. I have written a macro to test how to do this but I am getting a null error that i think is related to the parameters in the view template. Can anyone tell me if i am heading in the right direction for this?
public void getvpid()
{
Document doc = this.ActiveUIDocument.Document;
var view = doc.ActiveView;
var elementid = view.ViewTemplateId;
View template = doc.GetElement(elementid) as View;
var parameterids = template.GetTemplateParameterIds();
IList<ElementId> parameterlist = myList(parameterids);
using(var transaction = new Transaction(doc,"test"))
{
transaction.Start();
var noncontrolledparameterid = template.GetNonControlledTemplateParameterIds();
foreach(var p in noncontrolledparameterid)
{
parameterlist.Add(p);
}
template.SetNonControlledTemplateParameterIds(parameterlist);
transaction.Commit();
}
}
public IList<ElementId> myList(IList<ElementId> parameterids)
{
IList<ElementId> parameterlist = new List<ElementId>();
foreach(ElementId paramid in parameterids)
{
var parameter = doc.GetElement(paramid);
if(parameter.Name=="SCALE1"||parameter.Name=="SCALE2"||parameter.Name=="SCALE3"||parameter.Name=="SCALE4")
parameterlist.Add(paramid);
}
return parameterlist;
}
Thanks in Advanced