Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get ViewToWorldScale in Orthographic Camera ?

10 REPLIES 10
Reply
Message 1 of 11
glib.vedmedenkoTNJYP
660 Views, 10 Replies

How to get ViewToWorldScale in Orthographic Camera ?

Hello,
I'm using the BimTrack API to create a ViewPoint and the API request requires a ViewToWorldScale value for my Orthogonal camera. I can't find it in my Viewpoint in Navis nor in the JSON of my Viewpoint camera. How can I get this value?
Best regards!

10 REPLIES 10
Message 2 of 11

Hi @glib.vedmedenkoTNJYP ,

 

I have asked the Navisworks Engineering team for you.

I will keep you posted.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 11

Hi @glib.vedmedenkoTNJYP ,

 

The Navisworks Engineering team said they don't know what "ViewToWorldScale" means. It looks like that's not something they recognize.

Could you please explain what you mean by "ViewToWorldScale"?


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 4 of 11

ViewToWorldScale.png

Hi @naveen.kumar.t 
Thanks for your reply. Here you will find an image explaining what I am looking for.
Best regards !

Message 5 of 11

Hi @glib.vedmedenkoTNJYP ,

 

I do not now if API has such scale, or it is always a fix value, or some formula to calculate.

I checked with the Engineering team and I received the below comment from the Engineering team

"No. You'd have to work it out yourself"

Sorry I have no clue how to get this value.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 6 of 11

Just happen to see this thread,

 

Regarding the `ViewToWorldScale` (i.e. Orthographic Height), I think it should be the camera's `HeightField` in Navisworks COM API, according to the Navisworks COM API documentation.

 

easonkangEDLV4_0-1689060825194.png

 

Cheers,

 

 

 

 


Eason Kang
Developer Advocate
Developer Advocacy & Support Service
Autodesk Platform Service (formerly Forge)

Message 7 of 11

Hi, does anyone managed to find a solution for this?

Message 8 of 11

tetsuya_miwa_0-1707106877150.png

Description of HeightField.
For an orthographic camera, this is the distance between top and bottom planes of the camera view frustum. Default 0.785398 (45 degrees)

Message 9 of 11

Edit: After testing this answer is incorrect

Howdy, I believe they are referring to the units of the Navisworks document, which can be found:
Autodesk.Navisworks.Api.Application.ActiveDocument.units

here is a switch statement to return the value you are looking for-

 

                case Units.Meters:
                    docUnitScaleFactor = 1.0;
                    break;
                case Units.Centimeters:
                    docUnitScaleFactor = 100.0;
                    break;
                case Units.Millimeters:
                    docUnitScaleFactor = 1000.0;
                    break;
                case Units.Feet:
                    docUnitScaleFactor = 3.28084;
                    break;
                case Units.Inches:
                    docUnitScaleFactor = 39.3701;
                    break;
                case Units.Yards:
                    docUnitScaleFactor = 1.09361;
                    break;
                case Units.Kilometers:
                    docUnitScaleFactor = 0.001;
                    break;
                case Units.Miles:
                    docUnitScaleFactor = 0.000621371;
                    break;
                case Units.Micrometers:
                    docUnitScaleFactor = 1000000.0;
                    break;
                case Units.Mils:
                    docUnitScaleFactor = 39370.0787;
                    break;
                default:
                    docUnitScaleFactor = 1.0;
                    break;

 

 Regards,

Message 10 of 11

Hi,

Just to give some tips about the last comment, you can use Autodesk.Navisworks.Api.UnitConversion.ScaleFactor(Unit from, Unit to) to get thoses numbers

Message 11 of 11

Hi @glib.vedmedenkoTNJYP 

I had to use the screenToWorld factor for my project, here is the method I used

 

double? ScreenToWorldFactor(View view, Point3D point)
{
  Viewpoint viewpoint = view.CreateViewpointCopy();
  if (viewpoint.Projection == ViewpointProjection.Perspective)
  {
    if (!viewpoint.HasFocalDistance) return null;
    return viewpoint.Position.DistanceTo(point) * (viewpoint.VerticalExtentAtFocalDistance / viewpoint.FocalDistance) / view.Height;
  }
  if (viewpoint.Projection == ViewpointProjection.Orthographic)
  {
    return viewpoint.HeightField / view.Height;
  }
  return null;
}

 

This convert any distance in pixel to world. You need to give a Point3D when the projection is perspective.

Use it like this :

double distanceInWorld = distanceInPixel * ScreenToWorldFactor(point).Value;

 

Hope it helps 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report