Change FamilyInstance Orientation

Change FamilyInstance Orientation

mizrachi_amir2
Advocate Advocate
262 Views
2 Replies
Message 1 of 3

Change FamilyInstance Orientation

mizrachi_amir2
Advocate
Advocate

Hi,

 

I have a code creating walls based on some constraints.

I am trying to add structural steel columns in each wall (in predefined margins) such that per each wall all added columns will be at the same orientation as the wall itself.

For instance (in red a single column sketched in the correct orientation as of the hosting wall): 

mizrahi_amir_0-1710871111893.png

 

I am using this line of code for adding a single FamilyInstance in my wall:

FamilyInstance fi = doc.Create.NewFamilyInstance(geomLine.GetEndPoint(0), firstColumn, firstLevel, Autodesk.Revit.DB.Structure.StructuralType.Column);

I tried to change the column orientation using fi.GetTransform().BasisX and set its value but to no avail.

 

Any suggestions how can this be achieved?

0 Likes
263 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

I assume those columns are vertical. There is a difference in column orientation between vertical and slanted columns:

  

  

For vertical columns, as in your case, it is pretty simple: just look at the column LocationPoint Rotation property:

  

  

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

mizrachi_amir2
Advocate
Advocate

Thank you, @jeremy_tammik.

Helped me a lot!

 

Eventually I did something like this to rotate the column on its place:

FamilyInstance famInst = doc.Create.NewFamilyInstance(geomLine.GetEndPoint(0), firstColumn, firstLevel, Autodesk.Revit.DB.Structure.StructuralType.Column);
Transform myTransform = famInst.GetTotalTransform();
Line myLine = Line.CreateUnbound(geomLine.GetEndPoint(0), myTransform.BasisZ);
famInst.Location.Rotate(myLine, angle);