Family Instance Placement

One issue that keeps cropping up is how to determine which

NewFamilyInstance overload
to
use to place an instance of a given family.

As always, you need to first ensure that the desired workflow can be achieved manually through the user interface.

If anything fails in the interactively driven steps, it certainly will not work better when driven programmatically, and the user interface will provide much richer information on possible failure reasons.

The first place to look for information on driving this programmatically this is the Revit API Developer Guide Wikihelp section on

FamilyInstances
and
<!–
http://wikihelp.autodesk.com/Revit/enu/2013/Help/00006-API_Developer%27s_Guide/0074-Revit_Ge74/0083-Family_I83/0086-FamilyIn86#GUID-5163F12D-96E2-42A3-8B10-FBBCE24A6A12

<

div class=”ad-import-section”>

<

div id=”section_14″>


Creating FamilyInstance Objects

T
–>

creating FamilyInstance objects
.

We looked at a large number of different examples of programmatic family instance placement and how to determine the correct NewFamilyInstance overload to use in the past, as you can see by simply searching globally for

revit api newfamilyinstance overload
.

Here are two important testing tools for this that were discussed back in 2010:

  1. PlaceInstancesOnViews:
    This method tests placing a specific family instance in all views, to ensure that an instance can indeed be placed in a view using a specific NewFamilyInstance overload.

  2. TestAllOverloads
    :
    This method calls all possible overloads of NewFamilyInstance in order to find one that works.

Since then, a couple of enhancements have been added to the Revit API to simplify this task.

Here two important pieces of functionality to help clarify the family instance placement type up front, cited from the What’s New section of the Revit 2013 API help file RevitAPI.chm:

NewFamilyInstance validation

Some validation has been added to overloads of NewFamilyInstance.
This validation is intended to prevent use of the incorrect overload for a given family symbol input.
For specific details on the exceptional conditions that will be validated, consult the documentation.

Family.PlacementType

This new property provides information about the placement type for instances of the given family. PlacementType roughly maps to the overloads of NewFamilyInstance.

The first enhancement automatically notifies you if you try to place an instance with some invalid input and can cause issues where previously apparently working code now raises an exception.

The second one is something you have to be aware of yourself, though.

I hope you make a note of these possibilities and find them helpful when you next run into any programmatic family instance placement issues.


Comments

4 responses to “Family Instance Placement”

  1. I recently discovered the following which seems to select the correct overload for the given family (on the small number of occasions I have tried it). Not sure how it deals with an incorrect view type for the family however.
    UIDocument.PromptForFamilyInstancePlacement
    This was introduced in the 2011 API apparently. My question would be as to what are the limitations of it?

  2. Dear Mr Smith,
    Yes, indeed, PromptForFamilyInstancePlacement always selects the correct overload of the NewFamilyInstance method.
    Or, actually, no, it does do anything of the kind.
    The NewFamilyInstance is the Revit API method, whereas the PromptForFamilyInstancePlacement does whatever it does inside of Revit without ‘going out’ to the .NET environment and calling ‘back in’ to Revit via the API.
    The only limitation I am aware of is that this method does whatever it does, and you have no access to modify that behaviour.
    Here are some related discussions:

    Place Family Instance
    Place Site Component
    Place Furniture Instance
    Launching a Revit Command
    Loading an Inventor ADSK Component
    Drag and Drop to Revit
    Drag and Drop API
    Family API Add-in – Load Family and Place Instances
    Set a Suitable View for Family Instance Placement

    Cheers, Jeremy.

  3. Hi Jeremy,
    I have been reading you quite a bit in the paste few years and always manage to get my way through the big RVT monster.
    today, I face a new pb. I am trying to schedule a generic annotation that is across a linked file. – I know. I can’t.-
    the way I thought I could was to load the family of the linked file in my Central and then place it in a legend view – I have couple of hundreds instances of this family – the idea is OK but I forgot you cannot drag and drop all instances at once.
    any help would be appreciated / and or / an other method!

  4. Dear Jmc,
    Nice to hear that you are a regular, and were able to address all your needs so far.
    Whether or not you can or cannot drag and drop all instances at once ought to be irrelevant.
    Since the advent of the drag and drop API, you can drive that operation programmatically:
    http://thebuildingcoder.typepad.com/blog/2013/05/copy-and-paste-api-applications-and-modeless-assertion.html
    You computer should not be too much bothered by such a repetitive task.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading