How to position a FamilyInstance with the elements of Transform?

How to position a FamilyInstance with the elements of Transform?

pmeigneux
Advocate Advocate
461 Views
3 Replies
Message 1 of 4

How to position a FamilyInstance with the elements of Transform?

pmeigneux
Advocate
Advocate

Hello,

I want to position Family instances using BasicX, BasicY, BasicZ as well as Origin information.

I didn't prove in Create.NewFamilyInnstance this possibility so I used Doc.Create.NewFamilyInstance(xyz, familySymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

How to do the rotations so that the positioning is correct?

462 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

I am not aware of any method named NewFamilyInnstance with two lower-case 'n'. NewFamilyInstance comes equipped with quite a number of different overloads:

  

  

You need to choose the appropriate overload depending on the type of instance and instance placement that your specific family requires. Arbitrary free-floating placements in space are quite unusual within a building. Most BIM elements need some kind of support that is provided by some other BIM host element.

  

Here are some further discussion of various placement options:

  

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 4

architect.bim
Collaborator
Collaborator

Hi!

To rotate the created FamilyInstance get its Location and use the Rotate method:

 

f_instance = doc.Create.NewFamilyInstance(origin, f_symbol, structural_type)
f_instance.Location.Rotate(
    DB.Line.CreateUnbound(origin, DB.XYZ.BasisZ),
    angle
)

To calculate the angle use math trigonometric functions or AngleTo method.

 

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 4 of 4

pmeigneux
Advocate
Advocate

 

// Prepare rotate

Transform PositionAbs = ...;
XYZ axisX = PositionAbs.OfVector(PositionAbs.BasisX);
XYZ axisY = PositionAbs.OfVector(PositionAbs.BasisY);
XYZ axisZ = PositionAbs.OfVector(PositionAbs.BasisZ);

 

// rotate by X axis
double rotXRadian = PositionAbs.BasisX.AngleTo(axisY);

// rotate by Y axis
double rotYRadian = PositionAbs.BasisY.AngleTo(axisZ);

 

// rotate by Z axis
double rotZRadian = PositionAbs.BasisZ.AngleTo(axisX);

 

No Rotate ==> rotXRadian = rotYRadian  = rotZRadian  = Pi/2

Rotate 180 degre on X ==> rotXRadian  = Pi/2

 

It does not work..

 

Philippe.

0 Likes