NewFamilyInstance Workaround

NewFamilyInstance Workaround

grahamcook
Advocate Advocate
673 Views
2 Replies
Message 1 of 3

NewFamilyInstance Workaround

grahamcook
Advocate
Advocate

I thought i would share what appears to be a workaround when placing new instances of families using the NewFamilyInstance method (2014).  I was using the following overload to place an electrical socket in a wall:

 

Document.Create.NewFamilyInstance(XYZ location, FamilySymbol symbol, Element host, Level level, StructuralType structuralType)

 

This was successfully placing the family instance, problem is i then wanted to flip the face using the familyInstance.flipFacing() method which always returned false even though i could flip the instance through the user interface.  But i found if i place the instance, commit the current transaction, then attempt to flip the instance in a new trasnsaction then it worked.

 

Hope this helps someone else who may be fighting similar issues with the NewFamilyInstance method.

 

Regards

 

Graham Cook

 

 

0 Likes
Accepted solutions (1)
674 Views
2 Replies
Replies (2)
Message 2 of 3

grahamcook
Advocate
Advocate

Actually, doing a Doc.Regenerate() between placing the instance and flipFacing has the same effect and is obviously more straight forward.

 

Graham Cook

0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Graham,

 

Thank you very much for this important hint.

 

Actually, the topic 'Need to Regenerate' is a big and important one.

 

Omitting a required regeneration can cause a lot of head scratching, not to mention headache:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.33

 

Cheers, 

 

Jeremy

 

 



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