« PickObject Requires Valid View | Main | MEP Sample Code for Revit 2012 »

August 08, 2011

Comments

Jeremy, your blog is awesome. I had exactly the same question as this poster and your answer of “GetLabelFor” was spot on what I needed. Thank you very much for producing such a wonderful Revit API resource.

Dear Phillip,

Wow, thank you very much for your appreciation!

I am glad it hit the nail on the head :-)

Cheers, Jeremy.

Dear Jeremy,

I would like to have the geometry data of component elements such as width, thickness, height of windows, doors, and other furniture. I've tried with Built-in Parameters such as WINDOW_WIDTH (for windows elements) or other parameters related to Width of Element.Parameters, but unfortunately the results returned from method AsValueString() always "0.0" Could you tell me how I could do to retrieve this kind of data.

Schönes Wochenende.

Viele Grüße,

Trang

Dear Trang,

Accessing this data via family parameters depends on the family definition, which is freely defined by the user, so there are no fixed rules.

You have to explore each family definition whose data you wish to access and adapt to that.

Cheers, Jeremy.

Some parameters have values get from other enumerations, for example: "Condition Type" parameter gets values from ConditionType enumerated type. Is the possibility to get
correspondence between property and enumerated type for its values?

Is it possible to make easily than this code?
private int selectEnumValue(string paramName, string paramValue)
{
int intValue = -1;
Type paramEnum;
switch (paramName)
{
case "Condition Type":
paramEnum = typeof(ConditionType);
break;
case "Return Airflow":
paramEnum = typeof(ReturnAirflowType);
break;
case "Space Type":
paramEnum = typeof(SpaceType);
if (!(paramValue.Replace(" ", "").Equals("NoSpaceType", StringComparison.OrdinalIgnoreCase) ||
paramValue.Replace(" ", "").Equals("", StringComparison.OrdinalIgnoreCase)))
paramValue = "k" + paramValue;
break;
default:
paramEnum = null;
break;
}
if (paramEnum != null)
{
string[] enumNames = paramEnum.GetEnumNames();
for (int i = 0; i < enumNames.Length; i++)
{
if (enumNames[i].Equals(paramValue.Replace(" ", "").Replace("-", "").Replace(@"/", "Or"), StringComparison.OrdinalIgnoreCase))
{
intValue = i;
break;
}
}
}
return intValue;
}

Dear Anatoly,

Thank you for your interesting question and suggestion.

Sorry I took so long to respond, I have a large backlog of cases and comments and stuff.

The only thing I can think of to simplify and simultaneously complexify it would be to apply pattern matching between the parameter name and the enumeration names.

For instance, you could split the parameter name on white space and search for an enumeration name that contains all of the fragments.

That would be a pretty reliable way to ensure they match, wouldn't it?

And fun and elegant too, I think.

That might even be worth a blog post on its own, I think.

Cheers, Jeremy.

Hi I want to change the built in parameter worksetID, to the workset ID of another element, how can i do this?

Dear Frank,

http://thebuildingcoder.typepad.com/blog/2013/01/change-element-workset.html

Cheers, Jeremy.

Hi,Jeremy,your blog is amazing! On revit 2013, I got an error "Cannot find the BuiltInParameter STAIRS_LANDINGTYPE_TREADRISER_TYPE."when " foreach (BuiltInParameter bip in Enum.GetValues(typeof(BuiltInParameter))){strDetail = Autodesk. Revit.DB.LabelUtils.GetLabelFor(bip);}",Is there something changed with API2013?
BTW, you and Joe Ye really did a good job for our beginners, thank you so much!
Howie

Dear Howie,

Thank you for your appreciation. I'll pass it on to Joe as well. I am very glad to hear you find it useful.

Yes, the whole stair implementation was substantially updated in Revit 2013:

http://thebuildingcoder.typepad.com/blog/2013/03/whats-new-in-the-revit-2013-api.html

Search for 'Major Enhancements to the Revit API' and 'Stairs and railings API'.

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource