selecting element type parameter with none element type parameters

selecting element type parameter with none element type parameters

wahedfazeli
Enthusiast Enthusiast
1,142 Views
4 Replies
Message 1 of 5

selecting element type parameter with none element type parameters

wahedfazeli
Enthusiast
Enthusiast
Is there any way to select element type parameters with none element type parameters i want to get keynote parameter with volume and area parameter of a element . I want to place if condition when my keynote parameter was specific number i put volume or area parameter of that element in specific database. Is there any way i can do this work?
0 Likes
Accepted solutions (1)
1,143 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

If you are searching for elements with a parameter taking an ElementId data type, you might be able to search for all that have the value ElementId.InvalidElementId assigned to them:

 

http://www.revitapidocs.com/2018/08ae8886-6ab3-3ef5-d2e0-0da2ffa7bd2c.htm

 

Best regards,

 

Jeremy

 



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

Message 3 of 5

wahedfazeli
Enthusiast
Enthusiast

tnx dear jeremy

my problem dont solve 

when i write this code 

foreach(Element elem in new FilteredElementCollector( doc ).WhereElementIsNotElementType()) 

this code show parameters of area and volume but no keynote or uniformat parameter.

and when i write this code .

foreach(Element elem in new FilteredElementCollector( doc ).WhereElementIsElementType()) 

this code show parameters of keynote or uniformat but no area or volume parameter.

is there any way to select all of this parameters together?

 

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor
Accepted solution

Area is a instance parameter of an element, but KeyNote is a type parameter . So you need to find the type of the element to get the keynote.

 

To find the type of an element:

Element type_of_element = doc.GetElement( elem.GetTypeId());

the basic loop is something like this:

 

foreach(Element elem in new FilteredElementCollector( doc )
        .WhereElementIsNotElementType()
        .WhereElementIsViewIndependent()
      )
{
	Parameter p_area = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);
//				string area_value = p_area==null? string.Empty : p_area.AsDouble().ToString();
	string area_value = p_area==null? string.Empty : p_area.AsValueString();
	string keynote_value = string.Empty;
	Element type_of_element = doc.GetElement( elem.GetTypeId());
	if (type_of_element!=null)
	{
		Parameter p_keynote = type_of_element.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);
		keynote_value = p_keynote==null? string.Empty : p_keynote.AsString();
		TaskDialog.Show("debug", string.Format("{0}  area: {1}, keynote: {2}",elem.Name,area_value,keynote_value));
		break;
	}
}
Message 5 of 5

wahedfazeli
Enthusiast
Enthusiast

thanks a lot. my problem is solved

0 Likes