Why I can't to load one family to another?

Why I can't to load one family to another?

Anonymous
Not applicable
325 Views
1 Reply
Message 1 of 2

Why I can't to load one family to another?

Anonymous
Not applicable

On debugging the following code I have an exeption on load method (shown bold)

 

string templateFileName = @"C:\Documents and Settings\All Users\Application Data\Autodesk\RVT 2014\Family Templates\Russian\Метрическая система, типовая модель.rft";
            Document familyPlate = externalCommandData.Application.Application.NewFamilyDocument(templateFileName);
            
            Transaction transaction = new Transaction(familyPlate, "pop");
            transaction.Start();
            familyPlate.OwnerFamily.Name = "Plate";
            familyPlate.FamilyManager.NewType("Plate Type 1");
            transaction.Commit();
            familyPlate.SaveAs(@"D:\Arhive\Visual Studio\HelloWorld\1.rfa");

            Document familyBlock = externalCommandData.Application.Application.NewFamilyDocument(templateFileName);


            Transaction transaction2 = new Transaction(familyBlock, "pop2");            
            transaction2.Start();
            familyBlock.LoadFamily(familyPlate);
            transaction2.Commit();
            familyBlock.SaveAs(@"D:\Arhive\Visual Studio\HelloWorld\2.rfa");
            return Autodesk.Revit.UI.Result.Succeeded;

0 Likes
326 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Dear lebedun,

 

I cannot really answer the question without more context.

 

I would suggest reducing the code to the absolute minimum, step by step, until the error goes away, and noting what is causing the problem.

 

Alternatively, restart coding from zero and add line by line until it fails to find out what is causing the error.

 

There are numerous examples on The Building Coder blog demonstrating how to call LoadFamily successfully, most notably for the recent Family API class at the Russian DevCamp in Moscow:

 

http://thebuildingcoder.typepad.com/blog/2013/06/family-api-add-in-load-family-and-place-instances.h...

 

You could use that as a working starting point.

 

You also have to check that you can successully perform the required steps manually through the user interface before you start trying to automate them programmatically, of course.

 

Best regards,

 

Jeremy

 

 



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

0 Likes