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: 

Get all parameters that are schedulable for a category

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
2060 Views, 6 Replies

Get all parameters that are schedulable for a category

Hi,

 

I'm trying to find a good way to find all parameters you can schedule for a certain category.

I know you can find the parameter id's with following function:

var availableParameterIds = TableView.GetAvailableParameters(_doc, category.Id);

But these parameters doesn't include the shared parameters from a family.

Do I need to check every family for that category to get these parameters or is there a better way?

6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: Anonymous

One way to approach this for a given document, meseems, would be to collect all elements of the given category and create a list of all the parameters they are equipped with.

 



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

Message 3 of 7
Anonymous
in reply to: jeremytammik

Thank you for your reply. I already thought so but I hoped there was a better way to do it.

I hoped there was a way like TableView.GetAvailableParameters to get all the parameters.

If i loop trough every element for a certain category I still don't get the same result as the availble parameters for a schedule. Only the shared family parameters show up in this list but if you loop you also get the non shared and other stuff.

Message 4 of 7
FAIR59
in reply to: Anonymous

there is a better way, using the ViewSchedule, instead of the TableView.

ViewSchedule.Definition. GetSchedulableFields()

 

StringBuilder sb = new StringBuilder();
Document doc ;
ViewSchedule view = doc.ActiveView as ViewSchedule;
ScheduleDefinition def = view.Definition;
foreach(SchedulableField p in def.GetSchedulableFields())
{
	sb.AppendLine(string.Format("<{0}> {1}",p.ParameterId,p.GetName(doc)));
}
TaskDialog.Show("debug", sb.ToString());
Message 5 of 7
Anonymous
in reply to: FAIR59

But this only works if you have created a schedule.

The thing I try to do is get alle the parameters you can add to a schedule when you create one.

If you create a schedule for a category you can add several parameters. This list of parameters is the one I want to recreate!

Message 6 of 7
kiencent94
in reply to: Anonymous

Hello,

Have u shown up non shared parameters ? 

Message 7 of 7
havard.leding
in reply to: Anonymous

I just use the binding map. No elements needed and you get everything you need.

BuiltInParameters on the other hand seems trickier.
I only use...

GetAvailableParameters(_doc, category.Id);

...to get BuiltInParameters.
But still no way to know if they are type or instance without an element i think.

This is my BindingMap iterator to get shared parameters.

public static List<ParameterData> GetSharedParameterData(Document doc, BindingMap bindingMap, ForgeTypeId specTypeId)
        {

            DefinitionBindingMapIterator iter = bindingMap.ForwardIterator();

            List<ParameterData> parameterData = new List<ParameterData>();

            while (iter.MoveNext())
            {

                ElementBinding elemBind = (ElementBinding)iter.Current;
                if (elemBind == null)
                    continue;

                var categories = from Category dg in elemBind.Categories
                                 where dg is Category
                                 select dg.Id;

                InternalDefinition intDef = iter.Key as InternalDefinition;

                if (!(doc.GetElement(intDef.Id) is SharedParameterElement spe))
                    continue;

                if (!(specTypeId is null) && intDef.GetDataType() != specTypeId)
                    continue;

                ParameterData data = new ParameterData
                {
                    Name = spe.Name,
                    ParameterKey = spe.GuidValue.ToString(),
                    ParameterId = spe.Id.IntegerValue,
                    Instance = elemBind is InstanceBinding,
                    ParameterType = intDef.GetDataType(),
                    Categories = categories.Select(t => t.IntegerValue).ToList(),
                };

                parameterData.Add(data);
            }

            return parameterData;
        }

 

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community