Setting 3Dview to topview and North upwards

Setting 3Dview to topview and North upwards

Anonymous
Not applicable
1,013 Views
5 Replies
Message 1 of 6

Setting 3Dview to topview and North upwards

Anonymous
Not applicable

Hi

I have genereted some 3D views and set the target, eye and forward

But I need to set the view with north upwards, I think I have to set the Right Direction, but I can't get to that parameter !

 

Regards Anders

0 Likes
1,014 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi

 

The creation of the 3D view itself is OK, but they are all titled 90° to the right

 

Eye and up are located in the midtel og the section box and that workes fine allso the level of the target and eye of the camera

 

My code to create the 3D view look like this:

 

View3D view = View3D.CreatePerspective(mainDocument, viewFamilyType.Id);

XYZ eye = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 1);

XYZ up = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 0);

XYZ forward = new XYZ(0, 0, 1);

 

view.SetOrientation(new ViewOrientation3D(eye, up, forward));

 

Parameter EYE_ELE = view.get_Parameter(BuiltInParameter.VIEWER_EYE_ELEVATION);

EYE_ELE.Set(Alevel.Elevation + 78.75);

 

Parameter Tar_ele = view.get_Parameter(BuiltInParameter.VIEWER_TARGET_ELEVATION);

Tar_ele.Set(Alevel.Elevation + 49);

 

Hope someone can guide me 🙂

 

Regards

Anders

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Dear Anders,

 

Thank you for your query.

 

First I took a quick look at the Revit 2016 view API enhancements to see whether there is anything useful in there:

 

View3D additions

 

http://thebuildingcoder.typepad.com/blog/2015/04/whats-new-in-the-revit-2016-api.html#5.10

 

I saw nothing relevant, however.

 

Then I checked and confirmed that the View.RightDirection and View.UpDirection properties are both read-only.

 

Then I went back to the beginning and looked at your sample code snippet, where I should have started to begin with.

 

How about changing the up direction of your ViewOrientation3D?

 

As far as I can tell, you are setting it to a very strange value:

 

XYZ eye = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 1);
XYZ up = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 0);
XYZ forward = new XYZ(0, 0, 1);
view.SetOrientation(new ViewOrientation3D(eye, up, forward));

 

Note that the variable that you call 'eye' here is the eye position, which is a point.

 

The up and forward directions are vectors.

 

Therefore, it is really pretty weird to define 'up' to have the same X and Y coordintates as 'eye'.

 

How about trying something like this:

 

XYZ eye = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 1);
XYZ up = XYZ.BasisY;
XYZ forward = XYZ.BasisZ;

 

I hope this helps.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi

 

After a while I have stared on the automatic 3D views creation again, but still with no luck.

The North direction is still wrong.

When I use the eye, Up, Forward settings as below, North is turning Right insted of up

 

XYZ eye = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 1); // in the middle of the section box

XYZ up = XYZ.BasisY;
XYZ forward = XYZ.BasisZ;

 

If I swap the Up and Forward Z/Y:

XYZ eye = new XYZ((SecBMin.X + SecBMax.X) / 2, (SecBMin.Y + SecBMax.Y) / 2, 1);

XYZ up = XYZ.BasisZ;
XYZ forward = XYZ.BasisY;

 

Now I got the direction right, but the eye target is not placed in the midtel af the outer walls don't seem prarallel.

 

What do I do wrong ?

Isn't it possible to create a 3D perspective facing North ?

 

If not, is it possible to rotate the view after creation ?

 

Best Regards

Anders

0 Likes
Message 6 of 6

jeremytammik
Autodesk
Autodesk

Dear Anders,

 

Thank you for your update.

 

I do not know off-hand what might be wrong.

 

Yes, of course you can create a 3D perspective facing north.

 

Yes, you can probably rotate the view after creation as well.

 

Maybe back to basics would be best.

 

Do you understand the difference between points and vectors that I referred to in a previous answer?

 

Have you looked at the description of the views in the developer guide?

 

Maybe some study would do you good? 🙂

 

Welcome to Revit 2016 Learning

 

http://help.autodesk.com/view/RVT/2016/ENU

 

Revit API Developers Guide

 

http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-F0A122E0-E556-4D0D-9D0F-7E72A9315A42

 

Basic Interaction with Revit Elements

 

http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-54D8EFF1-5274-43D8-BD0C-68209F36BBD2

 

Views

 

http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-A7CE4D5C-8839-4CD8-817F-BE8B17F91D97

 

View3D

 

http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-A7FA8DBC-830E-482D-9B66-147399524442

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes