Macro Rotate View Free: Difference between revisions

From FreeCAD Documentation
(create page)
 
(Marked this version for translation)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
<!--T:1-->
{{Macro
{{Macro
|Name=Rotate View Free
|Name=Rotate View Free
Line 11: Line 12:
}}
}}


==Description==
==Description== <!--T:2-->


<!--T:3-->
This def pasted 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
This def pasted 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


==Use==
==Use== <!--T:4-->


<!--T:5-->
Paste the code in the Python console FreeCAD and type {{KEY|Enter}} → {{KEY|Enter}} (for validate) and tip ex: </translate>{{ColoredText|{{Emphasis|RotateView(0,1,0,45)}} }}<translate>
Paste the code in the Python console FreeCAD and type {{KEY|Enter}} → {{KEY|Enter}} (for validate) and tip ex: </translate>{{ColoredText|{{Emphasis|RotateView(0,1,0,45)}} }}<translate>


==Script==
==Script== <!--T:6-->


</translate>
</translate>
Line 44: Line 47:
<translate>
<translate>


<!--T:7-->
tip in the console ex :
tip in the console ex :


Line 52: Line 56:
<translate>
<translate>


<!--T:8-->
If there is not open document an error is returned
If there is not open document an error is returned
</translate>
</translate>

Revision as of 11:26, 7 June 2019

Other languages:

Generic macro icon. Create your personal icon with the same name of the macro Rotate View Free

Description
This def pasted 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

Macro version: 01.00
Last modified: 2010-11-17
FreeCAD version: All
Author: Yorik
Author
Yorik
Download
None
Links
Macro Version
01.00
Date last modified
2010-11-17
FreeCAD Version(s)
All
Default shortcut
None
See also
Macro Rotate View
Macro_Rotate_ViewAxonometric

Description

This def pasted 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

Use

Paste the code in the Python console FreeCAD and type EnterEnter (for validate) and tip ex: RotateView(0,1,0,45)

Script

Macro_Rotate_View_Free.FCMacro

#Paste in the Python console and tip ex:
#RotateView(0,1,0,45)
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 ")

tip in the console ex :

RotateView(0,1,0,45)

If there is not open document an error is returned