New family instance ends up in 0,0,0 and not given position

New family instance ends up in 0,0,0 and not given position

ottosson_mathias
Advocate Advocate
252 Views
2 Replies
Message 1 of 3

New family instance ends up in 0,0,0 and not given position

ottosson_mathias
Advocate
Advocate

I just want to place an air terminal using the doc.Create.NewFamilyInstance. I provide a XYZ location, familySymbol and level and the element gets created. But it ends up in 0,0,0 and not in the provided position.

If I try to manually set the location after the element has been created it ends up in the position but x2(!!).

 

What am I doing wrong here?

using (Transaction trans = new Transaction(Doc, "Place Air Terminal"))
{
    trans.Start();

    FamilyInstance airTerminalInstance = Doc.Create.NewFamilyInstance(location, airTerminalSymbol, level, StructuralType.NonStructural);

    LocationPoint locationPoint = airTerminalInstance.Location as LocationPoint;

    // since the location ends up in 0,0,0 I try to change it manually,
    // but this doesn't work either... the locationPoint.Point ends up to be
    // the provided point x2!
    locationPoint.Point = location;

    trans.Commit();
}

Thanks!

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

ottosson_mathias
Advocate
Advocate
Accepted solution

Seems I was a bit too quick. The transaction needed to commit for the location to be updated.

Now it's just the z-value that's not correct.

 

Edit:
Lol! Seems I've had this issue before! Just forgot about it =P
https://forums.autodesk.com/t5/revit-api-forum/document-create-newfamilyinstance-places-element-with...

 

0 Likes
Message 3 of 3

jeremy_tammik
Alumni
Alumni

LOL indeed. My mind work in a similar way. I forgot everything I ever did. That is the main reason for Tha Building Coder blog.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open