DWF View Definition

Here is a question related to the 3D views in Revit, i.e. standard, top, left, bottom, etc. and user created, and the corresponding ones in a DWF file.
The issue concerns the relationship between the internal Revit coordinate system and the exported coordinates in DWF.
For instance, how to create a 3D DWF with a custom view using the coordinates of the 3D view defined in Revit.
In a DWF file, the view is determined by

  • Camera position
  • Target toward which the camera is pointing
  • Up vector
  • Width
  • Height

Here is a description of these parameters from the

HOOPS/3dGS Programming Guide
.
These parameters are defined for the standard views in one of the XML files contained in the DWF file.

In Revit, the view is determined by the ViewDirection, UpDirection, and EyePosition properties of the View3D class in the Revit API.
When exporting a Revit file to DWF in Revit Architecture 2009, the parameters of the top view in the DWF file, for example (position, target, up vector), are different from the top view properties in Revit.
Here are the approximate values of the top view parameters extracted from the Revit file and its corresponding DWF file:

Revit top view:

  • Eye position: 16.47, 7.45, 31.58
  • Up direction: 0, 1, 0
  • View direction: 0, 0, 1

DWF top view:

  • Position: 10, 15.01, -7.5
  • Target: 10, 0, -7.5
  • Up: 0, 0, -1
  • Field width: 48.045
  • Field height: 48.045

Question:
What transformation should I apply to the 3D coordinates of view parameters in Revit so that I can get the corresponding 3D coordinates in DWF?
When I create custom views in Revit I want to make them available and apply them in the corresponding DWF file as well.
I also need to calculate the field width and height parameters of the DWF view, which do not have analogues in the Revit 3D view.

Answer:
Here are the transformations used to calculate the parameters of a DWF view from the Revit view.
The camera for the default view and named views are defined slightly differently.

This is the definition for the default view:

  • DWF Position = Rvt_Position.x, Rvt_Position.z, -Rvt_Position.y;
  • DWF Up Vector = Rvt_UpVector.x, Rvt_UpVector.z, -Rvt_UpVector.y;
  • DWF Target = Rvt_TargetPos.x, Rvt_TargetPos.z, -Rvt_TargetPos.y;
  • DWF Field of View = Rvt_FieldOfView.Width, Rvt_FieldOfView.Height;

This is the one for a named view:

  • unitScale = recorded in DWF as part of the transformation;
  • DWF Position = Rvt_Position.x / unitScale, Rvt_Position.z / unitScale, -Rvt_Position.y / unitScale;
  • DWF Up Vector = Rvt_UpVector.x / unitScale, Rvt_UpVector.z / unitScale, -Rvt_UpVector.y / unitScale;
  • DWF Target = Rvt_TargetPos.x / unitScale, Rvt_TargetPos.z / unitScale, -Rvt_TargetPos.y / unitScale;
  • DWF Field of View = Rvt_FieldOfView.Width / unitScale, Rvt_FieldOfView.Height / unitScale;

Actually, the transformation for the default view is just a special case of the named view one with the unit scale set to one.

Many thanks to Joe Ye for handling this case!


Comments

10 responses to “DWF View Definition”

  1. Hello.
    Can Not understand what assign components of the camera (Position, Target, Up, Field) knowing object extents (Back, Front, Top, Bottom, Right, Left)?
    Shall very grateful for help.

  2. Dear Sari,
    I have to tell you that this is currently not possible through the API. Sorry about that.
    Cheers, Jeremy.

  3. Hi Jeremy,
    Is it possible to get the camera zoom level through the API? I see that I can get camera position, view direction and possibly FOV but how about zoom?

  4. Dear Jeff,
    No, I am sorry to say that I do not believe that is possible right now, since I see an open wish list item for that functionality.
    Cheers, Jeremy.

  5. Jeremy,
    Thanks. Wow, hopefully they can get this into the next release.
    Jeff

  6. Hello Jeremy and Jeff,
    From the question of Jeff above, it seems that it is possible to get the camera position, view direction and FOV. Is it possible to set these values using the API?
    Thanks,

  7. Dear Amin,
    The wish list item I referred to is for an API to get and set the zoom factor of a view.
    I think Jeff is also referring to setting up a view.
    For that you might want to have a look at
    http://thebuildingcoder.typepad.com/blog/2009/12/crop-3d-view-to-room.html
    Cheers, Jeremy.

  8. Mohan Sawant Avatar
    Mohan Sawant

    Hi Jeremy,
    Can you please tell me how I can get Rvt_TargetPos using api. Currently Revit View3D class gives me position, viewdirection and upvector. I need the target and FOV.

  9. Dear Mohan,
    Thank you for posting your query here.
    I am checking with the development team whether and how this can be accessed.
    Cheers, Jeremy.

  10. Dear Mohan,
    I received a helpful answer from Arnošt Löbel for you and published it for all to enjoy right away:
    http://thebuildingcoder.typepad.com/blog/2014/09/custom-exporter-getcamerainfo.html
    Cheers, Jeremy.

Leave a Reply to AminCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading