Family Element Visibility

Here is a question on programmatically setting the visibility of an element in a family document:

Question: I need to assign a Yes/No parameter to the visibility property of a family feature, e.g. an extrusion element.
I need to do this to suppress a specific extrude feature for certain types.
I know how to do it manually, by selecting the feature and then clicking the visibility toggle in the element properties.
How can I achieve it through the API?

Answer: I created a sample family to test this by adding an extrusion element in a new family document using the Metric Generic Model template.
On the extrusion, I can see the property you refer to in the element properties as the Properties > Graphics > Visible toggle, which is displayed as a Boolean check box in the user interface:

Family extrusion element visible property

If I look at the extrusion element using RevitLookup, I see that this property is available through the element parameters: Add-Ins > Revit Lookup > Snoop Current Selection > Extrusion > Parameters > Visible with the corresponding built-in parameter IS_VISIBLE_PARAM:

Family extrusion element visible parameter

You can access this using the standard get_Parameter method on the extrusion element.

We made significant use of this property and showed how to hook it up with an externally accessible family parameter so that it can be controlled from outside on individual instances of the family inserted into the project file in the discussion on

DWG and DWF family creation
.

Note that if you wish have more detailed control over the visibility of the feature, you can also use its visibility property returning an instance of the FamilyElementVisibility class:

Family extrusion element visibility property

The Revit API help file RevitAPI.chm description of the FamilyElementVisibility class includes some sample code on using this.
Its use to set up different visibility of family elements for different detail levels of the inserted instances is also demonstrated by step 4 of the

Family API labs
.


Comments

5 responses to “Family Element Visibility”

  1. Jeremy,
    very informative post about FamilyElementVisibility!
    I am curious if its possible to control the settings on DetailFamily Instance in a similar way? I am placing a detail family instance in my door family and i want to show the detail family only when the door is being cut, I know while placing this family thru UI, I can access the visibility/graphics settings and check the little box which says ‘show only if instance is cut’, however, I can not access these properties programmatically, not sure what I am missing!

  2. oh never-mind! I found it!!
    By using snoop-debugger its really convenient to find answers for things like this!
    thanks..

  3. Dear Sami,
    Congratulations on solving your issue!
    Yes, RevitLookup really is an invaluable tool!
    Cheers, Jeremy.

  4. Hi Jeremy,
    I’m working with Yes/No parameters in an extension I’m writing. I added a yes\No parameter to the doors and added it to a schedule but it doesn’t behave as expected.
    When I first added the Yes\No parameter the column in the schedule is blank and the checkbox looks greyed out in the Properties palette. When I click the check box, the schedule shows “Yes” in the column. When I uncheck the checkbox the schedule shows “No” in the column. The checkbox on the properties palette looks normal after checking or unchecking the checkbox.
    When I set the Yes\No parameter through the API to 0 or 1 using parameter.set(). Nothing happens.
    Is there something I’m missing with these parameters?

  5. Dear Paul,
    Setting the parameter value to 0 or 1 through the API should have the same result as checking or unchecking it through the API, afaik.
    Cheers, Jeremy.

Leave a Reply to samiCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading