how do i get rotation of wall using revit api?

arvind.maurya37
Contributor
Contributor

how do i get rotation of wall using revit api?

arvind.maurya37
Contributor
Contributor

How do i get rotation of wall using revit api?
 if a Element is family instance then

 (FamilyInstance.Location as LocationPoint).Rotation;

i can easily get a the rotation easily.


if i try for wall

Curve curve = ((Wall).Location as LocationCurve).Curve;

or any thing like that.

 

 

 

0 Likes
Reply
Accepted solutions (1)
5,029 Views
5 Replies
Replies (5)

so-chong
Advocate
Advocate

Hi,

 

The Revit API Developers Guide has some examples (Code Region 10-6)

Maybe this is helpful to you.

 

http://help.autodesk.com/view/RVT/2019/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Basic_Interact...

 

Hope this helps.

0 Likes

arvind.maurya37
Contributor
Contributor

Hii,

thanks for the reply.

(Code Region 10-6)

bool LocationRotate(Autodesk.Revit.ApplicationServices.Application application, Autodesk.Revit.DB.Element element)
{
    bool rotated = false;
    // Rotate the element via its location curve.
    LocationCurve curve = element.Location as LocationCurve;
    if (null != curve)
    {
        Curve line = curve.Curve;
        XYZ aa = line.GetEndPoint(0);
        XYZ cc = new XYZ(aa.X, aa.Y, aa.Z + 10);
        Line axis = Line.CreateBound(aa, cc);
        rotated = curve.Rotate(axis, Math.PI / 2.0);
    }

    return rotated;
}

above code will rotate the wall with some given angle and return true or false.

i want something like

1) drawn a wall and rotated the wall with 90 Degree.
wall given for rotation 90 degreewall given for rotation 90 degree

 

 

 

 

 

 

 

 

 

 

 

 

2) i need to get the rotation value like ( in this case it is 90 degree).wall after rotating 90 degreewall after rotating 90 degree

 

 

 

 

 

 

 

 

 

 

 

 

needed the rotated value. via api .

 

0 Likes

jeremytammik
Autodesk
Autodesk
Accepted solution

I just answered your identical question on StackOverflow:

 

https://stackoverflow.com/questions/52302648/how-do-i-get-rotation-of-wall-using-revit-api

 

If your wall curve is a straight line, you can just grab the angle from the line: let V be the vector from the wall curve start to end point, and determine its angle to the X axis:

 

  angle = V.AngleTo( XYZ.BasisX );

 

Cheers,

 

Jeremy

  



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

Anonymous
Not applicable

Hi @jeremytammik , 

 

If I want to get the rotation for a structural column element, do I need to use the "LocationPoint.Rotation" approach?

 

Regards

0 Likes

jeremytammik
Autodesk
Autodesk

I believe there are two different type of columns: vertical and tilted. 

 

https://thebuildingcoder.typepad.com/blog/2009/06/creating-a-slanted-column.html

  

I believe the vertical ones use the location point approach, and the tilted to location line.

  

https://thebuildingcoder.typepad.com/blog/2011/03/slanted-column-cross-section-rotation.html

  

Please let us know how you end up solving this.

 

Thank you!

 

Cheers,

 

Jeremy

 



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

0 Likes