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

load and place a 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.html#10

 

 

my code since now:

 

	public void Floormacro()	{
		UIDocument uiDoc = this.Application.ActiveUIDocument;
                Document doc = uiDoc.Document;    
                using( Transaction trans = new Transaction( doc ) ) {
                trans.Start("start");

                //familypath
                string filePath = @"D:\Familie1.rfa";
                Family family;

                //load the family  
                doc.LoadFamily(filePath, out family);
                

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

the problem is that i always gets 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 66666

Trending Articles



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