Macro Rotate View: Difference between revisions
(Restore the version value as before) |
No edit summary |
||
(16 intermediate revisions by 5 users not shown) | |||
Line 3: | Line 3: | ||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
{{Macro |
||
|Name=Rotate View by 90° |
|Name=Macro Rotate View by 90° |
||
|Icon=Macro Rotate View view 90 Degrees.png |
|||
|Description=This macro rotates the current view by 90° to the left. Only works if you are in Top view |
|Description=This macro rotates the current view by 90° to the left. Only works if you are in [[Std_ViewTop|Top view]]. |
||
|Author=Yorik |
|Author=Yorik |
||
|Version=01.00 |
|Version=01.00 |
||
|Date=2010-11-17 |
|Date=2010-11-17 |
||
|FCVersion=All |
|||
|Download=[https://wiki.freecad.org/images/a/a0/Macro_Rotate_View_view_90_Degrees.png ToolBar Icon] |
|||
|SeeAlso=[[Macro_Rotate_ViewAxonometric|Macro Rotate ViewAxonometric]], [[Macro_Rotate_View_Free|Macro Rotate View Free]] |
|||
}} |
}} |
||
==Description== <!--T:2--> |
==Description== <!--T:2--> |
||
This macro rotates the current view by 90° to the left. Only works if you are in Top view [[File:Macro_Rotate_View_view_90_Degrees.png|rotation 90 degrees]] |
|||
⚫ | |||
This macro rotates the current view by 90° to the left. |
|||
⚫ | |||
⚫ | |||
Only works if you are in Top view: [[Image:View-top.svg|Std_ViewTop|16px|link=Std_ViewTop]] [[Std_ViewTop|XY (top)]] |
|||
⚫ | |||
⚫ | |||
ToolBar Icon [[Image:Macro Rotate View view 90 Degrees.png]] |
|||
</translate> |
</translate> |
||
'''Macro_Rotate_View_90_Degrees.FCMacro''' |
|||
{{ |
{{MacroCode|code= |
||
import math |
import math |
||
from pivy import coin |
from pivy import coin |
||
Line 24: | Line 41: | ||
cam.orientation = nrot |
cam.orientation = nrot |
||
}} |
}} |
||
<translate> |
|||
== Description== <!--T:8--> |
|||
This code for : |
|||
# axonometric view with Y pointing upwards [[File:Macro_Rotate_View_with_Y_pointing_upwards_.png|axonometric view with Y pointing upwards]] mode 1 |
|||
# axonometric view with Z pointing upwards [[File:Macro_Rotate_View_with_Z_pointing_upwards_.png|axonometric view with Z pointing upwards]] mode 2 |
|||
For FreeCAD Version 0.16 |
|||
</translate> |
|||
{{Code|code= |
|||
import math |
|||
import pivy |
|||
from pivy import coin |
|||
Gui.activeDocument().activeView().viewAxonometric() |
|||
Gui.SendMsgToActiveView("ViewFit") |
|||
cam = Gui.ActiveDocument.ActiveView.getCameraNode() |
|||
rot = coin.SbRotation() |
|||
rot.setValue(coin.SbVec3f(1,0,0),-math.pi/2) # Y pointing upwards (mode 1) |
|||
#rot.setValue(coin.SbVec3f(0,0,1),math.pi/2) # Z pointing upwards (mode 2 uncomment for use) |
|||
nrot = cam.orientation.getValue() * rot |
|||
cam.orientation = nrot |
|||
Gui.SendMsgToActiveView("ViewFit") |
|||
}} |
|||
<translate> |
|||
⚫ | |||
This def paste in the Python console FreeCAD (or your macro) allows you to rotate the view in 3-axis and the angle (in degrees) give interesting to create a plan to a desired position |
|||
⚫ | |||
Paste the code in the Python console FreeCAD and type {{KEY|Enter}} > {{KEY|Enter}} |
|||
⚫ | |||
</translate> |
|||
{{Code|code= |
|||
def RotateView(axisX=1.0,axisY=0.0,axisZ=0.0,angle=45.0): |
|||
import math |
|||
from pivy import coin |
|||
try: |
|||
cam = Gui.ActiveDocument.ActiveView.getCameraNode() |
|||
rot = coin.SbRotation() |
|||
rot.setValue(coin.SbVec3f(axisX,axisY,axisZ),math.radians(angle)) |
|||
nrot = cam.orientation.getValue() * rot |
|||
cam.orientation = nrot |
|||
print axisX," ",axisY," ",axisZ," ",angle |
|||
except Exception: |
|||
print "Not ActiveView " |
|||
}} |
|||
<translate> |
|||
⚫ | |||
tip in the console ex : |
|||
</translate> |
|||
{{Code|code= |
|||
RotateView(0,1,0,45) |
|||
}} |
|||
<translate> |
|||
⚫ | |||
If there is no open document an error is returned |
|||
</translate> |
|||
{{clear}} |
{{clear}} |
Latest revision as of 10:58, 30 December 2023
Description |
---|
This macro rotates the current view by 90° to the left. Only works if you are in Top view. Macro version: 01.00 Last modified: 2010-11-17 FreeCAD version: All Download: ToolBar Icon Author: Yorik |
Author |
Yorik |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
01.00 |
Date last modified |
2010-11-17 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
Macro Rotate ViewAxonometric, Macro Rotate View Free |
Description
This macro rotates the current view by 90° to the left.
Limitations
Only works if you are in Top view: XY (top)
Script
Macro_Rotate_View_90_Degrees.FCMacro
import math from pivy import coin cam = Gui.ActiveDocument.ActiveView.getCameraNode() rot = coin.SbRotation() rot.setValue(coin.SbVec3f(0,0,1),math.pi/2) nrot = cam.orientation.getValue() * rot cam.orientation = nrot