PDA

View Full Version : 2016 Trouble changing built in parameter of view



Gouz91
2016-06-25, 08:58 PM
Good evening,

I am trying to change the phase filter to Show All in a 3D view using the API. However it seems i can't set the parameter even when it return True.

The value of the phase filter parameter remains the same after running the script.
What am i doing wrong?
If it's impossible to change the phase filter, is there a way to import a viewtemplate from another file and apply that to a 3Dview?


using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;

namespace test
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("0C4DCB69-0A65-4FE4-9269-63E62D661120")]
public partial class ThisDocument
{
private void Module_Startup(object sender, EventArgs e)
{

}

private void Module_Shutdown(object sender, EventArgs e)
{

}

#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void test12()
{
UIDocument uidoc = Application.ActiveUIDocument;
Document doc = uidoc.Document;
FilteredElementCollector collector = new FilteredElementCollector( doc ).OfClass( typeof( View3D ) );


foreach( View3D v in collector )
{
msg(v.Title.ToString());
Parameter param = v.get_Parameter(BuiltInParameter.VIEW_PHASE_FILTER);
msg(param.AsValueString());
msg(param.Set("Show All").ToString());
msg(param.AsValueString());
}

}

public void msg(string message)
{
TaskDialog.Show("debug", message);

}
}
}

arqt49
2016-06-26, 09:26 AM
VIEW_PHASE_FILTER parameter type is ElementId, not boolean.

First, you have to find the "Show all" filter (using a collector, for instance), and then assign its Id property to the parameter.

Gouz91
2016-06-28, 11:29 AM
Thank you! It worked perfectly!