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?
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
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.
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.
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());
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!
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.