Macro FCCamera: Difference between revisions
(ver 0.5 correct name "FCCamera_Axis_rotation_X.png" in reset block) |
(Fixed icon location for Addon Manager.) |
||
(44 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=FCCamera_00|Name=Macro FCCamera|Description=This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen.|Author=Mario52|Version=0.5 (06/09/2016)}} |
|||
|Name=Macro FCCamera |
|||
|Icon=FCCamera_00.png |
|||
|Description={{ColoredText|#ff0000|#ffffff|The new modified version GUI for the HD dpi (QGridLayout) runs only with FC version 0.18 and more (PySide2 Qt5)}}<br/><br/> |
|||
For previous versions, see [https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/42dc3ef73dc8db463a03b175f5a7f1f6978e3293/Macro%2520FCCamera.FCMacro FCCamera] and install it manually.<br/><br/> |
|||
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view. |
|||
|Author=Mario52 |
|||
|Version=0.14 |
|||
|Date=2020/10/20 |
|||
|FCVersion=0.18 and more |
|||
|Download=[https://wiki.freecad.org/images/2/25/FCCamera_00.png ToolBar Icon] |
|||
}} |
|||
==Description== <!--T:2--> |
==Description== <!--T:2--> |
||
<!--T:63--> |
|||
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view. |
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view. |
||
</translate> |
|||
==How to use== <!--T:3--> |
|||
{{Codeextralink|https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro}} |
|||
<translate> |
|||
<!--T: |
==Usage== <!--T:3--> |
||
Uses aesy, |
|||
<!--T:5--> |
<!--T:5--> |
||
[[File:Macro FCCamera 00.png|left|FCCamera]] |
[[File:Macro FCCamera 00.png|250px|left|FCCamera]] |
||
<!--T:6--> |
<!--T:6--> |
||
Line 18: | Line 33: | ||
<!--T:7--> |
<!--T:7--> |
||
'''Angle rotation Axis in degrees''': Select the rotation axis '''X Y''' or '''Z'''. |
'''Angle rotation Axis in degrees''': Select the rotation axis '''X''', '''Y''' or '''Z'''. |
||
<!--T:8--> |
<!--T:8--> |
||
Line 30: | Line 45: | ||
<!--T:11--> |
<!--T:11--> |
||
* [[File:FCCamera_02.png|24px]] {{KEY|Detect camera orientation}} : Detect the camera orientation and print in report view. The returned value is the value provided by the function getCameraOrientation(). |
* [[File:FCCamera_02.png|24px]] {{KEY|Detect camera orientation}} : Detect the camera orientation and print in report view. The returned value is the value provided by the function '''getCameraOrientation()'''. |
||
<!--T:12--> |
<!--T:12--> |
||
Line 42: | Line 57: | ||
<!--T:15--> |
<!--T:15--> |
||
* [[File:FCCamera_05.png|24px]] {{KEY|Align object to view.}} : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle) |
* [[File:FCCamera_05.png|24px]] {{KEY|Align object to view.}} : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle), same Euler angles : Yaw, Pitch, Roll, The Translation is not modify. |
||
<!--T:16--> |
<!--T:16--> |
||
Line 51: | Line 66: | ||
}} |
}} |
||
<translate> |
<translate> |
||
<!--T:17--> |
<!--T:17--> |
||
* |
*{{KEY|[[File:FCCamera_07.png|24px]] Reset.}} : Reset all values |
||
* [[File: |
*{{KEY| [[File:FCCamera_00.png|24px]] Photo.}} : Section save the screen rotation an image in angle value |
||
*{{KEY| [[File:FCCamera_08.png|24px]] Quit.}} : Quit FCCamera |
|||
<!--T: |
<!--T:44--> |
||
{{clear}} |
{{clear}} |
||
==Section Photo== |
|||
<!--T:45--> |
|||
[[File:Macro FCCamera 00b.png|250px|left|FCCamera]] |
|||
Download the file image and copy in your macro repertory. |
|||
{{clear}} |
|||
<!--T: |
<!--T:46--> |
||
*{{KEY|ComboBox Actual }} : Choose your screen definition for the image format |
|||
Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ..." |
|||
**Available (pre-defined): |
|||
***"Actual" (definition actual of screen) |
|||
***"Icon 16 x 16" |
|||
***"Icon 32 x 32" |
|||
***"Icon 64 x 64" |
|||
***"Icon 128 x 128" |
|||
***"CGA 320 x 200" |
|||
***"QVGA 320 x 240" |
|||
***"VGA 640 x 480" |
|||
***"SVGA 800 x 600" |
|||
***"XGA 1024 x 768" |
|||
***"XGA+ 1152 x 864" |
|||
***"SXGA 1280 x 1024" |
|||
***"SXGA+ 1400 x 1050" |
|||
***"UXGA 1600 x 1200" |
|||
***"QXGA 2048 x 1536" |
|||
***"Free" |
|||
<!--T: |
<!--T:47--> |
||
*{{KEY|SpinBox X and Y }} |
|||
The path of icons is displayed in the View report |
|||
<!--T: |
<!--T:48--> |
||
*{{KEY|ComboBox Format image}} |
|||
'''ex:''' Path locality to FCCamera.....images.png [ C:\Users\xx\AppData\Roaming\FreeCAD\ ] |
|||
**Available : |
|||
***"BMP *.bmp" |
|||
***"ICO *.ico" |
|||
***"JPEG *.jpeg" |
|||
***"JPG *.jpg" |
|||
***"PNG *.png" (by default) |
|||
***"PPM *.ppm" |
|||
***"TIF *.tif" |
|||
***"TIFF *.tiff" |
|||
***"XBM *.xbm" |
|||
***"XPM *.xpm" |
|||
<!--T: |
<!--T:18--> |
||
*Line 1 : Number image calculated by the angle give (ex: angle 60 degrees = 360 (complete rotation) / 60 (angle) = 6 images |
|||
You can change the path by changing the path in the line 165 |
|||
<!--T: |
<!--T:49--> |
||
*Line 2 : The definition of screen used |
|||
'''Icons program :''' |
|||
<!--T:50--> |
|||
</translate> |
|||
*Background image : |
|||
** Actual : save image with the screen colour actual |
|||
[[File:FCCamera_00.png|Logo FCCamera]] [[File:FCCamera_01.png|Accept]] [[File:FCCamera_02.png|Detect]] [[File:FCCamera_03.png|To Face]] |
|||
** White : save image with the screen colour white |
|||
[[File:FCCamera_04.png|To Axis]] [[File:FCCamera_05.png|Align Object to View]] [[File:FCCamera_06.png|Create plane]] [[File:FCCamera_07.png|Reset]] |
|||
** Black : save image with the screen colour black |
|||
[[File:FCCamera_08.png|Quit]] |
|||
<!--T:51--> |
|||
*{{KEY|[[File:FCCamera_00.png|24px]] Launch}} : Open the file window , give the name and the path |
|||
*{{KEY|[[File:FCCamera_07.png|24px]] Reset}} : Reset the default value |
|||
*{{KEY|[[File:FCCamera_00.png|24px]] Return}} : Quit the photo panel and return to FCCamera panel |
|||
{{clear}} |
{{clear}} |
||
<translate> |
|||
<!--T:23--> |
|||
'''Icons tableau :''' |
|||
</translate> |
|||
[[File:FCCamera Axis rotation X.png|Axis X]] |
|||
[[File:FCCamera Axis rotation Y.png|Axis Y]] |
|||
[[File:FCCamera Axis rotation Z.png|Axis Z]] |
|||
==Links== <!--T:25--> |
|||
<translate> |
|||
==Examples== <!--T:24--> |
|||
to do ... |
|||
<!--T:64--> |
|||
Related Links with FCCamera |
Related Links with FCCamera |
||
<!--T:26--> |
<!--T:26--> |
||
*[[Macro_Rotate_View|Macro Rotate View]] |
|||
[[Macro_Rotate_View|Macro Rotate View]], [[Macro Align Object to View|Macro Align Object to View]], [[Macro_Align_Face_Object_to_View|Macro Align Face Object to View]], [[Macro_WorkFeatures|Macro WorkFeatures]] |
|||
*[[Macro Align Object to View|Macro Align Object to View]] |
|||
*[[Macro_Align_Face_Object_to_View|Macro Align Face Object to View]] |
|||
*[[Macro_WorkFeatures|Macro WorkFeatures]] |
|||
<!--T:27--> |
<!--T:27--> |
||
Line 105: | Line 150: | ||
==Script== <!--T:22--> |
==Script== <!--T:22--> |
||
</translate> |
|||
<!--T:58--> |
|||
'''Macro FCCamera.FCMacro''' |
|||
Download the icon files [https://forum.freecadweb.org/download/file.php?id=79288 FCCamera_Icones.zip] |
|||
<!--T:42--> |
|||
{{Code|code= |
|||
Download the macro to Gist [https://gist.github.com/mario52a/4aa545c23b323cf68824 '''Macro FCCamera.FCMacro'''] |
|||
# -*- coding: utf-8 -*- |
|||
""" |
|||
*************************************************************************** |
|||
* Copyright (c) 2015 2016 <mario52> * |
|||
* * |
|||
* This file is a supplement to the FreeCAD CAx development system. * |
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU Lesser General Public License (LGPL) * |
|||
* as published by the Free Software Foundation; either version 2 of * |
|||
* the License, or (at your option) any later version. * |
|||
* for detail see the LICENCE text file. * |
|||
* * |
|||
* This software is distributed in the hope that it will be useful, * |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|||
* GNU Library General Public License for more details. * |
|||
* * |
|||
* You should have received a copy of the GNU Library General Public * |
|||
* License along with this macro; if not, write to the Free Software * |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
|||
* USA * |
|||
*************************************************************************** |
|||
* WARNING! All changes in this file will be lost and * |
|||
* may cause malfunction of the program * |
|||
*************************************************************************** |
|||
""" |
|||
# FCCamera 0.5 18/03/2015 28/02/2016 06/09/2016 |
|||
# |
|||
#OS: Windows Vista #OS: Windows Vista |
|||
#Word size of OS: 32-bit #Word size of OS: 32-bit |
|||
#Word size of FreeCAD: 32-bit #Word size of FreeCAD: 32-bit |
|||
#Version: 0.15.4502 (Git) #Version: 0.15.4655 (Git) |
|||
#Branch: master #Branch: master |
|||
#Hash: 3c754da0cbc86e06ade2543baecbca25701b7160 #Hash: 5d159f5cf352a93b1aff4fb7b82e8b747ee4f35b |
|||
#Python version: 2.7.8 #Python version: 2.7.8 |
|||
#Qt version: 4.8.6 #Qt version: 4.8.6 |
|||
#Coin version: 4.0.0a #Coin version: 4.0.0a |
|||
#OCC version: 6.7.1 #OCC version: 6.7.1 |
|||
# |
|||
__title__ ="FCCamera" |
|||
__author__ = "Mario52" |
|||
__url__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_FCCamera" |
|||
__version__ = "00.05" |
|||
__date__ = "06/09/2016" |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, DraftVecUtils |
|||
#import os, WorkingPlane |
|||
App = FreeCAD |
|||
try: |
|||
import PyQt4 # PyQt4 |
|||
from PyQt4 import QtCore, QtGui # PyQt4 |
|||
App.Console.PrintMessage("PyQt4"+"\n") |
|||
except Exception: |
|||
import PySide # PySide |
|||
from PySide import QtCore, QtGui # PySide |
|||
App.Console.PrintMessage("PySide"+"\n") |
|||
from math import radians, degrees, sqrt, pi, sin, cos, asin |
|||
from FreeCAD import Base |
|||
from FreeCAD import Vector |
|||
import pivy |
|||
from pivy import coin |
|||
global path ; path = "" |
|||
global valeur ; valeur = 0.0 |
|||
global valeurV ; valeurV = 0.0 |
|||
global Rname ; Rname = ["","",""] |
|||
global RnameCube; RnameCube = "" |
|||
global RnameCompound; RnameCompound = "" |
|||
global datExtract; datExtract = "" |
|||
global positionX ; positionX = 0.0 |
|||
global positionY ; positionY = 0.0 |
|||
global positionZ ; positionZ = 0.0 |
|||
try: |
|||
_fromUtf8 = QtCore.QString.fromUtf8 |
|||
except AttributeError: |
|||
def _fromUtf8(s): |
|||
return s |
|||
try: |
|||
_encoding = QtGui.QApplication.UnicodeUTF8 |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|||
except AttributeError: |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig) |
|||
class SelObserver: # SelObserver |
|||
def addSelection(self,document, object, element, position): # Selection SelObserver |
|||
global positionX |
|||
global positionY |
|||
global positionZ |
|||
positionX = position[0] |
|||
positionY = position[1] |
|||
positionZ = position[2] |
|||
def datExtract(data): |
|||
# return a string |
|||
data = str(data) |
|||
a = "" |
|||
for i in data: |
|||
if i in ("0123456789e.- "): |
|||
a+=i |
|||
a = a.strip(" ") |
|||
a = a.split(" ") |
|||
return a |
|||
global Nameelement2; Nameelement2 = "" # new selection |
|||
global vueView ; vueView = 0 # passe vue |
|||
def To_Face_Or_To_Axis(ToFace): # 1=NormalAt 0=Axis #Align Face selected to Face or to Axis |
|||
global vueView |
|||
global Nameelement2 |
|||
try: |
|||
SubElement = FreeCADGui.Selection.getSelectionEx() |
|||
Nameelement = SubElement[0].SubElementNames[0] |
|||
if Nameelement != Nameelement2: |
|||
vueView = 0 |
|||
Nameelement2 = Nameelement |
|||
if ToFace == 1: |
|||
v = Gui.Selection.getSelectionEx()[0].SubObjects[0].normalAt(0,0) # NormalAt |
|||
App.Console.PrintMessage("Nor At ") |
|||
else: |
|||
v=Gui.Selection.getSelectionEx()[0].SubObjects[0].Surface.Axis # Axis |
|||
App.Console.PrintMessage("S Axis ") |
|||
if vueView == 0: |
|||
r=App.Rotation(App.Vector(0,0,1),v) |
|||
App.Console.PrintMessage("0,0,1"+"\n") |
|||
elif vueView == 1: |
|||
r=App.Rotation(App.Vector(0,0,-1),v) |
|||
App.Console.PrintMessage("0,0,-1"+"\n") |
|||
elif vueView == 2: |
|||
r=App.Rotation(App.Vector(0,1,0),v) |
|||
App.Console.PrintMessage("0,1,0"+"\n") |
|||
elif vueView == 3: |
|||
r=App.Rotation(App.Vector(0,-1,0),v) |
|||
App.Console.PrintMessage("0,-1,0"+"\n") |
|||
elif vueView == 4: |
|||
r=App.Rotation(App.Vector(1,0,0),v) |
|||
App.Console.PrintMessage("1,0,0"+"\n") |
|||
elif vueView == 5: |
|||
r=App.Rotation(App.Vector(-1,0,0),v) |
|||
App.Console.PrintMessage("-1,0,0"+"\n") |
|||
vueView = -1 |
|||
Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)# |
|||
vueView += 1 |
|||
except: |
|||
App.Console.PrintError("Select a face"+"\n") |
|||
class Ui_MainWindow(object): |
|||
def setupUi(self, MainWindow): |
|||
global path |
|||
self.window = MainWindow |
|||
#path = FreeCAD.ConfigGet("AppHomePath") |
|||
path = FreeCAD.ConfigGet("UserAppData") # |
|||
# path = "Yout path" # |
|||
App.Console.PrintMessage("Path locality to FCCamera.....images.png [ " + path + " ]"+"\n") |
|||
# print "Path locality ( ",path," )" |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
|||
MainWindow.resize(209, 500) |
|||
MainWindow.setMaximumSize(QtCore.QSize(209, 500)) |
|||
self.centralWidget = QtGui.QWidget(MainWindow) |
|||
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
|||
### ---graphicsView--- |
|||
self.graphicsView = QtGui.QGraphicsView(self.centralWidget) |
|||
self.graphicsView.setGeometry(QtCore.QRect(20, 10, 171, 101)) |
|||
self.graphicsView.setFrameShape(QtGui.QFrame.StyledPanel) |
|||
self.graphicsView.setObjectName(_fromUtf8("graphicsView")) |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
### ---graphicsView--- |
|||
self.groupBox_01 = QtGui.QGroupBox(self.centralWidget) |
|||
self.groupBox_01.setGeometry(QtCore.QRect(10, 120, 191, 151)) |
|||
self.groupBox_01.setObjectName(_fromUtf8("groupBox_01")) |
|||
self.label_02 = QtGui.QLabel(self.groupBox_01) |
|||
self.label_02.setGeometry(QtCore.QRect(10, 20, 181, 16)) |
|||
self.label_02.setObjectName(_fromUtf8("label_02")) |
|||
self.RB_Angle_X = QtGui.QRadioButton(self.groupBox_01) |
|||
self.RB_Angle_X.setGeometry(QtCore.QRect(10, 90, 51, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_X.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_X.setFont(font) |
|||
self.RB_Angle_X.setMouseTracking(True) |
|||
self.RB_Angle_X.setChecked(True) |
|||
self.RB_Angle_X.setObjectName(_fromUtf8("RB_Angle_X")) |
|||
self.RB_Angle_X.setToolTip(u"Rotation of the camera on the X axis") |
|||
self.RB_Angle_X.clicked.connect(self.on_RB_Angle_X_clicked) |
|||
self.label_03 = QtGui.QLabel(self.groupBox_01) |
|||
self.label_03.setGeometry(QtCore.QRect(10, 70, 161, 16)) |
|||
self.label_03.setObjectName(_fromUtf8("label_03")) |
|||
self.RB_Angle_Y = QtGui.QRadioButton(self.groupBox_01) |
|||
self.RB_Angle_Y.setGeometry(QtCore.QRect(80, 90, 41, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 170, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 170, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_Y.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_Y.setFont(font) |
|||
self.RB_Angle_Y.setObjectName(_fromUtf8("RB_Angle_Y")) |
|||
self.RB_Angle_Y.setToolTip(u"Rotation of the camera on the Y axis") |
|||
self.RB_Angle_Y.clicked.connect(self.on_RB_Angle_Y_clicked) |
|||
self.RB_Angle_Z = QtGui.QRadioButton(self.groupBox_01) |
|||
self.RB_Angle_Z.setGeometry(QtCore.QRect(150, 90, 41, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_Z.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_Z.setFont(font) |
|||
self.RB_Angle_Z.setObjectName(_fromUtf8("RB_Angle_Z")) |
|||
self.RB_Angle_Z.setToolTip(u"Rotation of the camera on the Z axis") |
|||
self.RB_Angle_Z.clicked.connect(self.on_RB_Angle_Z_clicked) |
|||
self.DS_Angle = QtGui.QDoubleSpinBox(self.groupBox_01) |
|||
self.DS_Angle.setGeometry(QtCore.QRect(8, 40, 171, 22)) |
|||
self.DS_Angle.setAlignment(QtCore.Qt.AlignCenter) |
|||
self.DS_Angle.setDecimals(10) |
|||
self.DS_Angle.setMinimum(-359.0) |
|||
self.DS_Angle.setMaximum(359.0) |
|||
self.DS_Angle.setSingleStep(1.0) |
|||
self.DS_Angle.setObjectName(_fromUtf8("DS_Angle")) |
|||
self.DS_Angle.setToolTip(u"Enter the angle of rotation in degrees.\n" |
|||
" The given angle is added to the angle of the current view") |
|||
self.DS_Angle.valueChanged.connect(self.on_DS_Angle_valueChanged) #connection DS_Angle |
|||
self.PB_Accept_View = QtGui.QPushButton(self.groupBox_01) |
|||
self.PB_Accept_View.setGeometry(QtCore.QRect(10, 110, 171, 28)) |
|||
icon1 = QtGui.QIcon() |
|||
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_01.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Accept_View.setIcon(icon1) |
|||
self.PB_Accept_View.setToolTip(u"Accept the view given") |
|||
self.PB_Accept_View.setObjectName(_fromUtf8("PB_Accept_View")) |
|||
self.PB_Accept_View.clicked.connect(self.on_PB_Accept_View_clicked) |
|||
self.groupBox_02 = QtGui.QGroupBox(self.centralWidget) |
|||
self.groupBox_02.setGeometry(QtCore.QRect(10, 280, 191, 181)) |
|||
self.groupBox_02.setObjectName(_fromUtf8("groupBox_02")) |
|||
self.PB_Detect_Camera = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_Detect_Camera.setGeometry(QtCore.QRect(10, 20, 171, 28)) |
|||
icon2 = QtGui.QIcon() |
|||
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_02.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Detect_Camera.setIcon(icon2) |
|||
self.PB_Detect_Camera.setObjectName(_fromUtf8("PB_Detect_Camera")) |
|||
self.PB_Detect_Camera.setToolTip(u"Detect the position of the camera\n" |
|||
" The returned value is the value provided by the function getCameraOrientation()") |
|||
self.PB_Detect_Camera.clicked.connect(self.on_PB_Detect_Camera_clicked) |
|||
self.PB_To_Face = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_To_Face.setGeometry(QtCore.QRect(10, 70, 81, 28)) |
|||
icon3 = QtGui.QIcon() |
|||
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_03.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_To_Face.setIcon(icon3) |
|||
self.PB_To_Face.setObjectName(_fromUtf8("PB_To_Face")) |
|||
self.PB_To_Face.setToolTip("Align the view to the selected face \n" |
|||
"Click and repeat the click for NormalAt : \n" |
|||
"(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)") |
|||
self.PB_To_Face.clicked.connect(self.on_PB_To_Face_clicked) # align view to face Face |
|||
self.label_04 = QtGui.QLabel(self.groupBox_02) |
|||
self.label_04.setGeometry(QtCore.QRect(10, 50, 161, 20)) |
|||
self.label_04.setObjectName(_fromUtf8("label_04")) |
|||
self.PB_To_Axis = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_To_Axis.setGeometry(QtCore.QRect(100, 70, 81, 28)) |
|||
icon4 = QtGui.QIcon() |
|||
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_04.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_To_Axis.setIcon(icon4) |
|||
self.PB_To_Axis.setObjectName(_fromUtf8("PB_To_Axis")) |
|||
self.PB_To_Axis.setToolTip("Align the view to Axis face selected \n" |
|||
"Click and repeat the click for Surface Axis : \n" |
|||
"(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)") |
|||
self.PB_To_Axis.clicked.connect(self.on_PB_To_Axis_clicked) # Align view to face Axis |
|||
self.PB_Align_O_To_View = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_Align_O_To_View.setGeometry(QtCore.QRect(10, 105, 171, 28)) |
|||
icon5 = QtGui.QIcon() |
|||
icon5.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_05.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Align_O_To_View.setIcon(icon5) |
|||
self.PB_Align_O_To_View.setObjectName(_fromUtf8("PB_Align_O_To_View")) |
|||
self.PB_Align_O_To_View.setToolTip("Align the object selected to the actual view \n" |
|||
"The changed values are : Rotation Axis((X, Y, Z), Angle) \n" |
|||
"Same Euler angles : Yaw, Pitch, Roll \n The Translation is not modify") |
|||
self.PB_Align_O_To_View.clicked.connect(self.on_PB_Align_O_To_View_clicked) # Align object to view |
|||
self.PB_Create_Plane = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_Create_Plane.setGeometry(QtCore.QRect(10, 140, 171, 28)) |
|||
icon6 = QtGui.QIcon() |
|||
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_06.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Create_Plane.setIcon(icon6) |
|||
self.PB_Create_Plane.setObjectName(_fromUtf8("PB_Create_Plane")) |
|||
self.PB_Create_Plane.setToolTip("A circular plane is created facing the screen to mouse click coordinates on an object \n" |
|||
"The radius of the plane is equal to the maximum dimension of BoundBox \n" |
|||
"If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm") |
|||
self.PB_Create_Plane.clicked.connect(self.on_PB_Create_Plane_clicked) # create plane |
|||
self.PB_Reset = QtGui.QPushButton(self.centralWidget) |
|||
self.PB_Reset.setGeometry(QtCore.QRect(10, 465, 91, 28)) |
|||
icon7 = QtGui.QIcon() |
|||
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_07.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Reset.setIcon(icon7) |
|||
self.PB_Reset.setObjectName(_fromUtf8("PB_Reset")) |
|||
self.PB_Reset.setToolTip("Refresh alls") |
|||
self.PB_Reset.clicked.connect(self.on_PB_Reset_clicked) # refresh |
|||
self.PB_Quit = QtGui.QPushButton(self.centralWidget) |
|||
self.PB_Quit.setGeometry(QtCore.QRect(110, 465, 91, 28)) |
|||
icon8 = QtGui.QIcon() |
|||
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCCamera_08.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Quit.setIcon(icon8) |
|||
self.PB_Quit.setObjectName(_fromUtf8("PB_Quit")) |
|||
self.PB_Quit.setToolTip("Quit FCCamera") |
|||
self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked) # quit |
|||
MainWindow.setCentralWidget(self.centralWidget) |
|||
self.retranslateUi(MainWindow) |
|||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
def retranslateUi(self, MainWindow): |
|||
MainWindow.setWindowTitle("FCCamera") |
|||
MainWindow.setWindowIcon(QtGui.QIcon(path+'FCCamera_00.png')) # change l'icône de la fenêtre principale |
|||
try: |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
self.groupBox_01.setTitle("Camera of Axis") |
|||
self.label_02.setText("Angle rotation Axis in degrees") |
|||
self.label_03.setText("Axe of rotation") |
|||
self.RB_Angle_X.setText("X") |
|||
self.RB_Angle_Y.setText("Y") |
|||
self.RB_Angle_Z.setText("Z") |
|||
self.PB_Accept_View.setText("Accept the rotation") |
|||
self.groupBox_02.setTitle("Virtual") |
|||
self.PB_Detect_Camera.setText("Detect camera orientation") |
|||
self.PB_To_Face.setText("To Face.") |
|||
self.label_04.setText("Align view to face selected.") |
|||
self.PB_To_Axis.setText("To Axis.") |
|||
self.PB_Align_O_To_View.setText("Align Object to View") |
|||
self.PB_Create_Plane.setText("Create plane of view.") |
|||
self.PB_Reset.setText("Reset") |
|||
self.PB_Quit.setText("Quit") |
|||
def on_RB_Angle_X_clicked(self): # X |
|||
global path |
|||
App.Console.PrintMessage("X"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_RB_Angle_Y_clicked(self): # Y |
|||
global path |
|||
App.Console.PrintMessage("Y"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_Y.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_RB_Angle_Z_clicked(self): # Z |
|||
global path |
|||
App.Console.PrintMessage("Z"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_Z.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_DS_Angle_valueChanged(self,value): # connection DS_Angle value donnee en degres |
|||
global valeur |
|||
valeur = 0.0 |
|||
valeur = math.radians(value) # valeur en degres convertie en radian |
|||
def on_PB_Detect_Camera_clicked(self): # detection Orientation camera |
|||
plan = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
cam=Gui.ActiveDocument.ActiveView.getCameraNode() |
|||
App.Console.PrintMessage("___Camera_Detection_____________________"+"\n") |
|||
App.Console.PrintMessage("position : " + str(cam.position.getValue().getValue()) + "\n") |
|||
App.Console.PrintMessage("orientation : " + str(FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation().Axis)+" , "+str(FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation().Angle) + "\n") |
|||
App.Console.PrintMessage("nearDistance : " + str(cam.nearDistance.getValue()) + "\n") |
|||
App.Console.PrintMessage("farDistance : " + str(cam.farDistance.getValue()) + "\n") |
|||
App.Console.PrintMessage("aspectRatio : " + str(cam.aspectRatio.getValue()) + "\n") |
|||
App.Console.PrintMessage("focalDistance : " + str(cam.focalDistance.getValue()) + "\n") |
|||
App.Console.PrintMessage("height : " + str(cam.height.getValue()) + "\n" + "\n") |
|||
App.Console.PrintMessage("___Camera_Orientation____________________"+"\n") |
|||
App.Console.PrintMessage("Radians XYZ Q : " + str(plan)+"\n") |
|||
xP = float(datExtract(plan)[0]) |
|||
yP = float(datExtract(plan)[1]) |
|||
zP = float(datExtract(plan)[2]) |
|||
qP = float(datExtract(plan)[3]) |
|||
App.Console.PrintMessage("Degrees XYZ : " + str(degrees(xP)) + " , " +str(degrees(yP)) + " , " + str(degrees(zP)) +"\n") |
|||
App.Console.PrintMessage("Degrees Q : " + str(degrees(qP)) +"\n"+"\n") |
|||
App.Console.PrintMessage("Radians Axis.xyz A : " + str(plan.Axis) + " , " + str(plan.Angle) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.x : " + str(degrees(plan.Axis.x)) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.y : " + str(degrees(plan.Axis.y)) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.z : " + str(degrees(plan.Axis.z)) +"\n") |
|||
App.Console.PrintMessage("Degrees Angle : " + str(degrees(plan.Angle)) +"\n") |
|||
#http://forum.freecadweb.org/viewtopic.php?f=13&t=14213 |
|||
App.Console.PrintMessage("Direction : " + str(cam.orientation.getValue().multVec(coin.SbVec3f(0,0,-1)).getValue()) + "\n") |
|||
App.Console.PrintMessage("___FCCamera______________________________"+"\n\n") |
|||
App.ActiveDocument.recompute() |
|||
def on_PB_Accept_View_clicked(self): # Accept Rotation Camera to Axis |
|||
global valeur |
|||
if (valeur != 0): |
|||
Xv = 0.0;Yv = 0.0;Zv = 0.0 |
|||
cam = Gui.ActiveDocument.ActiveView.getCameraNode() |
|||
rot = coin.SbRotation() |
|||
##### |
|||
if self.RB_Angle_X.isChecked(): |
|||
Xv = 1.0 |
|||
App.Console.PrintMessage("(X ") |
|||
else: |
|||
App.Console.PrintMessage("(- ") |
|||
if self.RB_Angle_Y.isChecked(): |
|||
Yv = 1.0 |
|||
App.Console.PrintMessage("Y ") |
|||
else: |
|||
App.Console.PrintMessage("- ") |
|||
if self.RB_Angle_Z.isChecked(): |
|||
Zv = 1.0 |
|||
App.Console.PrintMessage("Z) ") |
|||
else: |
|||
App.Console.PrintMessage("-) "+"\n") |
|||
##### |
|||
rot.setValue(coin.SbVec3f(Xv,Yv,Zv),valeur) |
|||
nrot = cam.orientation.getValue() * rot |
|||
cam.orientation = nrot |
|||
App.Console.PrintMessage(str(valeur)+" rad. , "+str(math.degrees(valeur))+" deg."+"\n") |
|||
App.Console.PrintMessage("FCCamera_________________________________"+"\n\n") |
|||
if valeur == 0: |
|||
App.Console.PrintError("Value egal zero select one Value"+"\n") |
|||
def on_PB_Align_O_To_View_clicked(self): #Align and Fix Object to View |
|||
sel = FreeCADGui.Selection.getSelection() |
|||
if (len(sel)==0): |
|||
App.Console.PrintError("Select one object"+"\n") |
|||
else: |
|||
Nameelement = sel[0].Name |
|||
print sel[0].Placement.Base |
|||
App.Console.PrintMessage(str(Nameelement)+"\n") |
|||
pl = FreeCAD.Placement() |
|||
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
pl.Base = sel[0].Placement.Base |
|||
App.ActiveDocument.getObject(Nameelement).Placement=pl |
|||
def on_PB_Create_Plane_clicked(self): # Create plane |
|||
global positionX # create plans coordinate mouse |
|||
global positionY |
|||
global positionZ |
|||
rayon = 20 # Radius of plane |
|||
selEx = FreeCADGui.Selection.getSelectionEx() |
|||
objs = [selobj.Object for selobj in selEx] |
|||
if len(objs) >= 1: # radius = > BounBox length |
|||
s = objs[0].Shape |
|||
boundBox_ = s.BoundBox |
|||
boundBoxLX = boundBox_.XLength |
|||
boundBoxLY = boundBox_.YLength |
|||
boundBoxLZ = boundBox_.ZLength |
|||
rayon = boundBoxLX |
|||
if rayon < boundBoxLY: |
|||
rayon = boundBoxLY |
|||
elif rayon < boundBoxLZ: |
|||
rayon = boundBoxLZ |
|||
radiusP = rayon # Radius of plane |
|||
App.Console.PrintMessage("Create plane ("+str(radiusP)+" mm)"+"\n") |
|||
FcPlane = doc.addObject("App::DocumentObjectGroup","FcPlane") |
|||
plan = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
# App.Console.PrintMessage(str(plan)+"\n") |
|||
# App.Console.PrintMessage(str(positionX)+" "+str(positionY)+" "+str(positionZ)+"\n") |
|||
xP = float(datExtract(plan)[0]) |
|||
yP = float(datExtract(plan)[1]) |
|||
zP = float(datExtract(plan)[2]) |
|||
qP = float(datExtract(plan)[3]) |
|||
pl = FreeCAD.Placement() |
|||
pl.Rotation.Q = (xP,yP,zP,qP) # rotation of object |
|||
pl.Base = FreeCAD.Vector(positionX,positionY,positionZ) # here coordinates XYZ of plan |
|||
# Draft.makeRectangle(length=radiusP,height=radiusP,placement=pl,face=False,support=None) |
|||
points=[FreeCAD.Vector(-(radiusP*1.5),0,0),FreeCAD.Vector((radiusP*1.5),0,0)] |
|||
mire01 = Draft.makeWire(points,closed=False,placement=pl,face=False,support=None) |
|||
FreeCADGui.ActiveDocument.getObject(App.ActiveDocument.ActiveObject.Name).LineColor = (1.0,0.0,0.0) |
|||
FcPlane.addObject(mire01) # contener character |
|||
points=[FreeCAD.Vector(0,-(radiusP*1.5),0),FreeCAD.Vector(0,(radiusP*1.5),0)] |
|||
mire02 = Draft.makeWire(points,closed=False,placement=pl,face=False,support=None) |
|||
FreeCADGui.ActiveDocument.getObject(App.ActiveDocument.ActiveObject.Name).LineColor = (1.0,0.0,0.0) |
|||
FcPlane.addObject(mire02) # contener character |
|||
cercle = Draft.makeCircle(radius=radiusP,placement=pl,face=False,support=None) |
|||
Rnameplane = App.ActiveDocument.ActiveObject.Name |
|||
App.ActiveDocument.ActiveObject.Label = "PlaneC" |
|||
FreeCAD.ActiveDocument.getObject(Rnameplane).MakeFace = True |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).LineColor = (1.0,0.0,0.0) |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).ShapeColor = (0.0,0.66666669,1.0) |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).Transparency = 80 |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).GridSize = '10 mm' |
|||
# FreeCADGui.ActiveDocument.getObject(Rnameplane).GridSnap = True |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).ShowGrid = True |
|||
FcPlane.addObject(cercle) # contener character |
|||
FreeCAD.ActiveDocument.recompute() |
|||
positionX = 0.0 |
|||
positionY = 0.0 |
|||
positionZ = 0.0 |
|||
def on_PB_To_Face_clicked(self): # view to face selected Face |
|||
To_Face_Or_To_Axis(1) |
|||
def on_PB_To_Axis_clicked(self): # view to face selected Axis |
|||
To_Face_Or_To_Axis(0) |
|||
def on_PB_Reset_clicked(self): # Refresh |
|||
global valeur |
|||
global positionX |
|||
global positionY |
|||
global positionZ |
|||
global vueView |
|||
global path |
|||
App.Console.PrintMessage("Refresh"+"\n") |
|||
Gui.activeDocument().activeView().viewTop() |
|||
Gui.SendMsgToActiveView("ViewFit") |
|||
valeur = 0.0 |
|||
self.DS_Angle.setProperty("value", 0.0) |
|||
positionX = 0.0 |
|||
positionY = 0.0 |
|||
positionZ = 0.0 |
|||
vueView = 0 |
|||
self.groupBox_01.setTitle("Camera of Axis") |
|||
self.label_02.setText("Angle rotation Axis in degrees") |
|||
self.label_03.setText("Axe of rotation") |
|||
self.RB_Angle_X.setText("X") |
|||
self.RB_Angle_Y.setText("Y") |
|||
self.RB_Angle_Z.setText("Z") |
|||
self.RB_Angle_X.setChecked(True) |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_PB_Quit_clicked(self): # quit |
|||
App.Console.PrintMessage("Fin FCCamera"+"\n") |
|||
FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente |
|||
self.window.hide() |
|||
##Start##### |
|||
doc = FreeCAD.ActiveDocument # create one document |
|||
if doc == None: |
|||
doc = FreeCAD.newDocument() |
|||
#Gui.ActiveDocument.ActiveView.setAxisCross(True) # GuiAxis true |
|||
s=SelObserver() # installe the function in resident mode SelObserver |
|||
FreeCADGui.Selection.addObserver(s) # installe the function in resident mode SelObserver |
|||
MainWindow = QtGui.QMainWindow() |
|||
ui = Ui_MainWindow() |
|||
ui.setupUi(MainWindow) |
|||
MainWindow.show() |
|||
}} |
|||
<translate> |
|||
==Examples== <!--T:31--> |
==Examples== <!--T:31--> |
||
Line 754: | Line 165: | ||
<gallery widths="300" heights="280"> |
<gallery widths="300" heights="280"> |
||
File:FCCamera 09.png|Create your object |
File:FCCamera 09.png|Create your object |
||
File:FCCamera 10.png|Create one cylinder and positionning this |
File:FCCamera 10.png|Create one cylinder and positionning like this.<br/>Give your axis, angle inclination and click the button [[File:FCCamera_01.png|24px]] {{KEY|Accept the rotation}} |
||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
Line 762: | Line 173: | ||
<gallery widths="300" heights="280"> |
<gallery widths="300" heights="280"> |
||
File:FCCamera 11.png|Select your cylinder for create your hole |
File:FCCamera 11.png|Select your cylinder for create your hole |
||
File:FCCamera 12.png|In FCCamera click the button [[File:FCCamera_05.png|24px]] {{KEY|Align Object to View}} |
File:FCCamera 12.png|In FCCamera, click the button [[File:FCCamera_05.png|24px]] {{KEY|Align Object to View}} |
||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
Line 769: | Line 180: | ||
<center> |
<center> |
||
<gallery widths="300" heights="280"> |
<gallery widths="300" heights="280"> |
||
File:FCCamera 13.png|The cylinder moves to 15 degrees ( |
File:FCCamera 13.png|The cylinder moves to 15 degrees (it takes the camera's position). Do your Boolean operation |
||
File:FCCamera 14.png|Your hole 15 degrees |
File:FCCamera 14.png|Your hole 15 degrees |
||
</gallery> |
</gallery> |
||
Line 775: | Line 186: | ||
<!--T:36--> |
<!--T:36--> |
||
The same result can be achieved by creating a plan in the corner |
The same result can be achieved by creating a plan in the corner given by the mouse click position and a sketch. |
||
<!--T:53--> |
|||
<center> |
|||
<gallery widths="750" heights="700"> |
|||
File:Macro_FCCamera_Align_To_Face.gif|example of the positioning of a spring on an axis of a face |
|||
</gallery> |
|||
</center> |
|||
<center> |
|||
<gallery widths="850" heights="550"> |
|||
File:Test_FCCamera_Photo_01.gif|Example photo rotation and save images (you must create one animate Gif [https://www.gimp.org/ with GIMP]) |
|||
</gallery> |
|||
</center> |
|||
</translate> |
|||
<translate> |
|||
==Version== <!--T:37--> |
==Version== <!--T:37--> |
||
<!--T:62--> |
|||
*'''ver 0.14 (20/10/2020):''' correction bug "Grid" not accepted |
|||
<!--T:61--> |
|||
*'''ver 0.13 (28/06/2020):''' adding files image in source code, create plane "On point, Center face, BBox center, Center Mass", gridLayout |
|||
<!--T:60--> |
|||
*'''ver 00.12.1 (12/02/2020):''' suppress the bad character lines 674 and 675 (accent...) again |
|||
<!--T:59--> |
|||
*'''ver 12 (01/08/2019):''' compatible Python 3 ( print to print() ) |
|||
<!--T:55--> |
|||
*'''ver 11 (13/01/2018):''' minor |
|||
<!--T:56--> |
|||
*'''ver 10 (13/01/2018):''' add "def centerBoundBoxGlobal():" |
|||
<!--T:57--> |
|||
*'''ver 09 (08/01/2018):''' minor |
|||
<!--T:52--> |
|||
*'''ver 08 (08/01/2018):''' supp "Pyqt4" and adjust number image |
|||
*'''ver 07 (03/01/2018):''' add photo panel and rotation to axis selected (wire, edge, line ) |
|||
<!--T:43--> |
|||
*'''ver 0.6 (13/12/2016):''' new system for search the macro path directly in the preferences |
|||
</translate> |
|||
#path = FreeCAD.ConfigGet("AppHomePath") |
|||
#path = FreeCAD.ConfigGet("UserAppData") |
|||
#path = "your path" |
|||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path |
|||
path = param.GetString("MacroPath","") + "/" # macro path |
|||
path = path.replace("\\","/") |
|||
App.Console.PrintMessage("Path locality to FCCamera.....images.png [ " + path + " ]"+"\n") |
|||
<translate> |
|||
<!--T:38--> |
<!--T:38--> |
||
*'''ver 0.5 06/09/2016:''' correct name "FCCamera_Axis_rotation_X.png" in reset block |
*'''ver 0.5 06/09/2016:''' correct name "FCCamera_Axis_rotation_X.png" in reset block |
||
<!--T:41--> |
|||
*'''ver 0.4 28/02/2016 :''' add display all camera detection and the [http://forum.freecadweb.org/viewtopic.php?f=13&t=14213#p114667 Direction] |
*'''ver 0.4 28/02/2016 :''' add display all camera detection and the [http://forum.freecadweb.org/viewtopic.php?f=13&t=14213#p114667 Direction] |
||
Line 791: | Line 255: | ||
</translate> |
</translate> |
||
<languages/> |
Latest revision as of 21:39, 28 December 2023
Description |
---|
The new modified version GUI for the HD dpi (QGridLayout) runs only with FC version 0.18 and more (PySide2 Qt5) For previous versions, see FCCamera and install it manually. |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
0.14 |
Date last modified |
2020/10/20 |
FreeCAD Version(s) |
0.18 and more |
Default shortcut |
None |
See also |
None |
Description
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view.
Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro
# This code is copied instead of the original macro code # to guide the user to the online download page. # Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki # or if the RAW code URL is somewhere else in the wiki. from PySide import QtGui, QtCore diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Information", "This macro must be downloaded from this link\n" "\n" "https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro" + "\n" "\n" "Quit this window to access the download page") diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) diag.setWindowModality(QtCore.Qt.ApplicationModal) diag.exec_() import webbrowser webbrowser.open("https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro")
Usage
Camera of Axis: The dialog box to enter the rotation value angle in degrees.
Angle rotation Axis in degrees: Select the rotation axis X, Y or Z.
Axe of rotation
Virtual
- Detect camera orientation : Detect the camera orientation and print in report view. The returned value is the value provided by the function getCameraOrientation().
Align view to face selected
- To Face. : Align the view to the selected face. Click and repeat the click for NormalAt : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)"
- To Axis. : Align the view to Axis face selected. Click and repeat the click for Surface Axis : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)"
- Align object to view. : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle), same Euler angles : Yaw, Pitch, Roll, The Translation is not modify.
- Create plane of view. : A circular plane is created facing the screen to mouse click coordinates on an object. The radius of the plane is equal to the maximum dimension of BoundBox. If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm. The radius is modifiable to line 515:
rayon = 20 # Radius of plane
- Reset. : Reset all values
- Photo. : Section save the screen rotation an image in angle value
- Quit. : Quit FCCamera
Section Photo
- ComboBox Actual : Choose your screen definition for the image format
- Available (pre-defined):
- "Actual" (definition actual of screen)
- "Icon 16 x 16"
- "Icon 32 x 32"
- "Icon 64 x 64"
- "Icon 128 x 128"
- "CGA 320 x 200"
- "QVGA 320 x 240"
- "VGA 640 x 480"
- "SVGA 800 x 600"
- "XGA 1024 x 768"
- "XGA+ 1152 x 864"
- "SXGA 1280 x 1024"
- "SXGA+ 1400 x 1050"
- "UXGA 1600 x 1200"
- "QXGA 2048 x 1536"
- "Free"
- Available (pre-defined):
- SpinBox X and Y
- ComboBox Format image
- Available :
- "BMP *.bmp"
- "ICO *.ico"
- "JPEG *.jpeg"
- "JPG *.jpg"
- "PNG *.png" (by default)
- "PPM *.ppm"
- "TIF *.tif"
- "TIFF *.tiff"
- "XBM *.xbm"
- "XPM *.xpm"
- Available :
- Line 1 : Number image calculated by the angle give (ex: angle 60 degrees = 360 (complete rotation) / 60 (angle) = 6 images
- Line 2 : The definition of screen used
- Background image :
- Actual : save image with the screen colour actual
- White : save image with the screen colour white
- Black : save image with the screen colour black
- Launch : Open the file window , give the name and the path
- Reset : Reset the default value
- Return : Quit the photo panel and return to FCCamera panel
Links
Related Links with FCCamera
Discussion Forum MACRO:Work Feature 2014_12
Script
Download the icon files FCCamera_Icones.zip
Download the macro to Gist Macro FCCamera.FCMacro
Examples
How to place an angle hole
-
Create your object
-
Select your cylinder for create your hole
-
The cylinder moves to 15 degrees (it takes the camera's position). Do your Boolean operation
-
Your hole 15 degrees
The same result can be achieved by creating a plan in the corner given by the mouse click position and a sketch.
-
example of the positioning of a spring on an axis of a face
-
Example photo rotation and save images (you must create one animate Gif with GIMP)
Version
- ver 0.14 (20/10/2020): correction bug "Grid" not accepted
- ver 0.13 (28/06/2020): adding files image in source code, create plane "On point, Center face, BBox center, Center Mass", gridLayout
- ver 00.12.1 (12/02/2020): suppress the bad character lines 674 and 675 (accent...) again
- ver 12 (01/08/2019): compatible Python 3 ( print to print() )
- ver 11 (13/01/2018): minor
- ver 10 (13/01/2018): add "def centerBoundBoxGlobal():"
- ver 09 (08/01/2018): minor
- ver 08 (08/01/2018): supp "Pyqt4" and adjust number image
- ver 07 (03/01/2018): add photo panel and rotation to axis selected (wire, edge, line )
- ver 0.6 (13/12/2016): new system for search the macro path directly in the preferences
#path = FreeCAD.ConfigGet("AppHomePath") #path = FreeCAD.ConfigGet("UserAppData") #path = "your path" param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path path = param.GetString("MacroPath","") + "/" # macro path path = path.replace("\\","/") App.Console.PrintMessage("Path locality to FCCamera.....images.png [ " + path + " ]"+"\n")
- ver 0.5 06/09/2016: correct name "FCCamera_Axis_rotation_X.png" in reset block
- ver 0.4 28/02/2016 : add display all camera detection and the Direction
- ver 0.3 18/03/2015 : modify line 492 replace "pl.Base = App.Vector(0,0,0)" to "pl.Base = sel[0].Placement.Base" now no longer moves the form at point (0,0,0) and leaves has the coordinates
- ver 0.2 25/02/2015 : correct names files in for compatibility Linux (case sensitive) thanks microelly2