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: 

ParameterBindings parameter ID

5 REPLIES 5
Reply
Message 1 of 6
chris
1491 Views, 5 Replies

ParameterBindings parameter ID

Hello,

 

Is there a way with Revit 2014 API to find a Project Parameters ID from ParameterBindings??

 

I have a project parameter and a family parameter both with the same Name and type, the only distinguishing feature is their ID's, so if I have a parameter how do I know if it is a Project Parameter??

 

Regards

 

Chris

5 REPLIES 5
Message 2 of 6
chris
in reply to: chris

Any responce from the Autodesk Team?

 

It is possible to in a project and 3 parameters, all called "test" of type "length" all Door Category and instance parameters... one as a Shared Parameter, one as a Family Parameter and one as a Project Parameter. Now it is easy to distinguish the Shared Parameter... but isolating a Family Parameter from Project Parameter seems inpossible??? I have even tried accessing FamilyParameters, but the ID of the parameter in a family is different to the same ID when loaded into a project...

 

If the ParameterBindings gave the Parameters ID then it would be an easy fix...

 

Am I missing something???

Message 3 of 6
Scott_Wilson
in reply to: chris

You might find some useful info on this within this discussion. http://forums.autodesk.com/t5/revit-api/reporting-on-project-parameter-definitions-need-guids/m-p/46...

 

Towards the bottom you will find some code snippets that use some interesting techniques to get at some of the hard to reach info of project parameters. Although not directly related to your problem, there might be something there that will allow you to get at what you want.

 

Along these lines, I just thought of one possible way to differentiate between family and project parameters. If you were to get 2 family instances from different families in the same category, the project parameter would appear on both (as it will be bound to all elements in the category), while the family parameter would only be found on one.

Message 4 of 6
chris
in reply to: Scott_Wilson

the problem comes, if you have only one door loaded that contains a Project Parameter called "test" and a Family Parameter called "test", and 2 instances of that door, there is no way of determining which parameter is a Project and which is a Family Parameter... mapping would work if you had two doors loaded as then you could determine which parameter "test" is the project one as the Id would be the same across both instances.

Message 5 of 6
Scott_Wilson
in reply to: chris

Yeah, that's the problem. Maybe you could create a new type of the family then set the default of the suspect parameter to a known value. Create an instance of that type and check which parameter contains the value. There are ofcourse many factors to consider here such as value storage types and whether the value entered will be valid for the family. It might be worth checking existing family types to see what the default values are then instance a type and check for the default. You'll still get stuck if all defaults are zero/blank though...

 

If the domain of the problem is restricted to a single or just a few categories, you could load in a pre-made minimal family of the appropriate category to use as proxy.

 

I also wonder whether the Definition objects found within the ParameterBindings can be matched to the Definition found in a live parameter using the .Equals() method?

 

 

Message 6 of 6
Scott_Wilson
in reply to: Scott_Wilson

Try this code out with a family instance selected. I think this technique will be key to solving your problem.

 

UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document dbDoc = uiDoc.Document;

Element selectedElem = dbDoc.GetElement(uiDoc.Selection.GetElementIds().First());

BindingMap bindings = dbDoc.ParameterBindings;

String resultString = "";

foreach(Parameter param in selectedElem.Parameters)
{					
	if(bindings.Contains(param.Definition))
	{
		resultString += "\n" + param.Definition.Name + ": Parameter Found!!!\n\n";
	}
	else
	{
		resultString += param.Definition.Name + ": Not Found...\n";
	}
}

TaskDialog.Show("Parameter Search Results", resultString);

 

The element's parameter definitions that are found in the bindings are project parameters (either shared or non-shared, easy to check) while the definitions not found are either Built-In parameters (easy to check) or specific to the family.

 

I'm pretty sure that should be enough to select the correct parameter for any situation.

 

 

 

 

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community