Rotate True North

We have previously looked at how to handle the

project location
properties
and more specifically how to handle the effect of a

rotated Project North
on
an element azimuth.

Here is a question on the ‘opposite’ topic, how to set up a project north rotation in the first place:

Question: Is there any way to rotate the truth north using the Revit API?

It can be done in the user interface using the Manage > Project Location > Position > Rotate True North command:

Rotate True North in Japanese

Here is the English command with its expanded tooltip:

Rotate True North in English

Answer: I believe the same effect can be achieved by rotating the Project North which is available in the API.

If this fits the bill, then here are some working code snippets making use of the related classes and methods:


  ProjectLocation plCurrent
    = _doc.ActiveProjectLocation;
 
  // . . . 
 
  ProjectPosition newPosition
    = _app.Create.NewProjectPosition(
      scaleToFT * cs.OriginX,
      scaleToFT * cs.OriginY,
      scaleToFT * cs.OriginZ,
      theRotationYouWant );
 
  plCurrent.set_ProjectPosition(
    ptOrigin, newPosition );

You may have to do this for all project locations.
A bit of 3D maths and brainwork may be required, but it should be doable.

Many thanks to Katsuaki Takamizawa and Miroslav Schonauer for this discussion and suggestion!


Comments

16 responses to “Rotate True North”

  1. Alfredo Medina Avatar
    Alfredo Medina

    Hello, Jeremy
    How do you write Rotate True North in Mandarin? Now I know, it’s on your first image (above).
    :)

  2. Hi Alfredo,
    Mandarin is Chinese, not Japanese, I think.
    But nontheless, both of them look quite strange.
    It shows how important icons are.
    Best regards,
    Rudolf

  3. My understanding is that rotation of True North only changes the view, the document and elements should not be affected.
    Then, after rotating the true north, I assume that the Document.ActiveProjectLocation.GetTotalTransform() and Document.ActiveProjectLocation.GetTransform() should return different results, the first one includes trueNorth effect, the latter one does not.
    However, after rotating the true north, I found they got the same result, both reflecting true north rotation.
    Could you please help me with that? How can I tell rotation of true north and project north? Should the two GetTransform() functions return different results for the two cases?
    Thanks a lot:)

  4. Dear Sa Li,
    My understanding of this is limited. At the DevLab last week, one participant said that rotating the true north is an absolutely crazy thing to do, affects everything, and should be completely avoided. He questions the sense of having such a command at all.
    I would suggest resolving this issue from a product point of view first. Maybe simply avoid rotating the true north, make it completely taboo, and the issue is resolved.
    All I can say is that you can bring element geometry into real world coordinates by applying the project location transform as described in
    http://thebuildingcoder.typepad.com/blog/2010/01/project-location.html
    I do see that the Revit API documentation states the difference that you are testing between the ProjectLocation members GetTotalTransform and GetTransform.
    I’ll check this with the development team.
    However, why do you care?
    Cheers, Jeremy.

  5. Dear Sa Li,
    I heard back from the development team, and they confirm that the difference between the two is the relationship to True North.
    If you can reproduce the problem please send me some ready-to-compile source code for this with an exact description of the steps to reproduce the issue.
    If you are an ADN member, please submit an ADN case for this and attach the files to that.
    Thank you!
    Cheers, Jeremy.

  6. Hi, Jeremy,
    Thanks a lot for your replies.
    I have tried to play with the Revit 2012 with updates 2, and after rotating true north, in any external command implementation, we can find current Document.ActiveProjectLocation.GetTotalTransform() and the GetTransform() return the same results, both reflecting the true north changes. While if before applying true north changes, an external instance is created, then we can retrieve the instance after rotating true north, its transform is still Identity, which is correct and that is what we want to get.
    As for our case, we are planning to add some external Instance to the existing project, and can be opened explicitly after user opens some project. And the transformation of the instance should be correct. Then, if user creates a project, rotates true north, then open the external Instance files, then trouble comes, we cannot get the correct Instance transformation when creating it.
    Thank you so much for your kind helps and wish to hear from you about the problem:)

  7. Dear Jeremy,
    Do you have any feedback for the question about GetTotalTransform() for the true north rotation?
    Thanks a lot for your time and helps:)
    Best Regards,
    Sa Li

  8. Dear Sa Li,
    Nope, no more news. All I can say is stated above. Good luck!
    Cheers, Jeremy.

  9. Dear Jeremy,
    How to place family at the end of pipe connector so that it dont need to rotate rather it automatically get rotated like manually working in Revit Mep API 2013.
    Thanks & Regards,
    Namit.

  10. Frank Halliday Avatar
    Frank Halliday

    Hi Jeremy,
    How can I find the direction the user rotated the true north(ie Clockwise or Counterclockwise)?
    This as I understand it determines if the BuiltInParameter.BASEPOINT_ANGLETON_PARAM is equal to some rotation say 90 deg or the negative -90 (which will return 270 deg).
    //here is an example of some of my code…
    FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_ProjectBasePoint;
    IList elements = collector.ToElements();
    //get first element
    Element projectInfoElement = elements.First();
    //get project info, project status parameter
    BuiltInParameter BIP_TrueNorth = BuiltInParameter.BASEPOINT_ANGLETON_PARAM;
    Parameter param_TrueNorth = projectInfoElement.get_Parameter(BIP_TrueNorth);

  11. Dear Frank,
    There are some interesting observations on this issue in the other comments above.
    Do they help at all?
    In addition, you can take a look at the The Building Coder sample command ‘Unrotate North’, implemented in the class CmdUnrotateNorth:
    https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdUnrotateNorth.cs
    When I select a single wall in a newly created project and run it, it displays a dialogue box that says:
    Selected element location: (0.58,0.84,0)
    Angle between project north and true north: 0 degrees
    Unrotated element location: (0.58,0.84,0) (0.58,0.84,0) (0.58,0.84,0)
    After rotating the true north 90 degrees clockwise using Manage > Project Location > Position > Rotate Project North, it displays the following for the same element:
    Selected element location: (0.84,-0.58,0)
    Angle between project north and true north: 90 degrees
    Unrotated element location: (0.58,0.84,0) (0.84,-0.58,0) (0.58,0.84,0)
    To answer your question in a second way by retrieving the rotation of the Project Base Point via the BASEPOINT_ANGLETON_PARAM built-in parameter, I added the following lines based on your sample code to the command:
    Element projectInfoElement
    = new FilteredElementCollector(doc)
    .OfCategory(BuiltInCategory.OST_ProjectBasePoint)
    .FirstElement();
    BuiltInParameter bipAtn
    = BuiltInParameter.BASEPOINT_ANGLETON_PARAM;
    Parameter patn = projectInfoElement.get_Parameter(
    bipAtn );
    double atn = patn.AsDouble();
    Debug.Print(
    “Angle to north from project info: {0}”,
    Util.AngleString( atn ) );
    In the first case, it reports:
    Angle to north from project info: 0 degrees
    After rotating 90 degrees clockwise, it reports:
    Angle to north from project info: 270 degrees
    That seems to me to indicate the direction perfectly well: 90 degrees is one direction, 270 the other.
    I hope that makes sense.
    The updated version of the command is provided in the version 2015.0.110.3 or The Building Coder samples:
    https://github.com/jeremytammik/the_building_coder_samples/releases/tag/2015.0.110.3
    Cheers, Jeremy.

  12. Dear Frank,
    I also briefly mentioned the updated version of The Building Coder and enhancements made to explore this issue here:
    http://thebuildingcoder.typepad.com/blog/2014/08/document-version-guid-and-number-of-saves.html#3
    I hope this helps.
    Cheers, Jeremy.

  13. Frank Halliday Avatar
    Frank Halliday

    Thank you Jeremy,
    I will have to get back to you on this one after some reading, there are still questions in my mind about what the true north value reads relative to the project north, for example what happens after a user rotates the project north 180 deg?

  14. Frank Halliday Avatar
    Frank Halliday

    Also, can the project north rotation be accessed? which object stores it?

  15. Frank Halliday Avatar
    Frank Halliday

    ok,
    I should have read the post you provided a link to thanks again Jeremy.

  16. Dear Frank,
    Thank you for your appreciation.
    I am sure you will resolve your issue.
    Good luck!
    Cheers, Jeremy.

Leave a Reply to Frank HallidayCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading