IFamilyLoadOptions implementation in revit 2013

IFamilyLoadOptions implementation in revit 2013

Anonymous
Not applicable
1,260 Views
7 Replies
Message 1 of 8

IFamilyLoadOptions implementation in revit 2013

Anonymous
Not applicable

Ive been using the IFamilyLoadOptions implementation in previous version of Revit to get around the dialog box appearing when loading families already loaded in revit. This no longer works in 2013. Is there another way to do this? Thanks for your help.

Accepted solutions (1)
1,261 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Is this what you are looking for?

namespace ProjectStartup
{
  [Transaction(TransactionMode.Manual)]
  [Regeneration(RegenerationOption.Manual)]

 public class Application : IExternalApplication
 {
   public Result OnStartup( UIControlledApplication application )
   {
   application.DialogBoxShowing += new 
     EventHandler<DialogBoxShowingEventArgs>(Project_DialogBoxShowing);
   return Result.Succeeded;
  }

  public void Project_DialogBoxShowing(Object sender, DialogBoxShowingEventArgs args)
  {
  TaskDialogShowingEventArgs args2 = args as TaskDialogShowingEventArgs;
  if (null != args2)
   {
   // Use this message box to display the ID of the task dialog. 
   // (Or search journal file)
   //MessageBox.Show("Dialog ID = " + args2.DialogId);
   if (args2.DialogId == "TaskDialog_Family_Already_Exists")
    {
    // Buttons with custom text have custom IDs with incremental values
    // starting at 1001 for the left-most or top-most button in a task dialog. 
    // "Overwrite the existing version", "1001"
    args2.OverrideResult(1001);
    // "Overwrite the existing version and its parameter values", "1002"
    //args2.OverrideResult(1002);
    }
   }
  }
 }
}

 

Message 3 of 8

Anonymous
Not applicable

Tried this already. For some reason it does not work when family already exist in model. It suppresses the dialog, but it does not update family.

0 Likes
Message 4 of 8

Anonymous
Not applicable

After looking a little further, I did run across this before. My solution was to delete the family in the project and then load it in.

Here is a code snippet from 2011. I was using TransactionMode.Automatic, so it may require a transaction. m_doc is the project file, f_doc is a family that has been modified, processfam is f_doc.Name.

                // Delete the family file in the project because it seems to error out if the file is still there
                m_doc.Delete(processfam);
                
                // Load the processed family back into the project
                processfam = f_doc.LoadFamily(m_doc);

 

0 Likes
Message 5 of 8

Anonymous
Not applicable

Dear peterjegen, Deleting the family is not an option since there are instances of these families in the model.

 

Thanks for your help.

 

Edited by
Discussion_Admin

0 Likes
Message 6 of 8

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Ken,

 

As we discussed in your ADN case 07540072 [IFamilyLoadOptions implementation in revit 2013], the basic issue appears to be the simple migration of the IFamilyLoadOptions implementation from the Revit 2012 to the 2013 API.

 

This just requires the 'ref' argument modifiers to be replaced by 'out', i.e. you need to implement

 

  bool OnFamilyFound(
    bool familyInUse,
    out bool overwriteParameterValues )

  bool OnSharedFamilyFound(
    Family sharedFamily,
    bool familyInUse,
    out FamilySource source,
    out bool overwriteParameterValues )

instead of

 

  bool OnFamilyFound(
    bool familyInUse,
    ref bool overwriteParameterValues )

  bool OnSharedFamilyFound(
    Family sharedFamily,
    bool familyInUse,
    ref FamilySource source,
    ref bool overwriteParameterValues )

I wish you a nice weekend!



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

0 Likes
Message 7 of 8

Anonymous
Not applicable
Dear Jeremy, That did it! It works perfectly. Thanks for all your help and have a great weekend. Best Regards, Ken Hostetter ________________________________ NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer.
0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

Great, I am glad! Thank you for the appreciation!



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

0 Likes