Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66677

load and place an familyobject => System.NullReferenceException

$
0
0

Hi all, 

 

i am trying to load and place an familyobject.

i am using this topic from jeremy tammik: 

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

 

 

my code since now:

 

 

public void FloorMacro()
		{
		UIDocument uiDoc = this.Application.ActiveUIDocument;
                Document doc = uiDoc.Document;

                XYZ location = new XYZ(0, 0, 0);
                string filePath = @"D:\Familie1.rfa";
                Family family;
                
 
                       using( Transaction trans = new Transaction( doc ) ) {
                	    trans.Start("start");
                
                           //load the family
                           doc.LoadFamily(filePath, out family);
                
      
                           trans.Commit();
                       }

                FamilySymbol symbol = null;
                
                      //choose the familysymbol
                      foreach( ElementId id in family.GetFamilySymbolIds() )  {
                	    symbol = doc.GetElement( id ) as FamilySymbol;
                		// Our family only contains one
                		// symbol, so pick it and leave
                		break;
              	      }
                
                symbol.Activate();
                
                
                //place the familyinstance
             	uiDoc.PromptForFamilyInstancePlacement( symbol );
		}

the problem is that i always get this error when i run the macro:

 

System.NullReferenceEcxeption

 

 

I hope that someone can help me to solve that Problem.

 

Thanks a lot!

 

 


Viewing all articles
Browse latest Browse all 66677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>