From 71db89fcd9209fe6395cef4652d0e6fa9060a246 Mon Sep 17 00:00:00 2001 From: Rentlau Date: Wed, 18 Feb 2015 08:55:11 +0100 Subject: [PATCH] - Try to fix issue with path of WorkFeature directory - myDialog handling - Circle and Ellipse Tab added - Cutting tab added --- .../{WFGui_2015_01_25.py => WFGui_2015.py} | 959 ++++-- .../{WFGui_2015_01_25.ui => WFGui_2015.ui} | 1724 +++++++--- WorkFeature/__init__.py | 3056 +++++++++++++---- start_WF.FCMacro | 20 +- 4 files changed, 4234 insertions(+), 1525 deletions(-) rename WorkFeature/{WFGui_2015_01_25.py => WFGui_2015.py} (54%) mode change 100755 => 100644 rename WorkFeature/{WFGui_2015_01_25.ui => WFGui_2015.ui} (59%) mode change 100755 => 100644 diff --git a/WorkFeature/WFGui_2015_01_25.py b/WorkFeature/WFGui_2015.py old mode 100755 new mode 100644 similarity index 54% rename from WorkFeature/WFGui_2015_01_25.py rename to WorkFeature/WFGui_2015.py index 16eda5e..0e6e907 --- a/WorkFeature/WFGui_2015_01_25.py +++ b/WorkFeature/WFGui_2015.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'WFGui_2015_01_25.ui' +# Form implementation generated from reading ui file 'WFGui_2015_02_17.ui' # -# Created: Sun Jan 25 10:01:02 2015 +# Created: Tue Feb 17 11:56:24 2015 # by: PySide UI code generator 4.9.1 # # WARNING! All changes made in this file will be lost! @@ -17,7 +17,7 @@ except AttributeError: class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) - Form.resize(368, 635) + Form.resize(376, 742) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_Axes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) Form.setWindowIcon(icon) @@ -27,95 +27,91 @@ class Ui_Form(object): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName(_fromUtf8("scrollArea")) self.scrollAreaWidgetContents_2 = QtGui.QWidget() - self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 335, 622)) + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, -35, 340, 722)) self.scrollAreaWidgetContents_2.setObjectName(_fromUtf8("scrollAreaWidgetContents_2")) - self.gridLayout_11 = QtGui.QGridLayout(self.scrollAreaWidgetContents_2) - self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) + self.gridLayout_4 = QtGui.QGridLayout(self.scrollAreaWidgetContents_2) + self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) self.tabWidget_0 = QtGui.QTabWidget(self.scrollAreaWidgetContents_2) self.tabWidget_0.setTabPosition(QtGui.QTabWidget.South) self.tabWidget_0.setObjectName(_fromUtf8("tabWidget_0")) self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName(_fromUtf8("tab_2")) - self.gridLayout_2 = QtGui.QGridLayout(self.tab_2) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.gridLayout_22 = QtGui.QGridLayout(self.tab_2) + self.gridLayout_22.setObjectName(_fromUtf8("gridLayout_22")) self.tabWidget = QtGui.QTabWidget(self.tab_2) self.tabWidget.setTabPosition(QtGui.QTabWidget.West) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) + self.Origin_Tab = QtGui.QWidget() + self.Origin_Tab.setObjectName(_fromUtf8("Origin_Tab")) + self.gridLayout_7 = QtGui.QGridLayout(self.Origin_Tab) + self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) + self.verticalLayout_3 = QtGui.QVBoxLayout() + self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) + self.button_origin = QtGui.QPushButton(self.Origin_Tab) + self.button_origin.setIcon(icon) + self.button_origin.setIconSize(QtCore.QSize(32, 32)) + self.button_origin.setObjectName(_fromUtf8("button_origin")) + self.verticalLayout_3.addWidget(self.button_origin) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem) + self.gridLayout_7.addLayout(self.verticalLayout_3, 0, 0, 1, 1) + self.tabWidget.addTab(self.Origin_Tab, icon, _fromUtf8("")) self.Point_Tab = QtGui.QWidget() self.Point_Tab.setObjectName(_fromUtf8("Point_Tab")) self.gridLayout_3 = QtGui.QGridLayout(self.Point_Tab) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) - self.button_point_face_point = QtGui.QPushButton(self.Point_Tab) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_point_face_point.setIcon(icon1) - self.button_point_face_point.setIconSize(QtCore.QSize(32, 32)) - self.button_point_face_point.setObjectName(_fromUtf8("button_point_face_point")) - self.gridLayout_3.addWidget(self.button_point_face_point, 8, 0, 1, 1) + self.horizontalLayout_10 = QtGui.QHBoxLayout() + self.horizontalLayout_10.setObjectName(_fromUtf8("horizontalLayout_10")) self.button_object_center = QtGui.QPushButton(self.Point_Tab) - icon2 = QtGui.QIcon() - icon2.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsPoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_object_center.setIcon(icon2) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsPoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_object_center.setIcon(icon1) self.button_object_center.setIconSize(QtCore.QSize(32, 32)) self.button_object_center.setObjectName(_fromUtf8("button_object_center")) - self.gridLayout_3.addWidget(self.button_object_center, 0, 0, 1, 1) - self.button_circle_center = QtGui.QPushButton(self.Point_Tab) - icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerCirclePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_circle_center.setIcon(icon3) - self.button_circle_center.setIconSize(QtCore.QSize(32, 32)) - self.button_circle_center.setObjectName(_fromUtf8("button_circle_center")) - self.gridLayout_3.addWidget(self.button_circle_center, 3, 0, 1, 1) - self.button_object_base_point = QtGui.QPushButton(self.Point_Tab) - icon4 = QtGui.QIcon() - icon4.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_objectBasePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_object_base_point.setIcon(icon4) - self.button_object_base_point.setIconSize(QtCore.QSize(32, 32)) - self.button_object_base_point.setObjectName(_fromUtf8("button_object_base_point")) - self.gridLayout_3.addWidget(self.button_object_base_point, 10, 0, 1, 1) - self.button_line_face_point = QtGui.QPushButton(self.Point_Tab) - icon5 = QtGui.QIcon() - icon5.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_lineFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_line_face_point.setIcon(icon5) - self.button_line_face_point.setIconSize(QtCore.QSize(32, 32)) - self.button_line_face_point.setObjectName(_fromUtf8("button_line_face_point")) - self.gridLayout_3.addWidget(self.button_line_face_point, 6, 0, 1, 1) - self.button_click_for_point = QtGui.QPushButton(self.Point_Tab) - icon6 = QtGui.QIcon() - icon6.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_clickPoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_click_for_point.setIcon(icon6) - self.button_click_for_point.setIconSize(QtCore.QSize(32, 32)) - self.button_click_for_point.setCheckable(False) - self.button_click_for_point.setObjectName(_fromUtf8("button_click_for_point")) - self.gridLayout_3.addWidget(self.button_click_for_point, 9, 0, 1, 1) + self.horizontalLayout_10.addWidget(self.button_object_center) + self.checkBox_object_center = QtGui.QCheckBox(self.Point_Tab) + self.checkBox_object_center.setObjectName(_fromUtf8("checkBox_object_center")) + self.horizontalLayout_10.addWidget(self.checkBox_object_center) + self.gridLayout_3.addLayout(self.horizontalLayout_10, 0, 0, 1, 1) + self.button_Npoints_center = QtGui.QPushButton(self.Point_Tab) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_NpointsPoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_Npoints_center.setIcon(icon2) + self.button_Npoints_center.setIconSize(QtCore.QSize(32, 32)) + self.button_Npoints_center.setObjectName(_fromUtf8("button_Npoints_center")) + self.gridLayout_3.addWidget(self.button_Npoints_center, 1, 0, 1, 1) + self.horizontalLayout_6 = QtGui.QHBoxLayout() + self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.button_line_center = QtGui.QPushButton(self.Point_Tab) - icon7 = QtGui.QIcon() - icon7.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_line_center.setIcon(icon7) + icon3 = QtGui.QIcon() + icon3.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_line_center.setIcon(icon3) self.button_line_center.setIconSize(QtCore.QSize(32, 32)) self.button_line_center.setObjectName(_fromUtf8("button_line_center")) - self.gridLayout_3.addWidget(self.button_line_center, 1, 0, 1, 1) - self.button_point_line_point = QtGui.QPushButton(self.Point_Tab) - icon8 = QtGui.QIcon() - icon8.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_point_line_point.setIcon(icon8) - self.button_point_line_point.setIconSize(QtCore.QSize(32, 32)) - self.button_point_line_point.setObjectName(_fromUtf8("button_point_line_point")) - self.gridLayout_3.addWidget(self.button_point_line_point, 7, 0, 1, 1) - self.button_face_center = QtGui.QPushButton(self.Point_Tab) - icon9 = QtGui.QIcon() - icon9.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_face_center.setIcon(icon9) - self.button_face_center.setIconSize(QtCore.QSize(32, 32)) - self.button_face_center.setObjectName(_fromUtf8("button_face_center")) - self.gridLayout_3.addWidget(self.button_face_center, 5, 0, 1, 1) + self.horizontalLayout_6.addWidget(self.button_line_center) + self.spin_line_center = QtGui.QSpinBox(self.Point_Tab) + self.spin_line_center.setMinimumSize(QtCore.QSize(40, 0)) + self.spin_line_center.setMaximumSize(QtCore.QSize(50, 16777215)) + self.spin_line_center.setMinimum(2) + self.spin_line_center.setMaximum(10) + self.spin_line_center.setSingleStep(1) + self.spin_line_center.setObjectName(_fromUtf8("spin_line_center")) + self.horizontalLayout_6.addWidget(self.spin_line_center) + self.gridLayout_3.addLayout(self.horizontalLayout_6, 2, 0, 1, 1) self.button_line_extrema = QtGui.QPushButton(self.Point_Tab) - icon10 = QtGui.QIcon() - icon10.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_extremaLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_line_extrema.setIcon(icon10) + icon4 = QtGui.QIcon() + icon4.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_extremaLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_line_extrema.setIcon(icon4) self.button_line_extrema.setIconSize(QtCore.QSize(32, 32)) self.button_line_extrema.setObjectName(_fromUtf8("button_line_extrema")) - self.gridLayout_3.addWidget(self.button_line_extrema, 2, 0, 1, 1) + self.gridLayout_3.addWidget(self.button_line_extrema, 3, 0, 1, 1) + self.button_circle_center = QtGui.QPushButton(self.Point_Tab) + icon5 = QtGui.QIcon() + icon5.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerCirclePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_circle_center.setIcon(icon5) + self.button_circle_center.setIconSize(QtCore.QSize(32, 32)) + self.button_circle_center.setObjectName(_fromUtf8("button_circle_center")) + self.gridLayout_3.addWidget(self.button_circle_center, 4, 0, 1, 1) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) @@ -125,9 +121,9 @@ class Ui_Form(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.button_point_on_line.sizePolicy().hasHeightForWidth()) self.button_point_on_line.setSizePolicy(sizePolicy) - icon11 = QtGui.QIcon() - icon11.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_alongLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_point_on_line.setIcon(icon11) + icon6 = QtGui.QIcon() + icon6.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_alongLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_point_on_line.setIcon(icon6) self.button_point_on_line.setIconSize(QtCore.QSize(32, 32)) self.button_point_on_line.setObjectName(_fromUtf8("button_point_on_line")) self.horizontalLayout.addWidget(self.button_point_on_line) @@ -141,107 +137,298 @@ class Ui_Form(object): self.distance_point_on_line.setMaximumSize(QtCore.QSize(60, 16777215)) self.distance_point_on_line.setObjectName(_fromUtf8("distance_point_on_line")) self.horizontalLayout.addWidget(self.distance_point_on_line) - self.gridLayout_3.addLayout(self.horizontalLayout, 4, 0, 1, 1) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_3.addItem(spacerItem, 11, 0, 1, 1) + self.gridLayout_3.addLayout(self.horizontalLayout, 5, 0, 1, 1) + self.button_face_center = QtGui.QPushButton(self.Point_Tab) + icon7 = QtGui.QIcon() + icon7.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_face_center.setIcon(icon7) + self.button_face_center.setIconSize(QtCore.QSize(32, 32)) + self.button_face_center.setObjectName(_fromUtf8("button_face_center")) + self.gridLayout_3.addWidget(self.button_face_center, 6, 0, 1, 1) + self.button_line_face_point = QtGui.QPushButton(self.Point_Tab) + icon8 = QtGui.QIcon() + icon8.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_lineFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_line_face_point.setIcon(icon8) + self.button_line_face_point.setIconSize(QtCore.QSize(32, 32)) + self.button_line_face_point.setObjectName(_fromUtf8("button_line_face_point")) + self.gridLayout_3.addWidget(self.button_line_face_point, 7, 0, 1, 1) + self.button_point_line_point = QtGui.QPushButton(self.Point_Tab) + icon9 = QtGui.QIcon() + icon9.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_point_line_point.setIcon(icon9) + self.button_point_line_point.setIconSize(QtCore.QSize(32, 32)) + self.button_point_line_point.setObjectName(_fromUtf8("button_point_line_point")) + self.gridLayout_3.addWidget(self.button_point_line_point, 8, 0, 1, 1) + self.button_point_face_point = QtGui.QPushButton(self.Point_Tab) + icon10 = QtGui.QIcon() + icon10.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointFacePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_point_face_point.setIcon(icon10) + self.button_point_face_point.setIconSize(QtCore.QSize(32, 32)) + self.button_point_face_point.setObjectName(_fromUtf8("button_point_face_point")) + self.gridLayout_3.addWidget(self.button_point_face_point, 9, 0, 1, 1) + self.button_twolines_point = QtGui.QPushButton(self.Point_Tab) + icon11 = QtGui.QIcon() + icon11.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_lineLinePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_twolines_point.setIcon(icon11) + self.button_twolines_point.setIconSize(QtCore.QSize(32, 32)) + self.button_twolines_point.setObjectName(_fromUtf8("button_twolines_point")) + self.gridLayout_3.addWidget(self.button_twolines_point, 10, 0, 1, 1) + self.button_click_for_point = QtGui.QPushButton(self.Point_Tab) icon12 = QtGui.QIcon() - icon12.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_point.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.tabWidget.addTab(self.Point_Tab, icon12, _fromUtf8("")) + icon12.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_clickPoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_click_for_point.setIcon(icon12) + self.button_click_for_point.setIconSize(QtCore.QSize(32, 32)) + self.button_click_for_point.setCheckable(False) + self.button_click_for_point.setObjectName(_fromUtf8("button_click_for_point")) + self.gridLayout_3.addWidget(self.button_click_for_point, 11, 0, 1, 1) + self.button_object_base_point = QtGui.QPushButton(self.Point_Tab) + icon13 = QtGui.QIcon() + icon13.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_objectBasePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_object_base_point.setIcon(icon13) + self.button_object_base_point.setIconSize(QtCore.QSize(32, 32)) + self.button_object_base_point.setObjectName(_fromUtf8("button_object_base_point")) + self.gridLayout_3.addWidget(self.button_object_base_point, 12, 0, 1, 1) + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem1, 13, 0, 1, 1) + icon14 = QtGui.QIcon() + icon14.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_point.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.Point_Tab, icon14, _fromUtf8("")) self.Axis_Tab = QtGui.QWidget() self.Axis_Tab.setObjectName(_fromUtf8("Axis_Tab")) self.gridLayout = QtGui.QGridLayout(self.Axis_Tab) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.button_object_axis = QtGui.QPushButton(self.Axis_Tab) - icon13 = QtGui.QIcon() - icon13.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsAxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_object_axis.setIcon(icon13) - self.button_object_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_object_axis.setObjectName(_fromUtf8("button_object_axis")) - self.gridLayout.addWidget(self.button_object_axis, 0, 0, 1, 1) - self.button_cylinder_axis = QtGui.QPushButton(self.Axis_Tab) - icon14 = QtGui.QIcon() - icon14.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cylinderAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_cylinder_axis.setIcon(icon14) - self.button_cylinder_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_cylinder_axis.setObjectName(_fromUtf8("button_cylinder_axis")) - self.gridLayout.addWidget(self.button_cylinder_axis, 2, 0, 1, 1) - self.button_line_plane_axis = QtGui.QPushButton(self.Axis_Tab) - icon15 = QtGui.QIcon() - icon15.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePlaneAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_line_plane_axis.setIcon(icon15) - self.button_line_plane_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_line_plane_axis.setObjectName(_fromUtf8("button_line_plane_axis")) - self.gridLayout.addWidget(self.button_line_plane_axis, 7, 0, 1, 1) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.button_twopoints_axis = QtGui.QPushButton(self.Axis_Tab) - icon16 = QtGui.QIcon() - icon16.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_2pointsLine.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_twopoints_axis.setIcon(icon16) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.button_twopoints_axis.sizePolicy().hasHeightForWidth()) + self.button_twopoints_axis.setSizePolicy(sizePolicy) + icon15 = QtGui.QIcon() + icon15.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_2pointsLine.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_twopoints_axis.setIcon(icon15) self.button_twopoints_axis.setIconSize(QtCore.QSize(32, 32)) self.button_twopoints_axis.setObjectName(_fromUtf8("button_twopoints_axis")) self.horizontalLayout_2.addWidget(self.button_twopoints_axis) self.extension_twopoints_axis = QtGui.QLineEdit(self.Axis_Tab) + self.extension_twopoints_axis.setMaximumSize(QtCore.QSize(60, 16777215)) self.extension_twopoints_axis.setObjectName(_fromUtf8("extension_twopoints_axis")) self.horizontalLayout_2.addWidget(self.extension_twopoints_axis) self.gridLayout.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) - self.button_2Planes_axis = QtGui.QPushButton(self.Axis_Tab) + self.button_cylinder_axis = QtGui.QPushButton(self.Axis_Tab) + icon16 = QtGui.QIcon() + icon16.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cylinderAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_cylinder_axis.setIcon(icon16) + self.button_cylinder_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_cylinder_axis.setObjectName(_fromUtf8("button_cylinder_axis")) + self.gridLayout.addWidget(self.button_cylinder_axis, 2, 0, 1, 1) + self.button_object_base_axes = QtGui.QPushButton(self.Axis_Tab) icon17 = QtGui.QIcon() - icon17.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_2PlanesAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_2Planes_axis.setIcon(icon17) - self.button_2Planes_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_2Planes_axis.setObjectName(_fromUtf8("button_2Planes_axis")) - self.gridLayout.addWidget(self.button_2Planes_axis, 8, 0, 1, 1) - self.button_plane_axis = QtGui.QPushButton(self.Axis_Tab) - icon18 = QtGui.QIcon() - icon18.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_FaceAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_plane_axis.setIcon(icon18) - self.button_plane_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_plane_axis.setObjectName(_fromUtf8("button_plane_axis")) - self.gridLayout.addWidget(self.button_plane_axis, 4, 0, 1, 1) - self.button_twolines_axis = QtGui.QPushButton(self.Axis_Tab) - icon19 = QtGui.QIcon() - icon19.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_twoLinesAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_twolines_axis.setIcon(icon19) - self.button_twolines_axis.setIconSize(QtCore.QSize(32, 32)) - self.button_twolines_axis.setObjectName(_fromUtf8("button_twolines_axis")) - self.gridLayout.addWidget(self.button_twolines_axis, 3, 0, 1, 1) + icon17.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_baseObjectsAxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_object_base_axes.setIcon(icon17) + self.button_object_base_axes.setIconSize(QtCore.QSize(32, 32)) + self.button_object_base_axes.setObjectName(_fromUtf8("button_object_base_axes")) + self.gridLayout.addWidget(self.button_object_base_axes, 11, 0, 1, 1) self.button_point_line_axis = QtGui.QPushButton(self.Axis_Tab) - icon20 = QtGui.QIcon() - icon20.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointLineAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_point_line_axis.setIcon(icon20) + icon18 = QtGui.QIcon() + icon18.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointLineAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_point_line_axis.setIcon(icon18) self.button_point_line_axis.setIconSize(QtCore.QSize(32, 32)) self.button_point_line_axis.setObjectName(_fromUtf8("button_point_line_axis")) - self.gridLayout.addWidget(self.button_point_line_axis, 5, 0, 1, 1) + self.gridLayout.addWidget(self.button_point_line_axis, 6, 0, 1, 1) self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) self.button_line_point_axis = QtGui.QPushButton(self.Axis_Tab) - icon21 = QtGui.QIcon() - icon21.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_line_point_axis.setIcon(icon21) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.button_line_point_axis.sizePolicy().hasHeightForWidth()) + self.button_line_point_axis.setSizePolicy(sizePolicy) + icon19 = QtGui.QIcon() + icon19.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_line_point_axis.setIcon(icon19) self.button_line_point_axis.setIconSize(QtCore.QSize(32, 32)) self.button_line_point_axis.setObjectName(_fromUtf8("button_line_point_axis")) self.horizontalLayout_7.addWidget(self.button_line_point_axis) self.extension_line_point_axis = QtGui.QLineEdit(self.Axis_Tab) + self.extension_line_point_axis.setMaximumSize(QtCore.QSize(60, 16777215)) self.extension_line_point_axis.setObjectName(_fromUtf8("extension_line_point_axis")) self.horizontalLayout_7.addWidget(self.extension_line_point_axis) - self.gridLayout.addLayout(self.horizontalLayout_7, 6, 0, 1, 1) - self.button_object_base_axes = QtGui.QPushButton(self.Axis_Tab) + self.gridLayout.addLayout(self.horizontalLayout_7, 7, 0, 1, 1) + self.horizontalLayout_5 = QtGui.QHBoxLayout() + self.horizontalLayout_5.setSpacing(5) + self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) + self.button_face_normal = QtGui.QPushButton(self.Axis_Tab) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.button_face_normal.sizePolicy().hasHeightForWidth()) + self.button_face_normal.setSizePolicy(sizePolicy) + icon20 = QtGui.QIcon() + icon20.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_FaceNormal.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_face_normal.setIcon(icon20) + self.button_face_normal.setIconSize(QtCore.QSize(32, 32)) + self.button_face_normal.setObjectName(_fromUtf8("button_face_normal")) + self.horizontalLayout_5.addWidget(self.button_face_normal) + self.extension_face_normal = QtGui.QLineEdit(self.Axis_Tab) + self.extension_face_normal.setMinimumSize(QtCore.QSize(40, 0)) + self.extension_face_normal.setMaximumSize(QtCore.QSize(60, 16777215)) + self.extension_face_normal.setObjectName(_fromUtf8("extension_face_normal")) + self.horizontalLayout_5.addWidget(self.extension_face_normal) + self.gridLayout.addLayout(self.horizontalLayout_5, 5, 0, 1, 1) + self.button_twolines_axis = QtGui.QPushButton(self.Axis_Tab) + icon21 = QtGui.QIcon() + icon21.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_twoLinesAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_twolines_axis.setIcon(icon21) + self.button_twolines_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_twolines_axis.setObjectName(_fromUtf8("button_twolines_axis")) + self.gridLayout.addWidget(self.button_twolines_axis, 3, 0, 1, 1) + self.button_object_axis = QtGui.QPushButton(self.Axis_Tab) icon22 = QtGui.QIcon() - icon22.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_baseObjectsAxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_object_base_axes.setIcon(icon22) - self.button_object_base_axes.setIconSize(QtCore.QSize(32, 32)) - self.button_object_base_axes.setObjectName(_fromUtf8("button_object_base_axes")) - self.gridLayout.addWidget(self.button_object_base_axes, 10, 0, 1, 1) - spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout.addItem(spacerItem1, 9, 0, 1, 1) + icon22.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsAxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_object_axis.setIcon(icon22) + self.button_object_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_object_axis.setObjectName(_fromUtf8("button_object_axis")) + self.gridLayout.addWidget(self.button_object_axis, 0, 0, 1, 1) + self.button_twoplanes_axis = QtGui.QPushButton(self.Axis_Tab) icon23 = QtGui.QIcon() - icon23.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_axis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.tabWidget.addTab(self.Axis_Tab, icon23, _fromUtf8("")) + icon23.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_2PlanesAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_twoplanes_axis.setIcon(icon23) + self.button_twoplanes_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_twoplanes_axis.setObjectName(_fromUtf8("button_twoplanes_axis")) + self.gridLayout.addWidget(self.button_twoplanes_axis, 9, 0, 1, 1) + self.button_plane_axis = QtGui.QPushButton(self.Axis_Tab) + icon24 = QtGui.QIcon() + icon24.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_FaceAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_plane_axis.setIcon(icon24) + self.button_plane_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_plane_axis.setObjectName(_fromUtf8("button_plane_axis")) + self.gridLayout.addWidget(self.button_plane_axis, 4, 0, 1, 1) + self.button_line_plane_axis = QtGui.QPushButton(self.Axis_Tab) + icon25 = QtGui.QIcon() + icon25.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePlaneAxis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_line_plane_axis.setIcon(icon25) + self.button_line_plane_axis.setIconSize(QtCore.QSize(32, 32)) + self.button_line_plane_axis.setObjectName(_fromUtf8("button_line_plane_axis")) + self.gridLayout.addWidget(self.button_line_plane_axis, 8, 0, 1, 1) + spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem2, 10, 0, 1, 1) + icon26 = QtGui.QIcon() + icon26.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_axis.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.Axis_Tab, icon26, _fromUtf8("")) + self.tab_4 = QtGui.QWidget() + self.tab_4.setObjectName(_fromUtf8("tab_4")) + self.gridLayout_5 = QtGui.QGridLayout(self.tab_4) + self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) + self.button_3points_circle = QtGui.QPushButton(self.tab_4) + icon27 = QtGui.QIcon() + icon27.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_3pointsCircle.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_3points_circle.setIcon(icon27) + self.button_3points_circle.setIconSize(QtCore.QSize(32, 32)) + self.button_3points_circle.setObjectName(_fromUtf8("button_3points_circle")) + self.gridLayout_5.addWidget(self.button_3points_circle, 2, 0, 1, 1) + self.button_3points_ellipse = QtGui.QPushButton(self.tab_4) + icon28 = QtGui.QIcon() + icon28.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_3pointsEllipse.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_3points_ellipse.setIcon(icon28) + self.button_3points_ellipse.setIconSize(QtCore.QSize(32, 32)) + self.button_3points_ellipse.setObjectName(_fromUtf8("button_3points_ellipse")) + self.gridLayout_5.addWidget(self.button_3points_ellipse, 3, 0, 1, 1) + self.button_linepoint_circle = QtGui.QPushButton(self.tab_4) + icon29 = QtGui.QIcon() + icon29.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointCircle.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_linepoint_circle.setIcon(icon29) + self.button_linepoint_circle.setIconSize(QtCore.QSize(32, 32)) + self.button_linepoint_circle.setObjectName(_fromUtf8("button_linepoint_circle")) + self.gridLayout_5.addWidget(self.button_linepoint_circle, 1, 0, 1, 1) + self.horizontalLayout_11 = QtGui.QHBoxLayout() + self.horizontalLayout_11.setObjectName(_fromUtf8("horizontalLayout_11")) + self.button_linecenter_circle = QtGui.QPushButton(self.tab_4) + icon30 = QtGui.QIcon() + icon30.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_lineCenterCircle.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_linecenter_circle.setIcon(icon30) + self.button_linecenter_circle.setIconSize(QtCore.QSize(32, 32)) + self.button_linecenter_circle.setObjectName(_fromUtf8("button_linecenter_circle")) + self.horizontalLayout_11.addWidget(self.button_linecenter_circle) + self.radius_circle = QtGui.QLineEdit(self.tab_4) + self.radius_circle.setMinimumSize(QtCore.QSize(40, 0)) + self.radius_circle.setMaximumSize(QtCore.QSize(60, 16777215)) + self.radius_circle.setObjectName(_fromUtf8("radius_circle")) + self.horizontalLayout_11.addWidget(self.radius_circle) + self.gridLayout_5.addLayout(self.horizontalLayout_11, 0, 0, 1, 1) + spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_5.addItem(spacerItem3, 4, 0, 1, 1) + icon31 = QtGui.QIcon() + icon31.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_circle.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.tab_4, icon31, _fromUtf8("")) self.Plane_Tab = QtGui.QWidget() self.Plane_Tab.setObjectName(_fromUtf8("Plane_Tab")) self.gridLayout_9 = QtGui.QGridLayout(self.Plane_Tab) self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) + self.gridLayout_16 = QtGui.QGridLayout() + self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16")) + self.button_planeandpoint_plane = QtGui.QPushButton(self.Plane_Tab) + icon32 = QtGui.QIcon() + icon32.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointPlanePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_planeandpoint_plane.setIcon(icon32) + self.button_planeandpoint_plane.setIconSize(QtCore.QSize(32, 32)) + self.button_planeandpoint_plane.setObjectName(_fromUtf8("button_planeandpoint_plane")) + self.gridLayout_16.addWidget(self.button_planeandpoint_plane, 0, 0, 1, 1) + self.extension_planePointPlane = QtGui.QLineEdit(self.Plane_Tab) + self.extension_planePointPlane.setMinimumSize(QtCore.QSize(40, 0)) + self.extension_planePointPlane.setMaximumSize(QtCore.QSize(60, 16777215)) + self.extension_planePointPlane.setObjectName(_fromUtf8("extension_planePointPlane")) + self.gridLayout_16.addWidget(self.extension_planePointPlane, 0, 1, 1, 1) + self.gridLayout_9.addLayout(self.gridLayout_16, 3, 0, 1, 1) + spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_9.addItem(spacerItem4, 6, 0, 1, 1) + self.button_axis_point_plane = QtGui.QPushButton(self.Plane_Tab) + icon33 = QtGui.QIcon() + icon33.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointPlane2.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_axis_point_plane.setIcon(icon33) + self.button_axis_point_plane.setIconSize(QtCore.QSize(32, 32)) + self.button_axis_point_plane.setObjectName(_fromUtf8("button_axis_point_plane")) + self.gridLayout_9.addWidget(self.button_axis_point_plane, 2, 0, 1, 1) + self.button_object_center_planes = QtGui.QPushButton(self.Plane_Tab) + icon34 = QtGui.QIcon() + icon34.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsPlanes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_object_center_planes.setIcon(icon34) + self.button_object_center_planes.setIconSize(QtCore.QSize(32, 32)) + self.button_object_center_planes.setObjectName(_fromUtf8("button_object_center_planes")) + self.gridLayout_9.addWidget(self.button_object_center_planes, 9, 0, 1, 1) + self.gridLayout_8 = QtGui.QGridLayout() + self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) + self.button_planeandaxis_plane = QtGui.QPushButton(self.Plane_Tab) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.button_planeandaxis_plane.sizePolicy().hasHeightForWidth()) + self.button_planeandaxis_plane.setSizePolicy(sizePolicy) + icon35 = QtGui.QIcon() + icon35.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_planeLinePlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_planeandaxis_plane.setIcon(icon35) + self.button_planeandaxis_plane.setIconSize(QtCore.QSize(32, 32)) + self.button_planeandaxis_plane.setObjectName(_fromUtf8("button_planeandaxis_plane")) + self.gridLayout_8.addWidget(self.button_planeandaxis_plane, 0, 0, 1, 1) + self.angle_planeandaxis_plane = QtGui.QLineEdit(self.Plane_Tab) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.angle_planeandaxis_plane.sizePolicy().hasHeightForWidth()) + self.angle_planeandaxis_plane.setSizePolicy(sizePolicy) + self.angle_planeandaxis_plane.setMinimumSize(QtCore.QSize(40, 0)) + self.angle_planeandaxis_plane.setMaximumSize(QtCore.QSize(60, 16777215)) + self.angle_planeandaxis_plane.setObjectName(_fromUtf8("angle_planeandaxis_plane")) + self.gridLayout_8.addWidget(self.angle_planeandaxis_plane, 0, 1, 1, 1) + self.gridLayout_9.addLayout(self.gridLayout_8, 4, 0, 1, 1) + self.button_axisandpoint_plane = QtGui.QPushButton(self.Plane_Tab) + icon36 = QtGui.QIcon() + icon36.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_axisandpoint_plane.setIcon(icon36) + self.button_axisandpoint_plane.setIconSize(QtCore.QSize(32, 32)) + self.button_axisandpoint_plane.setObjectName(_fromUtf8("button_axisandpoint_plane")) + self.gridLayout_9.addWidget(self.button_axisandpoint_plane, 1, 0, 1, 1) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.button_click_for_plane = QtGui.QPushButton(self.Plane_Tab) @@ -250,9 +437,9 @@ class Ui_Form(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.button_click_for_plane.sizePolicy().hasHeightForWidth()) self.button_click_for_plane.setSizePolicy(sizePolicy) - icon24 = QtGui.QIcon() - icon24.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_clickPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_click_for_plane.setIcon(icon24) + icon37 = QtGui.QIcon() + icon37.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_clickPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_click_for_plane.setIcon(icon37) self.button_click_for_plane.setIconSize(QtCore.QSize(32, 32)) self.button_click_for_plane.setObjectName(_fromUtf8("button_click_for_plane")) self.horizontalLayout_3.addWidget(self.button_click_for_plane) @@ -276,82 +463,54 @@ class Ui_Form(object): self.width_plane.setMaximumSize(QtCore.QSize(60, 16777215)) self.width_plane.setObjectName(_fromUtf8("width_plane")) self.horizontalLayout_3.addWidget(self.width_plane) - self.gridLayout_9.addLayout(self.horizontalLayout_3, 6, 0, 1, 1) - self.gridLayout_16 = QtGui.QGridLayout() - self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16")) - self.button_planeandpoint_plane = QtGui.QPushButton(self.Plane_Tab) - icon25 = QtGui.QIcon() - icon25.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_pointPlanePoint.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_planeandpoint_plane.setIcon(icon25) - self.button_planeandpoint_plane.setIconSize(QtCore.QSize(32, 32)) - self.button_planeandpoint_plane.setObjectName(_fromUtf8("button_planeandpoint_plane")) - self.gridLayout_16.addWidget(self.button_planeandpoint_plane, 0, 0, 1, 1) - self.extension_planePointPlane = QtGui.QLineEdit(self.Plane_Tab) - self.extension_planePointPlane.setMinimumSize(QtCore.QSize(40, 0)) - self.extension_planePointPlane.setMaximumSize(QtCore.QSize(60, 16777215)) - self.extension_planePointPlane.setObjectName(_fromUtf8("extension_planePointPlane")) - self.gridLayout_16.addWidget(self.extension_planePointPlane, 0, 1, 1, 1) - self.gridLayout_9.addLayout(self.gridLayout_16, 3, 0, 1, 1) - self.gridLayout_8 = QtGui.QGridLayout() - self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) - self.button_planeandaxis_plane = QtGui.QPushButton(self.Plane_Tab) + self.gridLayout_9.addLayout(self.horizontalLayout_3, 7, 0, 1, 1) + self.horizontalLayout_12 = QtGui.QHBoxLayout() + self.horizontalLayout_12.setObjectName(_fromUtf8("horizontalLayout_12")) + self.button_face_tangent = QtGui.QPushButton(self.Plane_Tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.button_planeandaxis_plane.sizePolicy().hasHeightForWidth()) - self.button_planeandaxis_plane.setSizePolicy(sizePolicy) - icon26 = QtGui.QIcon() - icon26.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_planeLinePlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_planeandaxis_plane.setIcon(icon26) - self.button_planeandaxis_plane.setIconSize(QtCore.QSize(32, 32)) - self.button_planeandaxis_plane.setObjectName(_fromUtf8("button_planeandaxis_plane")) - self.gridLayout_8.addWidget(self.button_planeandaxis_plane, 0, 0, 1, 1) - self.angle_planeandaxis_plane = QtGui.QLineEdit(self.Plane_Tab) + sizePolicy.setHeightForWidth(self.button_face_tangent.sizePolicy().hasHeightForWidth()) + self.button_face_tangent.setSizePolicy(sizePolicy) + icon38 = QtGui.QIcon() + icon38.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_FaceTangent.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_face_tangent.setIcon(icon38) + self.button_face_tangent.setIconSize(QtCore.QSize(32, 32)) + self.button_face_tangent.setObjectName(_fromUtf8("button_face_tangent")) + self.horizontalLayout_12.addWidget(self.button_face_tangent) + self.length_plane_2 = QtGui.QLineEdit(self.Plane_Tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.angle_planeandaxis_plane.sizePolicy().hasHeightForWidth()) - self.angle_planeandaxis_plane.setSizePolicy(sizePolicy) - self.angle_planeandaxis_plane.setMinimumSize(QtCore.QSize(40, 0)) - self.angle_planeandaxis_plane.setMaximumSize(QtCore.QSize(60, 16777215)) - self.angle_planeandaxis_plane.setObjectName(_fromUtf8("angle_planeandaxis_plane")) - self.gridLayout_8.addWidget(self.angle_planeandaxis_plane, 0, 1, 1, 1) - self.gridLayout_9.addLayout(self.gridLayout_8, 4, 0, 1, 1) - self.button_object_center_planes = QtGui.QPushButton(self.Plane_Tab) - icon27 = QtGui.QIcon() - icon27.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_centerObjectsPlanes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_object_center_planes.setIcon(icon27) - self.button_object_center_planes.setIconSize(QtCore.QSize(32, 32)) - self.button_object_center_planes.setObjectName(_fromUtf8("button_object_center_planes")) - self.gridLayout_9.addWidget(self.button_object_center_planes, 8, 0, 1, 1) - self.button_axisandpoint_plane = QtGui.QPushButton(self.Plane_Tab) - icon28 = QtGui.QIcon() - icon28.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_axisandpoint_plane.setIcon(icon28) - self.button_axisandpoint_plane.setIconSize(QtCore.QSize(32, 32)) - self.button_axisandpoint_plane.setObjectName(_fromUtf8("button_axisandpoint_plane")) - self.gridLayout_9.addWidget(self.button_axisandpoint_plane, 1, 0, 1, 1) - spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_9.addItem(spacerItem2, 5, 0, 1, 1) - self.button_axis_point_plane = QtGui.QPushButton(self.Plane_Tab) - icon29 = QtGui.QIcon() - icon29.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_linePointPlane2.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_axis_point_plane.setIcon(icon29) - self.button_axis_point_plane.setIconSize(QtCore.QSize(32, 32)) - self.button_axis_point_plane.setObjectName(_fromUtf8("button_axis_point_plane")) - self.gridLayout_9.addWidget(self.button_axis_point_plane, 2, 0, 1, 1) + sizePolicy.setHeightForWidth(self.length_plane_2.sizePolicy().hasHeightForWidth()) + self.length_plane_2.setSizePolicy(sizePolicy) + self.length_plane_2.setMinimumSize(QtCore.QSize(40, 0)) + self.length_plane_2.setMaximumSize(QtCore.QSize(60, 16777215)) + self.length_plane_2.setObjectName(_fromUtf8("length_plane_2")) + self.horizontalLayout_12.addWidget(self.length_plane_2) + self.width_plane_2 = QtGui.QLineEdit(self.Plane_Tab) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.width_plane_2.sizePolicy().hasHeightForWidth()) + self.width_plane_2.setSizePolicy(sizePolicy) + self.width_plane_2.setMinimumSize(QtCore.QSize(40, 0)) + self.width_plane_2.setMaximumSize(QtCore.QSize(60, 16777215)) + self.width_plane_2.setObjectName(_fromUtf8("width_plane_2")) + self.horizontalLayout_12.addWidget(self.width_plane_2) + self.gridLayout_9.addLayout(self.horizontalLayout_12, 5, 0, 1, 1) self.button_threepoints_plane = QtGui.QPushButton(self.Plane_Tab) - icon30 = QtGui.QIcon() - icon30.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_threePointsPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_threepoints_plane.setIcon(icon30) + icon39 = QtGui.QIcon() + icon39.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_threePointsPlane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_threepoints_plane.setIcon(icon39) self.button_threepoints_plane.setIconSize(QtCore.QSize(32, 32)) self.button_threepoints_plane.setObjectName(_fromUtf8("button_threepoints_plane")) self.gridLayout_9.addWidget(self.button_threepoints_plane, 0, 0, 1, 1) - spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_9.addItem(spacerItem3, 7, 0, 1, 1) - icon31 = QtGui.QIcon() - icon31.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_plane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.tabWidget.addTab(self.Plane_Tab, icon31, _fromUtf8("")) + spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_9.addItem(spacerItem5, 8, 0, 1, 1) + icon40 = QtGui.QIcon() + icon40.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_plane.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.Plane_Tab, icon40, _fromUtf8("")) self.Objects_Tab2 = QtGui.QWidget() self.Objects_Tab2.setEnabled(True) self.Objects_Tab2.setMinimumSize(QtCore.QSize(0, 0)) @@ -361,9 +520,9 @@ class Ui_Form(object): self.gridLayout_6 = QtGui.QGridLayout() self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) self.button_cylinder_create = QtGui.QPushButton(self.Objects_Tab2) - icon32 = QtGui.QIcon() - icon32.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cylinder.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_cylinder_create.setIcon(icon32) + icon41 = QtGui.QIcon() + icon41.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cylinder.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_cylinder_create.setIcon(icon41) self.button_cylinder_create.setIconSize(QtCore.QSize(32, 32)) self.button_cylinder_create.setObjectName(_fromUtf8("button_cylinder_create")) self.gridLayout_6.addWidget(self.button_cylinder_create, 0, 0, 1, 1) @@ -391,9 +550,9 @@ class Ui_Form(object): self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.button_cube_create = QtGui.QPushButton(self.Objects_Tab2) - icon33 = QtGui.QIcon() - icon33.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cube.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_cube_create.setIcon(icon33) + icon42 = QtGui.QIcon() + icon42.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_cube.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_cube_create.setIcon(icon42) self.button_cube_create.setIconSize(QtCore.QSize(32, 32)) self.button_cube_create.setObjectName(_fromUtf8("button_cube_create")) self.horizontalLayout_4.addWidget(self.button_cube_create) @@ -419,18 +578,18 @@ class Ui_Form(object): self.horizontalLayout_4.addWidget(self.height_cube) self.gridLayout_12.addLayout(self.horizontalLayout_4, 4, 0, 1, 1) self.button_boundingboxes = QtGui.QPushButton(self.Objects_Tab2) - icon34 = QtGui.QIcon() - icon34.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_boundingBoxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_boundingboxes.setIcon(icon34) + icon43 = QtGui.QIcon() + icon43.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_boundingBoxes.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_boundingboxes.setIcon(icon43) self.button_boundingboxes.setIconSize(QtCore.QSize(32, 32)) self.button_boundingboxes.setObjectName(_fromUtf8("button_boundingboxes")) self.gridLayout_12.addWidget(self.button_boundingboxes, 0, 0, 1, 1) - spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_12.addItem(spacerItem4, 5, 0, 1, 1) + spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_12.addItem(spacerItem6, 5, 0, 1, 1) self.button_boundingbox = QtGui.QPushButton(self.Objects_Tab2) - icon35 = QtGui.QIcon() - icon35.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_boundingBox.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_boundingbox.setIcon(icon35) + icon44 = QtGui.QIcon() + icon44.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_boundingBox.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_boundingbox.setIcon(icon44) self.button_boundingbox.setIconSize(QtCore.QSize(32, 32)) self.button_boundingbox.setObjectName(_fromUtf8("button_boundingbox")) self.gridLayout_12.addWidget(self.button_boundingbox, 1, 0, 1, 1) @@ -442,9 +601,9 @@ class Ui_Form(object): self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName(_fromUtf8("line")) self.gridLayout_12.addWidget(self.line, 2, 0, 1, 1) - icon36 = QtGui.QIcon() - icon36.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_box.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.tabWidget.addTab(self.Objects_Tab2, icon36, _fromUtf8("")) + icon45 = QtGui.QIcon() + icon45.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_box.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.Objects_Tab2, icon45, _fromUtf8("")) self.View_Tab = QtGui.QWidget() self.View_Tab.setObjectName(_fromUtf8("View_Tab")) self.gridLayout_13 = QtGui.QGridLayout(self.View_Tab) @@ -455,98 +614,277 @@ class Ui_Form(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.button_alignview.sizePolicy().hasHeightForWidth()) self.button_alignview.setSizePolicy(sizePolicy) - icon37 = QtGui.QIcon() - icon37.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_viewAlign.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.button_alignview.setIcon(icon37) + icon46 = QtGui.QIcon() + icon46.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_viewAlign.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.button_alignview.setIcon(icon46) self.button_alignview.setIconSize(QtCore.QSize(32, 32)) self.button_alignview.setObjectName(_fromUtf8("button_alignview")) self.gridLayout_13.addWidget(self.button_alignview, 0, 0, 1, 1) - spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_13.addItem(spacerItem5, 1, 0, 1, 1) - icon38 = QtGui.QIcon() - icon38.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_view.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.tabWidget.addTab(self.View_Tab, icon38, _fromUtf8("")) - self.Origin_Tab = QtGui.QWidget() - self.Origin_Tab.setObjectName(_fromUtf8("Origin_Tab")) - self.gridLayout_7 = QtGui.QGridLayout(self.Origin_Tab) - self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) - self.button_origin = QtGui.QPushButton(self.Origin_Tab) - self.button_origin.setIcon(icon) - self.button_origin.setIconSize(QtCore.QSize(32, 32)) - self.button_origin.setObjectName(_fromUtf8("button_origin")) - self.verticalLayout_3.addWidget(self.button_origin) - spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_3.addItem(spacerItem6) - self.gridLayout_7.addLayout(self.verticalLayout_3, 0, 0, 1, 1) - self.tabWidget.addTab(self.Origin_Tab, icon, _fromUtf8("")) - self.gridLayout_2.addWidget(self.tabWidget, 0, 0, 1, 1) + spacerItem7 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_13.addItem(spacerItem7, 1, 0, 1, 1) + icon47 = QtGui.QIcon() + icon47.addPixmap(QtGui.QPixmap(_fromUtf8("icons:WF_view.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.tabWidget.addTab(self.View_Tab, icon47, _fromUtf8("")) + self.Modif_Tab = QtGui.QWidget() + self.Modif_Tab.setObjectName(_fromUtf8("Modif_Tab")) + self.gridLayout_11 = QtGui.QGridLayout(self.Modif_Tab) + self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) + self.tabWidget_2 = QtGui.QTabWidget(self.Modif_Tab) + self.tabWidget_2.setObjectName(_fromUtf8("tabWidget_2")) + self.tab_5 = QtGui.QWidget() + self.tab_5.setObjectName(_fromUtf8("tab_5")) + self.gridLayout_2 = QtGui.QGridLayout(self.tab_5) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.gridLayout_17 = QtGui.QGridLayout() + self.gridLayout_17.setObjectName(_fromUtf8("gridLayout_17")) + self.gridLayout_19 = QtGui.QGridLayout() + self.gridLayout_19.setObjectName(_fromUtf8("gridLayout_19")) + self.label_angle = QtGui.QLabel(self.tab_5) + self.label_angle.setMaximumSize(QtCore.QSize(70, 16777215)) + self.label_angle.setObjectName(_fromUtf8("label_angle")) + self.gridLayout_19.addWidget(self.label_angle, 0, 0, 1, 1) + self.angle_cut_object = QtGui.QLineEdit(self.tab_5) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.angle_cut_object.sizePolicy().hasHeightForWidth()) + self.angle_cut_object.setSizePolicy(sizePolicy) + self.angle_cut_object.setMinimumSize(QtCore.QSize(0, 0)) + self.angle_cut_object.setMaximumSize(QtCore.QSize(50, 16777215)) + self.angle_cut_object.setObjectName(_fromUtf8("angle_cut_object")) + self.gridLayout_19.addWidget(self.angle_cut_object, 0, 1, 1, 1) + self.gridLayout_17.addLayout(self.gridLayout_19, 0, 0, 1, 1) + self.gridLayout_20 = QtGui.QGridLayout() + self.gridLayout_20.setObjectName(_fromUtf8("gridLayout_20")) + self.label_thickness = QtGui.QLabel(self.tab_5) + self.label_thickness.setMaximumSize(QtCore.QSize(70, 16777215)) + self.label_thickness.setObjectName(_fromUtf8("label_thickness")) + self.gridLayout_20.addWidget(self.label_thickness, 0, 0, 1, 1) + self.thickness_cut_object = QtGui.QLineEdit(self.tab_5) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.thickness_cut_object.sizePolicy().hasHeightForWidth()) + self.thickness_cut_object.setSizePolicy(sizePolicy) + self.thickness_cut_object.setMaximumSize(QtCore.QSize(50, 16777215)) + self.thickness_cut_object.setObjectName(_fromUtf8("thickness_cut_object")) + self.gridLayout_20.addWidget(self.thickness_cut_object, 0, 1, 1, 1) + self.gridLayout_17.addLayout(self.gridLayout_20, 1, 0, 1, 1) + self.horizontalLayout_8 = QtGui.QHBoxLayout() + self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) + self.button_cut_reset = QtGui.QPushButton(self.tab_5) + self.button_cut_reset.setMinimumSize(QtCore.QSize(40, 0)) + self.button_cut_reset.setMaximumSize(QtCore.QSize(60, 16777215)) + self.button_cut_reset.setObjectName(_fromUtf8("button_cut_reset")) + self.horizontalLayout_8.addWidget(self.button_cut_reset) + spacerItem8 = QtGui.QSpacerItem(18, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_8.addItem(spacerItem8) + self.button_cut_apply = QtGui.QPushButton(self.tab_5) + self.button_cut_apply.setEnabled(False) + self.button_cut_apply.setMaximumSize(QtCore.QSize(50, 16777215)) + self.button_cut_apply.setIconSize(QtCore.QSize(32, 32)) + self.button_cut_apply.setObjectName(_fromUtf8("button_cut_apply")) + self.horizontalLayout_8.addWidget(self.button_cut_apply) + self.gridLayout_17.addLayout(self.horizontalLayout_8, 2, 0, 1, 1) + self.gridLayout_2.addLayout(self.gridLayout_17, 1, 0, 1, 1) + self.gridLayout_18 = QtGui.QGridLayout() + self.gridLayout_18.setObjectName(_fromUtf8("gridLayout_18")) + self.button_cut_select_object = QtGui.QPushButton(self.tab_5) + self.button_cut_select_object.setMinimumSize(QtCore.QSize(130, 31)) + self.button_cut_select_object.setMaximumSize(QtCore.QSize(250, 40)) + self.button_cut_select_object.setObjectName(_fromUtf8("button_cut_select_object")) + self.gridLayout_18.addWidget(self.button_cut_select_object, 0, 0, 1, 1) + self.info_cut_select_object = QtGui.QLineEdit(self.tab_5) + self.info_cut_select_object.setEnabled(False) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.info_cut_select_object.sizePolicy().hasHeightForWidth()) + self.info_cut_select_object.setSizePolicy(sizePolicy) + self.info_cut_select_object.setReadOnly(True) + self.info_cut_select_object.setObjectName(_fromUtf8("info_cut_select_object")) + self.gridLayout_18.addWidget(self.info_cut_select_object, 1, 0, 1, 1) + self.button_cut_select_line = QtGui.QPushButton(self.tab_5) + self.button_cut_select_line.setEnabled(False) + self.button_cut_select_line.setMinimumSize(QtCore.QSize(130, 31)) + self.button_cut_select_line.setMaximumSize(QtCore.QSize(250, 40)) + self.button_cut_select_line.setObjectName(_fromUtf8("button_cut_select_line")) + self.gridLayout_18.addWidget(self.button_cut_select_line, 2, 0, 1, 1) + self.info_cut_select_axis = QtGui.QLineEdit(self.tab_5) + self.info_cut_select_axis.setEnabled(False) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.info_cut_select_axis.sizePolicy().hasHeightForWidth()) + self.info_cut_select_axis.setSizePolicy(sizePolicy) + self.info_cut_select_axis.setReadOnly(True) + self.info_cut_select_axis.setObjectName(_fromUtf8("info_cut_select_axis")) + self.gridLayout_18.addWidget(self.info_cut_select_axis, 3, 0, 1, 1) + self.button_cut_select_plane = QtGui.QPushButton(self.tab_5) + self.button_cut_select_plane.setEnabled(False) + self.button_cut_select_plane.setMinimumSize(QtCore.QSize(130, 31)) + self.button_cut_select_plane.setMaximumSize(QtCore.QSize(250, 40)) + self.button_cut_select_plane.setObjectName(_fromUtf8("button_cut_select_plane")) + self.gridLayout_18.addWidget(self.button_cut_select_plane, 4, 0, 1, 1) + self.info_cut_select_plane = QtGui.QLineEdit(self.tab_5) + self.info_cut_select_plane.setEnabled(False) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.info_cut_select_plane.sizePolicy().hasHeightForWidth()) + self.info_cut_select_plane.setSizePolicy(sizePolicy) + self.info_cut_select_plane.setReadOnly(True) + self.info_cut_select_plane.setObjectName(_fromUtf8("info_cut_select_plane")) + self.gridLayout_18.addWidget(self.info_cut_select_plane, 5, 0, 1, 1) + self.gridLayout_2.addLayout(self.gridLayout_18, 0, 0, 1, 1) + spacerItem9 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem9, 2, 0, 1, 1) + self.tabWidget_2.addTab(self.tab_5, _fromUtf8("")) + self.gridLayout_11.addWidget(self.tabWidget_2, 0, 0, 1, 1) + self.tabWidget.addTab(self.Modif_Tab, _fromUtf8("")) + self.gridLayout_22.addWidget(self.tabWidget, 0, 0, 1, 1) self.tabWidget_0.addTab(self.tab_2, _fromUtf8("")) - self.gridLayout_11.addWidget(self.tabWidget_0, 0, 0, 1, 1) + self.tab_3 = QtGui.QWidget() + self.tab_3.setObjectName(_fromUtf8("tab_3")) + self.gridLayout_14 = QtGui.QGridLayout(self.tab_3) + self.gridLayout_14.setObjectName(_fromUtf8("gridLayout_14")) + self.radioButton_verbose = QtGui.QRadioButton(self.tab_3) + self.radioButton_verbose.setObjectName(_fromUtf8("radioButton_verbose")) + self.gridLayout_14.addWidget(self.radioButton_verbose, 0, 0, 1, 1) + spacerItem10 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_14.addItem(spacerItem10, 1, 0, 1, 1) + self.tabWidget_0.addTab(self.tab_3, _fromUtf8("")) + self.gridLayout_4.addWidget(self.tabWidget_0, 0, 0, 1, 1) self.scrollArea.setWidget(self.scrollAreaWidgetContents_2) self.gridLayout_15.addWidget(self.scrollArea, 0, 0, 1, 1) + self.horizontalLayout_9 = QtGui.QHBoxLayout() + self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) + self.button_WF_quit = QtGui.QPushButton(Form) + self.button_WF_quit.setObjectName(_fromUtf8("button_WF_quit")) + self.horizontalLayout_9.addWidget(self.button_WF_quit) + spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_9.addItem(spacerItem11) + self.label_release = QtGui.QLabel(Form) + self.label_release.setObjectName(_fromUtf8("label_release")) + self.horizontalLayout_9.addWidget(self.label_release) + self.gridLayout_15.addLayout(self.horizontalLayout_9, 1, 0, 1, 1) self.retranslateUi(Form) self.tabWidget_0.setCurrentIndex(0) - self.tabWidget.setCurrentIndex(0) + self.tabWidget.setCurrentIndex(1) + self.tabWidget_2.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "WorkFeature", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_face_point.setToolTip(QtGui.QApplication.translate("Form", "Create a projection Point of a Point onto a Face.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_face_point.setText(QtGui.QApplication.translate("Form", "Point=(Point,Face)", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at center location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_origin.setToolTip(QtGui.QApplication.translate("Form", "Create at origin: a point and X,Y and Z axis and XZ,XY and YZ planes", None, QtGui.QApplication.UnicodeUTF8)) + self.button_origin.setText(QtGui.QApplication.translate("Form", "Origin", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.Origin_Tab), QtGui.QApplication.translate("Form", "Origin", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at center location of all selected Object(s).\n" +" if BBox is not toggled\n" +" This point is the MEAN location of all center of Mass (if exist) of all objects.\n" +" All center of Mass will be created too.\n" +" if BBox is toggled\n" +" This point is the center of the Global X,Y,Z bounding box of all objects.\n" +" This bounding box alway exists (especially for draft objects).\n" +" Be aware this point is not necessary the center of Mass of all Objects!", None, QtGui.QApplication.UnicodeUTF8)) self.button_object_center.setText(QtGui.QApplication.translate("Form", "Object(s) Center", None, QtGui.QApplication.UnicodeUTF8)) + self.checkBox_object_center.setText(QtGui.QApplication.translate("Form", "BBox", None, QtGui.QApplication.UnicodeUTF8)) + self.button_Npoints_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at mean location of all selected points.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_Npoints_center.setText(QtGui.QApplication.translate("Form", "Points Center", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_center.setToolTip(QtGui.QApplication.translate("Form", "Create Point(s):\n" +"Cut each selected Lines(s) in 2 (n) parts and create a (n-1) Point(s) at ends of edge(s).\n" +"The number indicates how many parts to consider.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_center.setText(QtGui.QApplication.translate("Form", "Line(s) Center", None, QtGui.QApplication.UnicodeUTF8)) + self.spin_line_center.setToolTip(QtGui.QApplication.translate("Form", "The number indicates in how many parts each selected Lines(s) will be cut.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_extrema.setToolTip(QtGui.QApplication.translate("Form", "Create Points at start and end location of each selected Line(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_extrema.setText(QtGui.QApplication.translate("Form", "Line(s) Extrema", None, QtGui.QApplication.UnicodeUTF8)) self.button_circle_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at center location of each selected Circle(s) or Arc(s).", None, QtGui.QApplication.UnicodeUTF8)) self.button_circle_center.setText(QtGui.QApplication.translate("Form", "Circle(s) Center", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_base_point.setToolTip(QtGui.QApplication.translate("Form", "Create Base Point of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_base_point.setText(QtGui.QApplication.translate("Form", "Object(s) Base Point", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_on_line.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at a certain distance along the line \n" +"respecting to the choosen reference starting point.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_on_line.setText(QtGui.QApplication.translate("Form", "Point along Line", None, QtGui.QApplication.UnicodeUTF8)) + self.distance_point_on_line.setToolTip(QtGui.QApplication.translate("Form", "Distance from the extremity", None, QtGui.QApplication.UnicodeUTF8)) + self.distance_point_on_line.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at center location of each selected Face(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_center.setText(QtGui.QApplication.translate("Form", "Face(s) Center", None, QtGui.QApplication.UnicodeUTF8)) self.button_line_face_point.setToolTip(QtGui.QApplication.translate("Form", "Create a point at the intersection of the Line and Plane selected.", None, QtGui.QApplication.UnicodeUTF8)) self.button_line_face_point.setText(QtGui.QApplication.translate("Form", "Point=(Line,Face) ", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_line_point.setToolTip(QtGui.QApplication.translate("Form", "Create a projection Point of a Point onto a Line and symetric point.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_line_point.setText(QtGui.QApplication.translate("Form", "Point=(Line,Point) ", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_face_point.setToolTip(QtGui.QApplication.translate("Form", "Create a projection Point of a Point onto a Face.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_point_face_point.setText(QtGui.QApplication.translate("Form", "Point=(Point,Face)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twolines_point.setToolTip(QtGui.QApplication.translate("Form", "Plot one or two Point(s) at minimum distance of two Lines\n" +"Create a Point at intersection of 2 crossing Lines.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twolines_point.setText(QtGui.QApplication.translate("Form", "Point=(Line,Line) ", None, QtGui.QApplication.UnicodeUTF8)) self.button_click_for_point.setToolTip(QtGui.QApplication.translate("Form", "Create a Point on a Plane perpendicular to the view at location of one mouse click.\n" "Click first on the Button then click once on the View (with no object in background).\n" "Click first on the Button then click once on the View (with an object in background) will attach the point to the surface of the object.\n" "", None, QtGui.QApplication.UnicodeUTF8)) self.button_click_for_point.setText(QtGui.QApplication.translate("Form", "Click", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at mid point location of each selected Line(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_center.setText(QtGui.QApplication.translate("Form", "Line(s) Center", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_line_point.setToolTip(QtGui.QApplication.translate("Form", "Create a projection Point of a Point onto a Line and symetric point.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_line_point.setText(QtGui.QApplication.translate("Form", "Point=(Line,Point) ", None, QtGui.QApplication.UnicodeUTF8)) - self.button_face_center.setToolTip(QtGui.QApplication.translate("Form", "Create a Point at center location of each selected Face(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_face_center.setText(QtGui.QApplication.translate("Form", "Face(s) Center", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_extrema.setToolTip(QtGui.QApplication.translate("Form", "Create Points at start and end location of each selected Line(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_extrema.setText(QtGui.QApplication.translate("Form", "Line(s) Extrema", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_on_line.setToolTip(QtGui.QApplication.translate("Form", "Create a Point on a line at some distance of the extremity point selected.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_point_on_line.setText(QtGui.QApplication.translate("Form", "Point along Line", None, QtGui.QApplication.UnicodeUTF8)) - self.distance_point_on_line.setToolTip(QtGui.QApplication.translate("Form", "Distance from the extremity", None, QtGui.QApplication.UnicodeUTF8)) - self.distance_point_on_line.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_base_point.setToolTip(QtGui.QApplication.translate("Form", "Create Base Point of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_base_point.setText(QtGui.QApplication.translate("Form", "Object(s) Base Point", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.Point_Tab), QtGui.QApplication.translate("Form", "Point", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_axis.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Axes at center location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_axis.setText(QtGui.QApplication.translate("Form", "Object(s) X, Y, Z Axes", None, QtGui.QApplication.UnicodeUTF8)) - self.button_cylinder_axis.setToolTip(QtGui.QApplication.translate("Form", "Create the Axis of a Cylinder.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_cylinder_axis.setText(QtGui.QApplication.translate("Form", "Cylinder(s) Axis", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_plane_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis on a Plane by projection from anoher Axis.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_line_plane_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Plane,Axis)", None, QtGui.QApplication.UnicodeUTF8)) self.button_twopoints_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis crossing 2 Points.", None, QtGui.QApplication.UnicodeUTF8)) self.button_twopoints_axis.setText(QtGui.QApplication.translate("Form", "Two Points Axis", None, QtGui.QApplication.UnicodeUTF8)) self.extension_twopoints_axis.setToolTip(QtGui.QApplication.translate("Form", "Distance for the extensions on extrema", None, QtGui.QApplication.UnicodeUTF8)) self.extension_twopoints_axis.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) - self.button_2Planes_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis by intersect of 2 Planes.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_2Planes_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Plane,Plane)", None, QtGui.QApplication.UnicodeUTF8)) - self.button_plane_axis.setToolTip(QtGui.QApplication.translate("Form", "Create 2 Perpendicular Axes at center location of a Plane.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_plane_axis.setText(QtGui.QApplication.translate("Form", "Plane(s) Axes", None, QtGui.QApplication.UnicodeUTF8)) - self.button_twolines_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis between 2 Axes.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_twolines_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Line,Line)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cylinder_axis.setToolTip(QtGui.QApplication.translate("Form", "Create the Axis of a Cylinder.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cylinder_axis.setText(QtGui.QApplication.translate("Form", "Cylinder(s) Axis", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_base_axes.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Axes at Base location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_base_axes.setText(QtGui.QApplication.translate("Form", "Object(s) Base Axes", None, QtGui.QApplication.UnicodeUTF8)) self.button_point_line_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis parallel to an Axis and crossing a Point.", None, QtGui.QApplication.UnicodeUTF8)) self.button_point_line_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Point,Axis)", None, QtGui.QApplication.UnicodeUTF8)) self.button_line_point_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis perpendicular to an Axis and crossing a Point.", None, QtGui.QApplication.UnicodeUTF8)) self.button_line_point_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Axis,Point)", None, QtGui.QApplication.UnicodeUTF8)) self.extension_line_point_axis.setToolTip(QtGui.QApplication.translate("Form", "Distance for the extensions on extrema.", None, QtGui.QApplication.UnicodeUTF8)) self.extension_line_point_axis.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_base_axes.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Axes at Base location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_base_axes.setText(QtGui.QApplication.translate("Form", "Object(s) Base Axes", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_normal.setToolTip(QtGui.QApplication.translate("Form", "Create a normal Axis at click location of a Face.\n" +"Click first in the view to select and object,\n" +"then push the button, \n" +"then click on a location on the selected object.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_normal.setText(QtGui.QApplication.translate("Form", "Face Normal", None, QtGui.QApplication.UnicodeUTF8)) + self.extension_face_normal.setToolTip(QtGui.QApplication.translate("Form", "Length of Normal Axis.", None, QtGui.QApplication.UnicodeUTF8)) + self.extension_face_normal.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twolines_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis between 2 Axes.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twolines_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Line,Line)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_axis.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Axes at center location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_axis.setText(QtGui.QApplication.translate("Form", "Object(s) X, Y, Z Axes", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twoplanes_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis by intersect of 2 Planes.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_twoplanes_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Plane,Plane)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_plane_axis.setToolTip(QtGui.QApplication.translate("Form", "Create 2 Perpendicular Axes at center location of a Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_plane_axis.setText(QtGui.QApplication.translate("Form", "Plane(s) Axes", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_plane_axis.setToolTip(QtGui.QApplication.translate("Form", "Create an Axis on a Plane by projection from anoher Axis.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_line_plane_axis.setText(QtGui.QApplication.translate("Form", "Axis=(Plane,Axis)", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.Axis_Tab), QtGui.QApplication.translate("Form", "Axis", None, QtGui.QApplication.UnicodeUTF8)) + self.button_3points_circle.setToolTip(QtGui.QApplication.translate("Form", "Select 3 Points to create a Circle.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_3points_circle.setText(QtGui.QApplication.translate("Form", "Circle=(3 points)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_3points_ellipse.setToolTip(QtGui.QApplication.translate("Form", "Select a center and 2 Points to create an Ellipse.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_3points_ellipse.setText(QtGui.QApplication.translate("Form", "Ellipse=(3 points)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_linepoint_circle.setToolTip(QtGui.QApplication.translate("Form", "Select an Axis and a Point to create a Circle\n" +"centered on the Axis and tangenting the Point.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_linepoint_circle.setText(QtGui.QApplication.translate("Form", "Circle=(Axis, point)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_linecenter_circle.setToolTip(QtGui.QApplication.translate("Form", "Select an Axis and a Point to create a Circle\n" +"centered on the Point, perpendicular to the Axis \n" +"with the given radius.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_linecenter_circle.setText(QtGui.QApplication.translate("Form", "Circle=(Axis, center)", None, QtGui.QApplication.UnicodeUTF8)) + self.radius_circle.setToolTip(QtGui.QApplication.translate("Form", "Radius of the Circle.", None, QtGui.QApplication.UnicodeUTF8)) + self.radius_circle.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), QtGui.QApplication.translate("Form", "Circle", None, QtGui.QApplication.UnicodeUTF8)) + self.button_planeandpoint_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane crossing a Point and parallel to a Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_planeandpoint_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, Plane)", None, QtGui.QApplication.UnicodeUTF8)) + self.extension_planePointPlane.setToolTip(QtGui.QApplication.translate("Form", "Distance for the extensions of the new Plane compared to initial one.", None, QtGui.QApplication.UnicodeUTF8)) + self.extension_planePointPlane.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_axis_point_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane perpendicular to a Line and crossing a Point.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_axis_point_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, _|Axis)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_center_planes.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Planes (XY, XZ and YZ) at center location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) + self.button_object_center_planes.setText(QtGui.QApplication.translate("Form", "Object(s) Center Planes", None, QtGui.QApplication.UnicodeUTF8)) + self.button_planeandaxis_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a Plane crossing a Line and perpendicular to a Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_planeandaxis_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Plane, Axis)", None, QtGui.QApplication.UnicodeUTF8)) + self.angle_planeandaxis_plane.setToolTip(QtGui.QApplication.translate("Form", "Angle relative to the Plane (in degrees).", None, QtGui.QApplication.UnicodeUTF8)) + self.angle_planeandaxis_plane.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_axisandpoint_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane crossing a Line and a Point.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_axisandpoint_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, Axis)", None, QtGui.QApplication.UnicodeUTF8)) self.button_click_for_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a Plane perpendicular to the view at location of one mouse click.\n" "Click first on the Button then click once on the View.\n" "Click first on the Button then click once on one object of the View\n" @@ -557,20 +895,15 @@ class Ui_Form(object): self.length_plane.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) self.width_plane.setToolTip(QtGui.QApplication.translate("Form", "Width of the Plane.", None, QtGui.QApplication.UnicodeUTF8)) self.width_plane.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) - self.button_planeandpoint_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane crossing a Point and parallel to a Plane.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_planeandpoint_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, Plane)", None, QtGui.QApplication.UnicodeUTF8)) - self.extension_planePointPlane.setToolTip(QtGui.QApplication.translate("Form", "Distance for the extensions of the new Plane compared to initial one.", None, QtGui.QApplication.UnicodeUTF8)) - self.extension_planePointPlane.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) - self.button_planeandaxis_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a Plane crossing a Line and perpendicular to a Plane.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_planeandaxis_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Plane, Axis)", None, QtGui.QApplication.UnicodeUTF8)) - self.angle_planeandaxis_plane.setToolTip(QtGui.QApplication.translate("Form", "Angle relative to the Plane (in degrees).", None, QtGui.QApplication.UnicodeUTF8)) - self.angle_planeandaxis_plane.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_center_planes.setToolTip(QtGui.QApplication.translate("Form", "Create 3 Planes (XY, XZ and YZ) at center location of all selected Object(s).", None, QtGui.QApplication.UnicodeUTF8)) - self.button_object_center_planes.setText(QtGui.QApplication.translate("Form", "Object(s) Center Planes", None, QtGui.QApplication.UnicodeUTF8)) - self.button_axisandpoint_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane crossing a Line and a Point.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_axisandpoint_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, Axis)", None, QtGui.QApplication.UnicodeUTF8)) - self.button_axis_point_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a plane perpendicular to a Line and crossing a Point.", None, QtGui.QApplication.UnicodeUTF8)) - self.button_axis_point_plane.setText(QtGui.QApplication.translate("Form", "Plane=(Point, _|Axis)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_tangent.setToolTip(QtGui.QApplication.translate("Form", "Create a tanget Plane at click location of a Face.\n" +"Click first in the view to select and object,\n" +"then push the button, \n" +"then click on a location on the selected object.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_face_tangent.setText(QtGui.QApplication.translate("Form", "Face Tangent", None, QtGui.QApplication.UnicodeUTF8)) + self.length_plane_2.setToolTip(QtGui.QApplication.translate("Form", "Length of the Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.length_plane_2.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) + self.width_plane_2.setToolTip(QtGui.QApplication.translate("Form", "Width of the Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.width_plane_2.setText(QtGui.QApplication.translate("Form", "10.0", None, QtGui.QApplication.UnicodeUTF8)) self.button_threepoints_plane.setToolTip(QtGui.QApplication.translate("Form", "Create a Plane crossing 3 Points.", None, QtGui.QApplication.UnicodeUTF8)) self.button_threepoints_plane.setText(QtGui.QApplication.translate("Form", "Three Points Plane", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.Plane_Tab), QtGui.QApplication.translate("Form", "Plane", None, QtGui.QApplication.UnicodeUTF8)) @@ -605,8 +938,34 @@ class Ui_Form(object): "ReClick with same selection, will reverse the direction.", None, QtGui.QApplication.UnicodeUTF8)) self.button_alignview.setText(QtGui.QApplication.translate("Form", "Align to ...", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.View_Tab), QtGui.QApplication.translate("Form", "Views", None, QtGui.QApplication.UnicodeUTF8)) - self.button_origin.setToolTip(QtGui.QApplication.translate("Form", "Create at origin: a point and X,Y and Z axis and XZ,XY and YZ planes", None, QtGui.QApplication.UnicodeUTF8)) - self.button_origin.setText(QtGui.QApplication.translate("Form", "Origin", None, QtGui.QApplication.UnicodeUTF8)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.Origin_Tab), QtGui.QApplication.translate("Form", "Origin", None, QtGui.QApplication.UnicodeUTF8)) + self.label_angle.setText(QtGui.QApplication.translate("Form", "Angle", None, QtGui.QApplication.UnicodeUTF8)) + self.angle_cut_object.setToolTip(QtGui.QApplication.translate("Form", "Angle of cutting relative to the Reference Plane (in degrees).", None, QtGui.QApplication.UnicodeUTF8)) + self.angle_cut_object.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.label_thickness.setText(QtGui.QApplication.translate("Form", "Thickness", None, QtGui.QApplication.UnicodeUTF8)) + self.thickness_cut_object.setToolTip(QtGui.QApplication.translate("Form", "Thickness of the Cut.", None, QtGui.QApplication.UnicodeUTF8)) + self.thickness_cut_object.setText(QtGui.QApplication.translate("Form", "0.0", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_reset.setText(QtGui.QApplication.translate("Form", "Reset", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_apply.setToolTip(QtGui.QApplication.translate("Form", "Cut an object by selecting a Line cut, a Plane and an Angle regarding the Plane.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_apply.setText(QtGui.QApplication.translate("Form", "Apply", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_object.setToolTip(QtGui.QApplication.translate("Form", "Select the Object to cut:\n" +"First Click on the object in the view \n" +"and push this button to accept...", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_object.setText(QtGui.QApplication.translate("Form", "Select Object", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_line.setToolTip(QtGui.QApplication.translate("Form", "Select the Line to cut the Object along:\n" +"First Click on the line/edge in the view \n" +"and push this button to accept...", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_line.setText(QtGui.QApplication.translate("Form", "Select Cut Line", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_plane.setToolTip(QtGui.QApplication.translate("Form", "Select the reference Plane to cut the Object from:\n" +"First Click on the plane in the view \n" +"and push this button to accept...\n" +"(Note that the Angle is calculated from this Plane)", None, QtGui.QApplication.UnicodeUTF8)) + self.button_cut_select_plane.setText(QtGui.QApplication.translate("Form", "Select Ref. Plane", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_5), QtGui.QApplication.translate("Form", "Cutting", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.Modif_Tab), QtGui.QApplication.translate("Form", "Modif.", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget_0.setTabText(self.tabWidget_0.indexOf(self.tab_2), QtGui.QApplication.translate("Form", "W. F.", None, QtGui.QApplication.UnicodeUTF8)) + self.radioButton_verbose.setToolTip(QtGui.QApplication.translate("Form", "Toggle here if you want a lot of information printed into report View.", None, QtGui.QApplication.UnicodeUTF8)) + self.radioButton_verbose.setText(QtGui.QApplication.translate("Form", "Verbose", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget_0.setTabText(self.tabWidget_0.indexOf(self.tab_3), QtGui.QApplication.translate("Form", "Pref.", None, QtGui.QApplication.UnicodeUTF8)) + self.button_WF_quit.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.label_release.setText(QtGui.QApplication.translate("Form", "2015", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/WorkFeature/WFGui_2015_01_25.ui b/WorkFeature/WFGui_2015.ui old mode 100755 new mode 100644 similarity index 59% rename from WorkFeature/WFGui_2015_01_25.ui rename to WorkFeature/WFGui_2015.ui index ff0b7ef..f398812 --- a/WorkFeature/WFGui_2015_01_25.ui +++ b/WorkFeature/WFGui_2015.ui @@ -6,8 +6,8 @@ 0 0 - 368 - 635 + 376 + 742 @@ -27,12 +27,12 @@ 0 - 0 - 335 - 622 + -35 + 340 + 722 - + @@ -45,15 +45,63 @@ W. F. - + QTabWidget::West - 0 + 1 + + + + Icons/WF_Axes.svgIcons/WF_Axes.svg + + + Origin + + + + + + + + Create at origin: a point and X,Y and Z axis and XZ,XY and YZ planes + + + Origin + + + + Icons/WF_Axes.svgIcons/WF_Axes.svg + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + @@ -63,183 +111,55 @@ Point - - - - Create a projection Point of a Point onto a Face. - - - Point=(Point,Face) - - - - Icons/WF_pointFacePoint.svgIcons/WF_pointFacePoint.svg - - - - 32 - 32 - - - - - - - Create a Point at center location of all selected Object(s). - - - Object(s) Center - - - - Icons/WF_centerObjectsPoint.svgIcons/WF_centerObjectsPoint.svg - - - - 32 - 32 - - - - - - - - Create a Point at center location of each selected Circle(s) or Arc(s). - - - Circle(s) Center - - - - Icons/WF_centerCirclePoint.svgIcons/WF_centerCirclePoint.svg - - - - 32 - 32 - - - - - - - - Create Base Point of all selected Object(s). - - - Object(s) Base Point - - - - Icons/WF_objectBasePoint.svgIcons/WF_objectBasePoint.svg - - - - 32 - 32 - - - - - - - - Create a point at the intersection of the Line and Plane selected. - - - Point=(Line,Face) - - - - Icons/WF_lineFacePoint.svgIcons/WF_lineFacePoint.svg - - - - 32 - 32 - - - - - - - - Create a Point on a Plane perpendicular to the view at location of one mouse click. -Click first on the Button then click once on the View (with no object in background). -Click first on the Button then click once on the View (with an object in background) will attach the point to the surface of the object. - - - - Click - - - - ../Icons/WF_clickPoint.svg../Icons/WF_clickPoint.svg - - - - 32 - 32 - - - - false - - + + + + + Create a Point at center location of all selected Object(s). + if BBox is not toggled + This point is the MEAN location of all center of Mass (if exist) of all objects. + All center of Mass will be created too. + if BBox is toggled + This point is the center of the Global X,Y,Z bounding box of all objects. + This bounding box alway exists (especially for draft objects). + Be aware this point is not necessary the center of Mass of all Objects! + + + Object(s) Center + + + + Icons/WF_centerObjectsPoint.svgIcons/WF_centerObjectsPoint.svg + + + + 32 + 32 + + + + + + + + BBox + + + + - + - Create a Point at mid point location of each selected Line(s). + Create a Point at mean location of all selected points. - Line(s) Center + Points Center - Icons/WF_centerLinePoint.svgIcons/WF_centerLinePoint.svg - - - - 32 - 32 - - - - - - - - Create a projection Point of a Point onto a Line and symetric point. - - - Point=(Line,Point) - - - - Icons/WF_pointLinePoint.svgIcons/WF_pointLinePoint.svg - - - - 32 - 32 - - - - - - - - Create a Point at center location of each selected Face(s). - - - Face(s) Center - - - - Icons/WF_centerFacePoint.svgIcons/WF_centerFacePoint.svg + Icons/WF_NpointsPoint.svgIcons/WF_NpointsPoint.svg @@ -250,6 +170,60 @@ Click first on the Button then click once on the View (with an object in backgro + + + + + Create Point(s): +Cut each selected Lines(s) in 2 (n) parts and create a (n-1) Point(s) at ends of edge(s). +The number indicates how many parts to consider. + + + Line(s) Center + + + + Icons/WF_centerLinePoint.svgIcons/WF_centerLinePoint.svg + + + + 32 + 32 + + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + The number indicates in how many parts each selected Lines(s) will be cut. + + + 2 + + + 10 + + + 1 + + + + + + Create Points at start and end location of each selected Line(s). @@ -270,6 +244,26 @@ Click first on the Button then click once on the View (with an object in backgro + + + Create a Point at center location of each selected Circle(s) or Arc(s). + + + Circle(s) Center + + + + Icons/WF_centerCirclePoint.svgIcons/WF_centerCirclePoint.svg + + + + 32 + 32 + + + + + QLayout::SetFixedSize @@ -283,7 +277,8 @@ Click first on the Button then click once on the View (with an object in backgro - Create a Point on a line at some distance of the extremity point selected. + Create a Point at a certain distance along the line +respecting to the choosen reference starting point. Point along Line @@ -330,7 +325,154 @@ Click first on the Button then click once on the View (with an object in backgro + + + + Create a Point at center location of each selected Face(s). + + + Face(s) Center + + + + Icons/WF_centerFacePoint.svgIcons/WF_centerFacePoint.svg + + + + 32 + 32 + + + + + + + + Create a point at the intersection of the Line and Plane selected. + + + Point=(Line,Face) + + + + Icons/WF_lineFacePoint.svgIcons/WF_lineFacePoint.svg + + + + 32 + 32 + + + + + + + + Create a projection Point of a Point onto a Line and symetric point. + + + Point=(Line,Point) + + + + Icons/WF_pointLinePoint.svgIcons/WF_pointLinePoint.svg + + + + 32 + 32 + + + + + + + + Create a projection Point of a Point onto a Face. + + + Point=(Point,Face) + + + + Icons/WF_pointFacePoint.svgIcons/WF_pointFacePoint.svg + + + + 32 + 32 + + + + + + + + Plot one or two Point(s) at minimum distance of two Lines +Create a Point at intersection of 2 crossing Lines. + + + Point=(Line,Line) + + + + Icons/WF_lineLinePoint.svgIcons/WF_lineLinePoint.svg + + + + 32 + 32 + + + + + + + Create a Point on a Plane perpendicular to the view at location of one mouse click. +Click first on the Button then click once on the View (with no object in background). +Click first on the Button then click once on the View (with an object in background) will attach the point to the surface of the object. + + + + Click + + + + ../Icons/WF_clickPoint.svg../Icons/WF_clickPoint.svg + + + + 32 + 32 + + + + false + + + + + + + Create Base Point of all selected Object(s). + + + Object(s) Base Point + + + + Icons/WF_objectBasePoint.svgIcons/WF_objectBasePoint.svg + + + + 32 + 32 + + + + + Qt::Vertical @@ -344,6 +486,19 @@ Click first on the Button then click once on the View (with an object in backgro + button_object_center + button_line_extrema + button_circle_center + button_face_center + button_line_face_point + button_point_line_point + button_point_face_point + button_twolines_point + button_click_for_point + button_object_base_point + button_Npoints_center + verticalSpacer_2 + checkBox_object_center @@ -354,25 +509,51 @@ Click first on the Button then click once on the View (with an object in backgro Axis - - - - Create 3 Axes at center location of all selected Object(s). - - - Object(s) X, Y, Z Axes - - - - Icons/WF_centerObjectsAxes.svgIcons/WF_centerObjectsAxes.svg - - - - 32 - 32 - - - + + + + + + + 0 + 0 + + + + Create an Axis crossing 2 Points. + + + Two Points Axis + + + + Icons/WF_2pointsLine.svgIcons/WF_2pointsLine.svg + + + + 32 + 32 + + + + + + + + + 60 + 16777215 + + + + Distance for the extensions on extrema + + + 0.0 + + + + @@ -394,17 +575,17 @@ Click first on the Button then click once on the View (with an object in backgro - - + + - Create an Axis on a Plane by projection from anoher Axis. + Create 3 Axes at Base location of all selected Object(s). - Axis=(Plane,Axis) + Object(s) Base Axes - Icons/WF_linePlaneAxis.svgIcons/WF_linePlaneAxis.svg + Icons/WF_baseObjectsAxes.svgIcons/WF_baseObjectsAxes.svg @@ -414,19 +595,45 @@ Click first on the Button then click once on the View (with an object in backgro - - + + + + Create an Axis parallel to an Axis and crossing a Point. + + + Axis=(Point,Axis) + + + + Icons/WF_pointLineAxis.svgIcons/WF_pointLineAxis.svg + + + + 32 + 32 + + + + + + - + + + + 0 + 0 + + - Create an Axis crossing 2 Points. + Create an Axis perpendicular to an Axis and crossing a Point. - Two Points Axis + Axis=(Axis,Point) - Icons/WF_2pointsLine.svgIcons/WF_2pointsLine.svg + Icons/WF_linePointAxis.svgIcons/WF_linePointAxis.svg @@ -437,9 +644,15 @@ Click first on the Button then click once on the View (with an object in backgro - + + + + 60 + 16777215 + + - Distance for the extensions on extrema + Distance for the extensions on extrema. 0.0 @@ -448,8 +661,106 @@ Click first on the Button then click once on the View (with an object in backgro - - + + + + 5 + + + + + + 0 + 0 + + + + Create a normal Axis at click location of a Face. +Click first in the view to select and object, +then push the button, +then click on a location on the selected object. + + + Face Normal + + + + Icons/WF_FaceNormal.svgIcons/WF_FaceNormal.svg + + + + 32 + 32 + + + + + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Length of Normal Axis. + + + 10.0 + + + + + + + + + Create an Axis between 2 Axes. + + + Axis=(Line,Line) + + + + Icons/WF_twoLinesAxis.svgIcons/WF_twoLinesAxis.svg + + + + 32 + 32 + + + + + + + + Create 3 Axes at center location of all selected Object(s). + + + Object(s) X, Y, Z Axes + + + + Icons/WF_centerObjectsAxes.svgIcons/WF_centerObjectsAxes.svg + + + + 32 + 32 + + + + + + Create an Axis by intersect of 2 Planes. @@ -488,17 +799,81 @@ Click first on the Button then click once on the View (with an object in backgro + + + + Create an Axis on a Plane by projection from anoher Axis. + + + Axis=(Plane,Axis) + + + + Icons/WF_linePlaneAxis.svgIcons/WF_linePlaneAxis.svg + + + + 32 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + ../Icons/WF_circle.svg../Icons/WF_circle.svg + + + Circle + + + + + + Select 3 Points to create a Circle. + + + Circle=(3 points) + + + + ../Icons/WF_3pointsCircle.svg../Icons/WF_3pointsCircle.svg + + + + 32 + 32 + + + + - + - Create an Axis between 2 Axes. + Select a center and 2 Points to create an Ellipse. - Axis=(Line,Line) + Ellipse=(3 points) - Icons/WF_twoLinesAxis.svgIcons/WF_twoLinesAxis.svg + ../Icons/WF_3pointsEllipse.svg../Icons/WF_3pointsEllipse.svg @@ -508,17 +883,18 @@ Click first on the Button then click once on the View (with an object in backgro - - + + - Create an Axis parallel to an Axis and crossing a Point. + Select an Axis and a Point to create a Circle +centered on the Axis and tangenting the Point. - Axis=(Point,Axis) + Circle=(Axis, point) - Icons/WF_pointLineAxis.svgIcons/WF_pointLineAxis.svg + ../Icons/WF_linePointCircle.svg../Icons/WF_linePointCircle.svg @@ -528,19 +904,21 @@ Click first on the Button then click once on the View (with an object in backgro - - + + - + - Create an Axis perpendicular to an Axis and crossing a Point. + Select an Axis and a Point to create a Circle +centered on the Point, perpendicular to the Axis +with the given radius. - Axis=(Axis,Point) + Circle=(Axis, center) - Icons/WF_linePointAxis.svgIcons/WF_linePointAxis.svg + ../Icons/WF_lineCenterCircle.svg../Icons/WF_lineCenterCircle.svg @@ -551,39 +929,31 @@ Click first on the Button then click once on the View (with an object in backgro - + + + + 40 + 0 + + + + + 60 + 16777215 + + - Distance for the extensions on extrema. + Radius of the Circle. - 0.0 + 10.0 - - - - Create 3 Axes at Base location of all selected Object(s). - - - Object(s) Base Axes - - - - Icons/WF_baseObjectsAxes.svgIcons/WF_baseObjectsAxes.svg - - - - 32 - 32 - - - - - - + + Qt::Vertical @@ -606,7 +976,184 @@ Click first on the Button then click once on the View (with an object in backgro Plane + + + + + + Create a plane crossing a Point and parallel to a Plane. + + + Plane=(Point, Plane) + + + + Icons/WF_pointPlanePoint.svgIcons/WF_pointPlanePoint.svg + + + + 32 + 32 + + + + + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Distance for the extensions of the new Plane compared to initial one. + + + 0.0 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Create a plane perpendicular to a Line and crossing a Point. + + + Plane=(Point, _|Axis) + + + + Icons/WF_linePointPlane2.svgIcons/WF_linePointPlane2.svg + + + + 32 + 32 + + + + + + + + Create 3 Planes (XY, XZ and YZ) at center location of all selected Object(s). + + + Object(s) Center Planes + + + + Icons/WF_centerObjectsPlanes.svgIcons/WF_centerObjectsPlanes.svg + + + + 32 + 32 + + + + + + + + + + + 0 + 0 + + + + Create a Plane crossing a Line and perpendicular to a Plane. + + + Plane=(Plane, Axis) + + + + Icons/WF_planeLinePlane.svgIcons/WF_planeLinePlane.svg + + + + 32 + 32 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Angle relative to the Plane (in degrees). + + + 0.0 + + + + + + + + + Create a plane crossing a Line and a Point. + + + Plane=(Point, Axis) + + + + Icons/WF_linePointPlane.svgIcons/WF_linePointPlane.svg + + + + 32 + 32 + + + + + @@ -696,182 +1243,94 @@ But you can also select an already existing point first and click the button to - - - - - - Create a plane crossing a Point and parallel to a Plane. - - - Plane=(Point, Plane) - - - - Icons/WF_pointPlanePoint.svgIcons/WF_pointPlanePoint.svg - - - - 32 - 32 - - - - - - - - - 40 - 0 - - - - - 60 - 16777215 - - - - Distance for the extensions of the new Plane compared to initial one. - - - 0.0 - - - - - - - - - - - - 0 - 0 - - - - Create a Plane crossing a Line and perpendicular to a Plane. - - - Plane=(Plane, Axis) - - - - Icons/WF_planeLinePlane.svgIcons/WF_planeLinePlane.svg - - - - 32 - 32 - - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - - 60 - 16777215 - - - - Angle relative to the Plane (in degrees). - - - 0.0 - - - - - - - - - Create 3 Planes (XY, XZ and YZ) at center location of all selected Object(s). - - - Object(s) Center Planes - - - - Icons/WF_centerObjectsPlanes.svgIcons/WF_centerObjectsPlanes.svg - - - - 32 - 32 - - - - - - - - Create a plane crossing a Line and a Point. - - - Plane=(Point, Axis) - - - - Icons/WF_linePointPlane.svgIcons/WF_linePointPlane.svg - - - - 32 - 32 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Create a plane perpendicular to a Line and crossing a Point. - - - Plane=(Point, _|Axis) - - - - Icons/WF_linePointPlane2.svgIcons/WF_linePointPlane2.svg - - - - 32 - 32 - - - + + + + + + 0 + 0 + + + + Create a tanget Plane at click location of a Face. +Click first in the view to select and object, +then push the button, +then click on a location on the selected object. + + + Face Tangent + + + + ../Icons/WF_FaceTangent.svg../Icons/WF_FaceTangent.svg + + + + 32 + 32 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Length of the Plane. + + + 10.0 + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Width of the Plane. + + + 10.0 + + + + @@ -893,7 +1352,7 @@ But you can also select an already existing point first and click the button to - + Qt::Vertical @@ -1218,51 +1677,317 @@ ReClick with same selection, will reverse the direction. - - - - Icons/WF_Axes.svgIcons/WF_Axes.svg - + - Origin + Modif. - + - - - - - Create at origin: a point and X,Y and Z axis and XZ,XY and YZ planes - - - Origin - - - - Icons/WF_Axes.svgIcons/WF_Axes.svg - - - - 32 - 32 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + 0 + + + + Cutting + + + + + + + + + + + 70 + 16777215 + + + + Angle + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Angle of cutting relative to the Reference Plane (in degrees). + + + 0.0 + + + + + + + + + + + + 70 + 16777215 + + + + Thickness + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Thickness of the Cut. + + + 0.0 + + + + + + + + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + Reset + + + + + + + Qt::Horizontal + + + + 18 + 20 + + + + + + + + false + + + + 50 + 16777215 + + + + Cut an object by selecting a Line cut, a Plane and an Angle regarding the Plane. + + + Apply + + + + 32 + 32 + + + + + + + + + + + + + + + 130 + 31 + + + + + 250 + 40 + + + + Select the Object to cut: +First Click on the object in the view +and push this button to accept... + + + Select Object + + + + + + + false + + + + 0 + 0 + + + + true + + + + + + + false + + + + 130 + 31 + + + + + 250 + 40 + + + + Select the Line to cut the Object along: +First Click on the line/edge in the view +and push this button to accept... + + + Select Cut Line + + + + + + + false + + + + 0 + 0 + + + + true + + + + + + + false + + + + 130 + 31 + + + + + 250 + 40 + + + + Select the reference Plane to cut the Object from: +First Click on the plane in the view +and push this button to accept... +(Note that the Angle is calculated from this Plane) + + + Select Ref. Plane + + + + + + + false + + + + 0 + 0 + + + + true + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + @@ -1270,12 +1995,73 @@ ReClick with same selection, will reverse the direction. + + + Pref. + + + + + + Toggle here if you want a lot of information printed into report View. + + + Verbose + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 2015 + + + + + diff --git a/WorkFeature/__init__.py b/WorkFeature/__init__.py index de2293c..71eb118 100644 --- a/WorkFeature/__init__.py +++ b/WorkFeature/__init__.py @@ -6,18 +6,22 @@ * Javier Martinez Garcia 2014 * * Gui ideas from by Jonathan Wiedemann 2014 * * Jonathan Wiedemann for view codes * -* Special thanks to Mario52 * -* for bounding box codes, advices, diverse pieces of codes * -* and all discussions * +* galou_breizh for macro which creates a circle from 3 selected points * +* Eriossoltero for macro Ellipse-Center+2Points * +* Many Thanks to wmayer for his active help on testing and debbuging * +* Special thanks to Mario52 for FCCamera code * +* for bounding box codes, advices, diverse pieces of codes * +* and all discussions...merci Mario * *************************************************************************** *************************************************************************** * FreeCAD Work Features / version 2015-01 * * Copyright (c) 2014, 2015 * * Code rewrite by * * Copyright (c) 2014 Javier Martinez Garcia * -* Copyright (c) 2014 Jonathan Wiedemann * +* Copyright (c) 2013, 2014 Jonathan Wiedemann * * Copyright (c) 2014, 2015 Mario52 * -* Copyright (c) 2013 Jonathan Wiedemann * +* Copyright (c) 2013 galou_breizh * +* Copyright (c) Eriossoltero * * * * This file is a supplement to the FreeCAD CAx development system. * * * @@ -41,20 +45,22 @@ # First two lines to be able to launch with python import sys # change this by your own FreeCAD lib path import FreeCAD -if not sys.path.__contains__("/usr/lib/freecad/lib"): - sys.path.append("/usr/lib/freecad/lib") - -import WFGui_2015_01_25 as WFGui +if not sys.path.__contains__("/usr/lib/freecad/lib"): + sys.path.append("/usr/lib/freecad/lib") + +import WFGui_2015 as WFGui +global myRelease +myRelease = "2105_02_17" import os.path import math - + import FreeCAD as App import FreeCADGui as Gui from pivy.coin import * import Part import Draft -from FreeCAD import Base +from FreeCAD import Base from PySide import QtCore, QtGui @@ -62,8 +68,8 @@ from PySide import QtCore, QtGui # assume the Icons directory in the same directory as this MACRO file ICONS_PATH = os.path.dirname(__file__) + "/Icons" -# use "icons" as prefix which we used in the .ui file -QtCore.QDir.setSearchPaths("icons", [ICONS_PATH]) +# use "icons" as prefix which we used in the .ui file +QtCore.QDir.setSearchPaths("icons", [ICONS_PATH]) # LineColor red = 1.0 # 1 = 255 @@ -76,28 +82,38 @@ global myDialog myDialog = None global myObject myObject = None +global centerOfMass +centerOfMass=True +global verbose +verbose=0 + +m_numberLinePart = 2 m_distanceLinePoint = 0.0 m_extensionTwoPointsAxis = 0.0 m_extensionLinePointAxis = 0.0 +m_radiusCircle = 10.0 +m_extensionFaceNormal = 10.0 m_extensionPlanePointPlane = 0.0 m_anglePlaneAxisPlane = 0.0 m_lengthPlane = 10.0 m_diameterCylinder = 2.0 -m_lengthCylinder = 20.0 +m_lengthCylinder = 20.0 m_lengthCube = 2.0 m_widthCube = 2.0 -m_heightCube = 20.0 +m_heightCube = 20.0 m_widthPlane = 10.0 + +m_cut_selectObjects = [] m_angleCutObject = 0.0 -m_thicknessCutObject = 1.0 +m_thicknessCutObject = 0.0 m_callback = None m_stack = [] error_msg = "Not yet Developped !" - + #################################################################################### - + #Create a simple QMessageBox dialog for error messages. def gui_errorDialog(msg): """ Create a simple QMessageBox dialog for error messages. @@ -111,7 +127,7 @@ def gui_errorDialog(msg): diag.exec_() -#Print a message on console. +#Print a message on console. def print_msg(message): """ Print a message on console. """ @@ -119,7 +135,7 @@ def print_msg(message): App.Console.PrintMessage( message + "\n") -#Print a ERROR message on console. +#Print a ERROR message on console. def printError_msg(message): """ Print a ERROR message on console. """ @@ -157,26 +173,33 @@ def print_segment(segment, msg=""): point2 = segment[1] if point1.__class__.__name__ != "Vector": print_msg("Not a Vector to print !") - return + return if point2.__class__.__name__ != "Vector": print_msg("Not a Vector to print !") - return + return print_msg(str(msg) + "x1 =" + str(point1.x) + ", " "y1 =" + str(point1.y) + ", " - "z1 =" + str(point1.z) + ", " + "z1 =" + str(point1.z) + ", " "x2 =" + str(point2.x) + ", " "y2 =" + str(point2.y) + ", " "z2 =" + str(point2.z)) return +def verbose_toggled(flag): + """ Respond to the change of verbose flag. + """ + global verbose + verbose=0 + if flag == True: + verbose=1 def init_min_max(): """ Return min and max values from System. min_val, max_val = init_min_max """ import sys - if sys.version < '3.0.0': + if sys.version < '3.0.0': max_val = sys.maxint min_val = -sys.maxint - 1 else:# for python 3.0 use sys.maxsize @@ -194,24 +217,24 @@ def alignCamera(sub0,sub1,reverse=False,info=0): else: v=sub1.sub(sub0) if info != 0: - print_msg("Vectors difference is :" + str(v)) + print_msg("Vectors difference is :" + str(v)) r=App.Rotation(App.Vector(0,0,1),v) if info != 0: print_msg("App.Rotation :" + str(r)) # App.Rotation.Q : the rotation element as Quaternion Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q) - - + + def createFolders(folder=None): """ Create WorkFeatures folders if needed. """ - if not(App.ActiveDocument.getObject("WorkFeatures")): + if not(App.ActiveDocument.getObject("WorkFeatures")): try: - App.ActiveDocument.addObject("App::DocumentObjectGroup","WorkFeatures") + App.ActiveDocument.addObject("App::DocumentObjectGroup","WorkFeatures") except: printError_msg("Could not Create 'WorkFeatures' Objects Group!") - m_list_dirs = ['Origin','WorkPoints','WorkAxis','WorkPlanes','WorkBoxes','WorkObjects'] - for m_dir in m_list_dirs: + m_list_dirs = ['Origin','WorkPoints','WorkAxis','WorkPlanes','WorkCircles','WorkBoxes','WorkObjects'] + for m_dir in m_list_dirs: if folder == m_dir: if not(App.ActiveDocument.getObject(str(m_dir))): try: @@ -230,10 +253,10 @@ def get_ActiveDocument(info=0): return None if info != 0: message = "Active Document is : " + str(m_actDoc.Name) - print_msg(message) + print_msg(message) return m_actDoc - + def get_ActiveView(info=0): """ Return the active View of active Document """ @@ -243,11 +266,11 @@ def get_ActiveView(info=0): return None if info != 0: message = "Active View is : " + str(m_actView) - print_msg(message) + print_msg(message) return m_actView - - -def get_InfoObjects(info=0): + + +def get_InfoObjects(info=0, printError=True): """ Return info on objects selected: num, selEx, objs, objNames num : number of objects @@ -257,7 +280,8 @@ def get_InfoObjects(info=0): """ m_actDoc=get_ActiveDocument() if m_actDoc == None: - printError_msg("No active document !") + if printError: + printError_msg("No active document !") return 0, 0, 0, 0 # Return a list of Selected Objects for a given document name. m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) @@ -265,7 +289,8 @@ def get_InfoObjects(info=0): m_objNames = [selobj.ObjectName for selobj in m_selEx] m_num = len(m_objs) if m_num < 1: - printError_msg("Select at least one object !") + if printError: + printError_msg("Select at least one object !") return 0, 0, 0, 0 if info != 0: print_msg("m_num=" + str(m_num) + @@ -274,27 +299,27 @@ def get_InfoObjects(info=0): ", m_objNames=" + str(m_objNames)) return m_num, m_selEx, m_objs, m_objNames - -def get_SelectedObjects(info=0): + +def get_SelectedObjects(info=0, printError=True): """ Return selected objects as - Selection = (Number_of_Points, Number_of_Edges, Number_of_Planes, + Selection = (Number_of_Points, Number_of_Edges, Number_of_Planes, Selected_Points, Selected_Edges, Selected_Planes) """ m_actDoc=get_ActiveDocument(info=1) - - if m_actDoc.Name: + + if m_actDoc.Name: # Return a list of SelectionObjects for a given document name. # "getSelectionEx" Used for selecting subobjects m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) m_objs = [selobj.Object for selobj in m_selEx] m_objNames = [selobj.ObjectName for selobj in m_selEx] - m_num = len(m_objs) + m_num = len(m_objs) m_num = len(m_selEx) - if m_num >= 1: + if m_num >= 1: Selected_Points = [] Selected_Edges = [] Selected_Planes = [] - for m_i in range(m_num): + for m_i in range(m_num): Sel_i_Object = m_selEx[m_i] SubObjects_Inside = Sel_i_Object.SubObjects for n in range(len(SubObjects_Inside)): @@ -305,7 +330,7 @@ def get_SelectedObjects(info=0): if SubObject.ShapeType == "Vertex": Selected_Points.append(SubObject) if SubObject.ShapeType == "Edge": - Selected_Edges.append(SubObject) + Selected_Edges.append(SubObject) if SubObject.ShapeType == "Face": Selected_Planes.append(SubObject) Number_of_Points = len(Selected_Points) @@ -318,43 +343,43 @@ def get_SelectedObjects(info=0): "Selected_Points, Selected_Edges, Selected_Planes = " + str(Selection)) return Selection else: - printError_msg("Select at least one object !") + if printError: + printError_msg("Select at least one object !") return None else: printError_msg("No active document !") - return + return def definePropOfActiveObj(): Gui.activeDocument().activeObject().LineColor = (red, green, blue) Gui.activeDocument().activeObject().ShapeColor = (0.33,1.00,1.00) Gui.activeDocument().activeObject().Transparency = (50) - - + + def addObjectToGrp(obj,grp,info=0): m_obj = obj m_grp = grp m_grp.addObject(m_obj) # adds object to the group if info != 0: print_msg("Object " + str(m_obj) + " added to Group : " + str(m_grp)) - + def addObjectToGrp2(obj,grp,info=0): m_obj = obj m_grp = grp m_grp.addObject(m_obj) # adds object to the group m_wire,m_del=Draft.downgrade(m_obj ,delete=True) m_num = len(m_wire) - for m_i in range(m_num): + for m_i in range(m_num): m_grp.addObject(m_wire[m_i]) # adds object to the group m_face,m_del1=Draft.upgrade(m_wire[m_i] ,delete=True) m_num = len(m_face) for m_i in range(m_num): m_grp.addObject(m_face[m_i]) # adds object to the group - - - + + def minMaxVectorsLimits(vertx,info=0): - """ Return the min and max limits along the 3 Axis for all selected objects + """ Return the min and max limits along the 3 Axis for all selected objects. """ xmax = xmin = ymax = ymin = zmax = zmin = 0 if vertx == None: @@ -366,7 +391,7 @@ def minMaxVectorsLimits(vertx,info=0): print_msg("ERROR : len(m_vertx) <1 , leaving minMaxVectorsLimits()") return xmax, xmin, ymax, ymin, zmax, zmin - min_val, max_val = init_min_max() + min_val, max_val = init_min_max() xmin = ymin = zmin = max_val xmax = ymax = zmax = min_val #print_msg(str(xmin)) @@ -381,49 +406,56 @@ def minMaxVectorsLimits(vertx,info=0): zmax = max(zmax, m_vert.z) zmin = min(zmin, m_vert.z) if info != 0: - print_msg("Limits of all objects selected are :") + print_msg("Limits along the 3 Axis of all vectors selected are :") print_msg("xmax =" + str(xmax) + ", " "xmin =" + str(xmin) + ", " "ymax =" + str(ymax) + ", " "ymin =" + str(ymin) + ", " "zmax =" + str(zmax) + ", " - "zmin =" + str(zmin)) + "zmin =" + str(zmin)) return xmax, xmin, ymax, ymin, zmax, zmin +def meanObjects(objs,info=0): + """ Return the mean of centers of mass of all selected objects. + """ + mean = App.Vector(0.0,0.0,0.0) + + return mean + def minMaxObjectsLimits(objs,info=0): - """ Return the min and max limits along the 3 Axis for all selected objects + """ Return the min and max limits along the 3 Axis for all selected objects. """ xmax = xmin = ymax = ymin = zmax = zmin = 0 if objs == None: print_msg("ERROR : objs=None, leaving minMaxObjectsLimits()") return xmax, xmin, ymax, ymin, zmax, zmin - + m_objs = objs m_num = len(m_objs) if m_num < 1: - print_msg("ERROR : len(m_vertx) <1 , leaving minMaxObjectsLimits()") + print_msg("ERROR : len(m_objs) <1 , leaving minMaxObjectsLimits()") return xmax, xmin, ymax, ymin, zmax, zmin import sys - if sys.version < '3.0.0': + if sys.version < '3.0.0': max_val = sys.maxint min_val = -sys.maxint - 1 else:# for python 3.0 use sys.maxsize max_val = sys.maxsize - min_val = -sys.maxsize - 1 + min_val = -sys.maxsize - 1 xmin = ymin = zmin = max_val - xmax = ymax = zmax = min_val + xmax = ymax = zmax = min_val #print_msg(str(xmin)) #print_msg(str(xmax)) m_doc=get_ActiveDocument() - + for m_obj in m_objs: if hasattr(m_obj, 'TypeId'): m_type = m_obj.TypeId else: m_type = m_obj.Type - #pm_type = m_obj.TypeId + #pm_type = m_obj.TypeId if info != 0: print_msg("m_obj : " + str(m_obj)) #print_msg("m_obj.Type : " + str(m_obj.Type)) @@ -454,7 +486,7 @@ def minMaxObjectsLimits(objs,info=0): elif m_type[:6] == "Sketch": if info != 0: print_msg("Found a Sketch object!") - #box = Draft.draftify(m_obj,delete=False).Shape.BoundBox + #box = Draft.draftify(m_obj,delete=False).Shape.BoundBox m_wire = Draft.draftify(m_obj,delete=False) if info != 0: print_msg("m_wire = " + str(m_wire)) @@ -468,10 +500,10 @@ def minMaxObjectsLimits(objs,info=0): ymax = max(ymax, box.YMax) ymin = min(ymin, box.YMin) zmax = max(zmax, box.ZMax) - zmin = min(zmin, box.ZMin) + zmin = min(zmin, box.ZMin) App.getDocument(str(m_doc.Name)).removeObject(str(m_sub_wire.Label)) - else: - box = m_wire.Shape.BoundBox + else: + box = m_wire.Shape.BoundBox App.getDocument(str(m_doc.Name)).removeObject(str(m_wire.Label)) else: continue @@ -484,13 +516,13 @@ def minMaxObjectsLimits(objs,info=0): zmax = max(zmax, box.ZMax) zmin = min(zmin, box.ZMin) if info != 0: - print_msg("Limits of all objects selected are :") + print_msg("Limits of all objects selected are :") print_msg("xmax =" + str(xmax) + ", " "xmin =" + str(xmin) + ", " "ymax =" + str(ymax) + ", " "ymin =" + str(ymin) + ", " "zmax =" + str(zmax) + ", " - "zmin =" + str(zmin)) + "zmin =" + str(zmin)) return xmax, xmin, ymax, ymin, zmax, zmin @@ -502,34 +534,78 @@ def baseObjectPoint(obj,info=0): base = placement.Base #rotation = placement.Rotation if info != 0: - print_point(base,"Base of object selected is :") + print_point(base,"Base of object selected is :") return base - -def centerVectorsPoint(vertx,info=0): - """ Return the center point of all selected Vectors. +def meanVectorsPoint(vertx,info=0): + """ Return the mean point of all selected Vectors. + """ + mean = App.Vector(0.0,0.0,0.0) + m_vertx = vertx + m_num = len(m_vertx) + if info != 0: + print_msg("m_vertx = " + str(m_vertx)) + print_msg("m_num = " + str(m_num)) + if m_num < 1: + print_msg("ERROR : len(m_vertx) <1 , meanVectorsPoint()") + return mean + m_list = [] + for m_vert in m_vertx: + m_list.append(m_vert.x) + m_list.append(m_vert.y) + m_list.append(m_vert.z) + + import numpy + V=numpy.array(m_list) + Vre = V.reshape(m_num,3) + C=sum(Vre,0)/m_num + + if info != 0: + print_msg("V = " + str(V)) + print_msg("Vre = " + str(Vre)) + print_msg("C = " + str(C)) + + mean = App.Vector(C[0], C[1] , C[2]) + if info != 0: + print_point(mean,"Mean of all vectors selected is : ") + return mean + +def centerBBVectorsPoint(vertx,info=0): + """ Return the center point of the bounding box of all selected Vectors. """ center = None xmax, xmin, ymax, ymin, zmax, zmin = minMaxVectorsLimits(vertx,info=info) - + center = App.Vector((xmax+xmin)/2.0, (ymax+ymin)/2.0, (zmax+zmin)/2.0) - + if info != 0: print_point(center,"Center of all vectors selected is : ") return center - + def centerObjectsPoint(objs,info=0): """ Return the center point of all selected Objects. """ center = None - xmax, xmin, ymax, ymin, zmax, zmin = minMaxObjectsLimits(objs,info=info) + xmax, xmin, ymax, ymin, zmax, zmin = minMaxObjectsLimits(objs,info=info) center = App.Vector((xmax+xmin)/2.0, (ymax+ymin)/2.0, (zmax+zmin)/2.0) if info != 0: print_point(center,"Center of all objects selected is : ") return center + +def centerLinePoints(edge, index, number,info=0): + """ Return the point at index/number of the Line. + """ + Vector_A = None + distance = edge.Length / 2 + if number != 0: + distance = index * (edge.Length / number) + Vector_A = edge.valueAt( distance ) + if info != 0: + print_point(Vector_A,"Point of line selected is : ") + return Vector_A - + def centerLinePoint(edge,info=0): """ Return the center point of the Line. """ @@ -539,7 +615,7 @@ def centerLinePoint(edge,info=0): Vector_MidPoint = Vector_B + Vector_A center = Vector_MidPoint.multiply(0.5) if info != 0: - print_point(center,"Center of line selected is : ") + print_point(center,"Center of line selected is : ") return center @@ -549,7 +625,7 @@ def centerCirclePoint(edge,info=0): center = None center = edge.centerOfCurvatureAt( 0.0 ) if info != 0: - print_point(center,"Center of circle selected is :") + print_point(center,"Center of circle selected is :") return center @@ -559,9 +635,9 @@ def distanceBetween(A, B): line = Part.Line(A,B) edge = line.toShape() return edge.Length + - -def colinearVectors(A, B, C, info=0): +def colinearVectors(A, B, C, info=0, precision=1e-12): """ Return true if the 3 points are aligned. """ Vector_1 = B - A @@ -572,8 +648,8 @@ def colinearVectors(A, B, C, info=0): Vector_3 = Vector_1.cross(Vector_2) if info != 0: print_point(Vector_3, msg="Vector_1.cross(Vector_2) : ") - - if abs(Vector_3.x) <= 1e-12 and abs(Vector_3.y) <= 1e-12 and abs(Vector_3.z) <= 1e-12: + + if abs(Vector_3.x) <= precision and abs(Vector_3.y) <= precision and abs(Vector_3.z) <= precision: if info != 0: print_msg("Colinear Vectors !") return True @@ -581,7 +657,7 @@ def colinearVectors(A, B, C, info=0): if info != 0: print_msg("NOT Colinear Vectors !") return False - return + return def intersecPoints(shape1, shape2, info=0): @@ -590,10 +666,10 @@ def intersecPoints(shape1, shape2, info=0): or None """ #s1 = shape1.Shape - #s2 = shape2.Shape + #s2 = shape2.Shape s1 = shape1 s2 = shape2 - cs = s1.common(s2) + cs = s1.common(s2) sec = s1.section(s2) if info != 0: print_msg("s1 = " + str(s1)) @@ -616,7 +692,7 @@ def intersecPoints(shape1, shape2, info=0): error_msg = "Can't find any intersection point !" printError_msg(error_msg) return None - return + return def getClickedPoint2(info): view = Gui.ActiveDocument.ActiveView @@ -635,10 +711,94 @@ def getClickedPoint2(info): name = "Point" part = "Part::Feature" plot_point(m_stack[-1], part, name) + print_point(m_stack[-1],"Click point at :") view.removeEventCallback("SoMouseButtonEvent",m_callback) del m_stack[:] - + +def getClickedNormal(info): + msg=0 + view = Gui.ActiveDocument.ActiveView + down = (info["State"] == "DOWN") + pos = info["Position"] + if msg != 0: + print_msg("info['Position'] : " + str(pos)) + global m_stack + global m_callback + global m_extensionFaceNorma + part = "Part::Feature" + if (down): + point = view.getPoint(pos[0],pos[1]) + obj = view.getObjectInfo(pos) + if msg != 0: + print_msg("view.getPoint(pos[0],pos[1] : " + str(point)) + print_msg("view.getObjectInfo(pos) : " + str(obj)) + if obj == None: + printError_msg("No Object selected !") + view.removeEventCallback("SoMouseButtonEvent",m_callback) + return None + else: + m_sel = Gui.Selection.getSelection()[0] + m_face = m_sel.Shape.Faces[0] + m_surf = m_face.Surface + m_p = App.Vector(obj["x"],obj["y"],obj["z"]) + m_uv = m_surf.parameter(m_p) + u,v = m_uv[0], m_uv[1] + m_p1 = m_face.valueAt(u,v) + m_p2 = m_face.normalAt(u,v) + m_p3 = m_p1 + m_p2.normalize().multiply(m_extensionFaceNormal) + createFolders('WorkAxis') + name = "Normal" + plot_axis(m_p1,m_p3, part, name) + createFolders('WorkPoints') + name = "Point" + plot_point(m_p1, part, name) + view.removeEventCallback("SoMouseButtonEvent",m_callback) + +def getClickedTangent(info): + msg=0 + view = Gui.ActiveDocument.ActiveView + down = (info["State"] == "DOWN") + pos = info["Position"] + if msg != 0: + print_msg("info['Position'] : " + str(pos)) + global m_stack + global m_callback + global m_extensionFaceNorma + part = "Part::Feature" + if (down): + point = view.getPoint(pos[0],pos[1]) + obj = view.getObjectInfo(pos) + if msg != 0: + print_msg("view.getPoint(pos[0],pos[1] : " + str(point)) + print_msg("view.getObjectInfo(pos) : " + str(obj)) + if obj == None: + printError_msg("No Object selected !") + view.removeEventCallback("SoMouseButtonEvent",m_callback) + return None + else: + m_sel = Gui.Selection.getSelection()[0] + m_face = m_sel.Shape.Faces[0] + m_surf = m_face.Surface + m_p = App.Vector(obj["x"],obj["y"],obj["z"]) + m_uv = m_surf.parameter(m_p) + u,v = m_uv[0], m_uv[1] + m_p1 = m_face.valueAt(u,v) + m_p2 = m_face.normalAt(u,v) + m_p3 = m_p1 + m_p2.normalize().multiply(m_extensionFaceNormal) + Plane_Normal = m_p3 - m_p1 + createFolders('WorkPlanes') + name = "Tangent" + Plane_User_Name, plane = plot_plane(m_lengthPlane, m_widthPlane, m_p1, Plane_Normal, part, name) + #createFolders('WorkAxis') + #name = "Normal" + #plot_axis(m_p1,m_p3, part, name) + createFolders('WorkPoints') + name = "Point" + plot_point(m_p1, part, name) + view.removeEventCallback("SoMouseButtonEvent",m_callback) + + def getClickedPoint(event_cb): event = event_cb.getEvent() view = Gui.ActiveDocument.ActiveView @@ -653,8 +813,8 @@ def getClickedPoint(event_cb): part = "Part::Feature" plot_point(stack[-1], part, name) view.removeEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),m_callback) - - + + def getClickedAxis(event_cb): event = event_cb.getEvent() view = Gui.ActiveDocument.ActiveView @@ -693,11 +853,11 @@ def getClickedPlane2(info): Plane_Point = m_stack[-1] # Create a Plane Plane_User_Name, plane = plot_plane(m_lengthPlane, m_widthPlane, Plane_Point, Plane_Normal, part, name) - + view.removeEventCallback("SoMouseButtonEvent",m_callback) del m_stack[:] - + def getClickedPlane(event_cb): event = event_cb.getEvent() view = Gui.ActiveDocument.ActiveView @@ -716,21 +876,62 @@ def getClickedPlane(event_cb): Plane_Point = m_stack[-1] # Create a Plane Plane_User_Name, plane = plot_plane(m_lengthPlane, m_widthPlane, Plane_Point, Plane_Normal, part, name) - + view.removeEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),m_callback) del m_stack[:] - + +#============================================================================== +# def intersecLineLine(A, B, C, D, info=0): +# """ Return the intersection between the Line L1 defined by A and B +# and the Line L2 defined by C and D, if exists. +# """ +# # L1 is the line defined by 2 points A(ax, ay, az) and B(bx, by, bz), and +# # may be also defined as the line crossing A(ax, ay, az) and along the +# # direction AB = U1(bx-ax, by-ay, bz-az) +# # If U1(u1x, u1y, u1z) = U1(bx-ax, by-ay, bz-az) the Line L1 is the set of +# # points M1 as defined by eq(1): +# # Vector(M1A) = k1 * Vector(U1) +# # with k1 Real +# if A == B: +# return None +# ax, ay, az = A.x, A.y, A.z +# bx, by, bz = B.x, B.y, B.z +# u1x, u1y, u1z = bx - ax, by - ay, bz - az +# +# # L2 is the line defined by 2 points C(cx, cy, cz) and D(dx, dy, dz), and +# # may be also defined as the line crossing C(cx, cy, cz) and along the +# # direction CD = U2(dx-cx, dy-cy, dz-cz) +# # If U2(u2x, u2y, u2z) = U2(dx-cx, dy-cy, dz-cz) the Line L1 is the set of +# # points M2 as defined by eq(2): +# # Vector(M2C) = k2 * Vector(U2) +# # with k2 Real +# if C == D: +# return None +# cx, cy, cz = C.x, C.y, C.z +# dx, dy, dz = D.x, D.y, D.z +# u2x, u2y, u2z = dx - cx, dy - cy, dz - cz +# +# # We look for point T(tx, ty, tz) as eq(3): +# #Vector(TA) = k1 * Vector(U1) and +# #Vector(TC) = k2 * Vector(U2) +# tx = ax + k * ux +# +# ty = ay + k * uy +# tz = az + k * uz +# +# return T +#============================================================================== def intersecPerpendicularLine(A, B, C, info=0): """ Return the intersection between the Line L defined by A and B and the Line perpendicular crossing the point C. """ # L is the line defined by 2 points A(ax, ay, az) and B(bx, by, bz), and - # may be also defined as the line crossing A(ax, ay, az) and along the + # may be also defined as the line crossing A(ax, ay, az) and along the # direction AB = U(bx-ax, by-ay, bz-az) - # If U(ux, uy, uz) = U(bx-ax, by-ay, bz-az) the Line L is the set of + # If U(ux, uy, uz) = U(bx-ax, by-ay, bz-az) the Line L is the set of # points M as defined by eq(1): # Vector(MA) = k * Vector(U) - # with k Real + # with k Real if A == B: return None ax, ay, az = A.x, A.y, A.z @@ -740,14 +941,14 @@ def intersecPerpendicularLine(A, B, C, info=0): #U = App.Vector(ux, uy, uz) # We look for T(tx, ty, tz) on the Line L # eq(1) in parametric form; k exists and follows eq(2): - # tx = ax + k * ux + # tx = ax + k * ux # ty = ay + k * uy # tz = az + k * uz - + # and vector V(vx, vy, vz) defined by point C and point T # vx, vy, vz = tx - cx, ty - cy, tz - cz - # V must be perpendicular to the Line L - # We consider Dot product between U and V and give us eq(3) + # V must be perpendicular to the Line L + # We consider Dot product between U and V and give us eq(3) # U.V = 0 # so ux * vx + uy * vy + uz * vz = 0 # ux * (tx - cx) + uy * (ty - cy) + uz * (tz - cz) = 0 @@ -755,8 +956,8 @@ def intersecPerpendicularLine(A, B, C, info=0): # ux*ax + ux*(k*ux) - ux*cx + uy*ay + uy*(k*uy) - uy*cy + uz*az + uz*(k*uz) - uz*cz = 0 if (ux*ux + uy*uy + uz*uz) == 0.0: return None - k = (ux*cx + uy*cy + uz*cz - ux*ax - uy*ay - uz*az)/(ux*ux + uy*uy + uz*uz) - tx = ax + k * ux + k = (ux*cx + uy*cy + uz*cz - ux*ax - uy*ay - uz*az)/(ux*ux + uy*uy + uz*uz) + tx = ax + k * ux ty = ay + k * uy tz = az + k * uz T = App.Vector(tx, ty, tz) @@ -768,20 +969,20 @@ def intersecPerpendicularLine(A, B, C, info=0): print_point(T, msg="Intersection Point at distance of " + str(distance) + " is : ") return T, distance, Tprime - - + + def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): """ Return the intersection between the Line L defined by A and B and the Plane defined by Plane_Normal and Plane_Point. """ - # Plane Equation is eq(0) P(x, y, z): - # a * x + b * y + c * z + d = 0 + # Plane Equation is eq(0) P(x, y, z): + # a * x + b * y + c * z + d = 0 # where Normal to P is N(a, b, c) N = Plane_Normal if info == 1: print_point(N,"N is : ") #if N == App.Vector(0.0, 0.0, 0.0): - # return None + # return None a, b, c = N.x, N.y, N.z if info == 1: print_msg("a = " + str(a) + " b = " + str(b) + " c = " + str(c)) @@ -793,9 +994,9 @@ def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): if info == 1: print_msg("d = "+ str(d)) # L is the line defined by 2 points A(ax, ay, az) and B(bx, by, bz), and - # may be also defined as the line crossing A(ax, ay, az) and along + # may be also defined as the line crossing A(ax, ay, az) and along # the direction AB = U(bx-ax, by-ay, bz-az) - # If U(ux, uy, uz) = U(bx-ax, by-ay, bz-az) the Line L is the set of + # If U(ux, uy, uz) = U(bx-ax, by-ay, bz-az) the Line L is the set of # points M as defined by eq(1): # Vector(MA) = k * Vector(U) # with k Real @@ -807,11 +1008,11 @@ def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): U = App.Vector(ux, uy, uz) if info == 1: print_point(U,"U is : ") - # We consider Dot product between U and N + # We consider Dot product between U and N # 1> U.N = 0 if info == 1: print_msg("U.dot(N) =" + str(U.dot(N))) - + if U.dot(N) == 0.0: # if A belongs to P : the full Line L is included in the Plane if (a * ax) + (b * ay) + (c * az) + d == 0.0: @@ -827,15 +1028,15 @@ def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): else: # We look for T(tx, ty, tz) on the Line L # eq(1) in parametric form; k exists and follows eq(2): - # tx = ax + k * ux + # tx = ax + k * ux # ty = ay + k * uy # tz = az + k * uz # and T(tx, ty, tz) on the plane too so eq(1) is # a * tx + b * ty + c * tz + d = 0 - # by pasting the tx, ty and tz expressions into eq(1) we have a first + # by pasting the tx, ty and tz expressions into eq(1) we have a first # deg equation with one unknow 'k': # a * (ax + k * ux) + b * (ay + k * uy) + c * (az + k * uz) + d = 0 - # so + # so # a * ax + a * k * ux + b * ay + b * k * uy + c * az + c * k * uz + d = 0 # k * ( a * ux + b * uy c *uz ) + a * ax + b * ay + c * az + d = 0 # k = -1 * (a * ax + b * ay + c * az + d) / ( a * ux + b * uy + c *uz ) @@ -844,7 +1045,7 @@ def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): print_msg("a * ux + b * uy + c *uz == " + str(a * ux + b * uy + c *uz)) return None k = -1 * (a * ax + b * ay + c * az + d) / ( a * ux + b * uy + c *uz ) - tx = ax + k * ux + tx = ax + k * ux ty = ay + k * uy tz = az + k * uz if info == 1: @@ -855,11 +1056,11 @@ def intersecLinePlane(A, B, Plane_Normal, Plane_Point, info=0): return T -def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, info=0): +def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, info=0): """ Return the intersection Line between two Planes. """ - # Plane Equation is eq(0) P1(x, y, z): - # a1 * x + b1 * y + c1 * z + d1 = 0 + # Plane Equation is eq(0) P1(x, y, z): + # a1 * x + b1 * y + c1 * z + d1 = 0 # where Normal to P1 is N1(a1, b1, c1) N1 = Plane_Normal1 if info == 1: @@ -867,8 +1068,8 @@ def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, a1, b1, c1 = N1.x, N1.y, N1.z if info == 1: print_msg("a1 = " + str(a1) + " b1 = " + str(b1) + " c1 = " + str(c1)) - # Plane Equation is eq(1) P2(x, y, z): - # a2 * x + b2 * y + c2 * z + d2 = 0 + # Plane Equation is eq(1) P2(x, y, z): + # a2 * x + b2 * y + c2 * z + d2 = 0 # where Normal to P2 is N2(a2, b2, c2) N2 = Plane_Normal2 if info == 1: @@ -876,7 +1077,7 @@ def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, a2, b2, c2 = N2.x, N2.y, N2.z if info == 1: print_msg("a2 = " + str(a2) + " b2 = " + str(b2) + " c2 = " + str(c2)) - + # p1(p1x,p1y,p1z) belongs to the plane P1, so # a1 * p1x + b1 * p1y + c1 * p1z + d1 = 0 and # d1 = -(a1 * p1x + b1 * p1y + c1 * p1z) @@ -884,7 +1085,7 @@ def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, d1 = -((a1 * p1.x) + (b1 * p1.y) + (c1 * p1.z)) if info == 1: print_msg("d1 = "+ str(d1)) - + # p2(p2x,p2y,p2z) belongs to the plane P2, so # a2 * p2x + b2 * p2y + c2 * p2z + d2 = 0 and # d2 = -(a2 * p2x + b2 * p2y + c2 * p2z) @@ -892,14 +1093,14 @@ def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, d2 = -((a2 * p2.x) + (b2 * p2.y) + (c2 * p2.z)) if info == 1: print_msg("d2 = "+ str(d2)) - - U = N2.cross( N1 ) + + U = N2.cross( N1 ) if abs(U.x) <= 1.e-16 and abs(U.y) <= 1.e-16 and abs(U.z) <= 1.e-16: - U.x, U.y, U.z = 0.0, 0.0, 0.0 - + U.x, U.y, U.z = 0.0, 0.0, 0.0 + if info == 1: print_point(U,"N2.cross( N1 ) : ") - + if abs(U.x) == 0.0 and abs(U.y) == 0.0 and abs(U.z) == 0.0: if a1/a2 == d1/d2: if info == 1: @@ -912,11 +1113,267 @@ def intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, else: return U +#============================================================================== + +def plot_point(Vector_point, part, name, grp="WorkPoints"): + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + point = App.ActiveDocument.addObject( part, name ) + point.Shape = Part.Vertex( Vector_point ) + App.ActiveDocument.getObject( grp ).addObject(point) + point_User_Name = point.Label + Gui.ActiveDocument.getObject( point_User_Name ).PointColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( point_User_Name ).PointSize = 5.00 + return point_User_Name + + +def plot_axis(Vector_A, Vector_B, part, name, grp="WorkAxis"): + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + axis = App.ActiveDocument.addObject(part, name) + axis.Shape = Part.makeLine(Vector_A, Vector_B) + App.ActiveDocument.getObject( grp ).addObject(axis) + axis_User_Name = axis.Label + Gui.ActiveDocument.getObject(axis_User_Name).LineColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject(axis_User_Name).PointColor = (1.00,0.67,0.00) + return axis_User_Name, axis + + +def plot_circle(Radius, Position, Direction, part= "Part::Feature", name= "Circle", grp="Circles"): + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + circle = App.ActiveDocument.addObject(part, name) + circle.Shape = Part.makeCircle(Radius, Position, Direction) + App.ActiveDocument.getObject( grp ).addObject(circle) + circle_User_Name = circle.Label + Gui.ActiveDocument.getObject(circle_User_Name).LineColor = (1.00,0.67,0.00) + return circle_User_Name, circle + + +def plot_ellipse(S1, S2, Center, part= "Part::Feature", name= "Ellipse", grp="Circles"): + """Creates an ellipse centered on the point Center, where + the plane of the ellipse is defined by Center, S1 and S2, + its major axis is defined by Center and S1, + its major radius is the distance between Center and S1, and + its minor radius is the distance between S2 and the major axis. + """ + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + ellipse = App.ActiveDocument.addObject(part, name) + + print_point(Center,"Center = :") + print_point(S1,"S1 = :") + print_point(S2,"S2 = :") + + P1C = (Center - S1).Length + P2C = (Center - S2).Length + if P1C > P2C: + e = Part.Ellipse(S1,S2,Center) + else: + #e = Part.Ellipse(S1+Center,S2,Center) + e = Part.Ellipse(S2,S1,Center) + #e = Part.Ellipse() + print_msg(str(e)) + + ellipse.Shape = e.toShape() + App.ActiveDocument.getObject( grp ).addObject(ellipse) + ellipse_User_Name = ellipse.Label + Gui.ActiveDocument.getObject(ellipse_User_Name).LineColor = (1.00,0.67,0.00) + return ellipse_User_Name, ellipse + + +def plot_plane(Edge_Length1, Edge_Length2, Plane_Point, Plane_Normal, part, name, grp="WorkPlanes"): + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + + plane = App.ActiveDocument.addObject(part, name) + + Plane_face = Part.makePlane( Edge_Length1, Edge_Length2, Plane_Point, Plane_Normal ) + Plane_Center = Plane_face.CenterOfMass + Plane_Translate = Plane_Point - Plane_Center + Plane_face.translate( Plane_Translate ) + plane.Shape = Plane_face + + App.ActiveDocument.getObject( grp ).addObject( plane ) + plane_User_Name = plane.Label + Gui.ActiveDocument.getObject( plane_User_Name ).PointColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( plane_User_Name ).LineColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( plane_User_Name ).ShapeColor = (0.00,0.33,1.00) + Gui.ActiveDocument.getObject( plane_User_Name ).Transparency = 75 + return plane_User_Name, plane + + + +def plot_cube(length, width, height, point, axis, part, name, grp="WorkObjects"): + """ Creating a Cube in the view. + One of the Cube's extremities will be at the given point location. + The Cube's axis will be along given axis + Function used : makeBox(length,width,height,[pnt,axis]). + By default pnt=Vector(0,0,0) and axis=Vector(0,0,1) + """ + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + + cube = App.ActiveDocument.addObject(part, name) + + Cube = Part.makeBox(length, width, abs(height), point, axis ) + Cube_Center = Cube.CenterOfMass + Cube_Translate = point - Cube_Center + Cube.translate( Cube_Translate ) + Cube_Translate = axis.normalize().multiply(height/2.) + Cube.translate( Cube_Translate ) + cube.Shape = Cube + + App.ActiveDocument.getObject( grp ).addObject( cube ) + cube_User_Name = cube.Label + + Gui.ActiveDocument.getObject( cube_User_Name ).PointColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( cube_User_Name ).LineColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( cube_User_Name ).ShapeColor = (0.00,0.33,1.00) + Gui.ActiveDocument.getObject( cube_User_Name ).Transparency = 75 + return cube_User_Name, cube + + +def plot_cylinder(radius, height, point, axis, part, name, grp="WorkObjects"): + """ Creating a Cylinder in the view. + One of the Cylinder's extremities will be at the given point location. + The Cylinder's axis will be along given axis + Function used : makeCylinder(radius,height,[pnt,axis,angle]). + By default pnt=Vector(0,0,0),axis=Vector(0,0,1) and angle=360 + """ + if not(App.ActiveDocument.getObject( grp )): + App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) + + cylinder = App.ActiveDocument.addObject(part, name) + + Cylinder = Part.makeCylinder( radius, abs(height), point, axis ) + Cylinder_Center = Cylinder.CenterOfMass + Cylinder_Translate = point - Cylinder_Center + Cylinder.translate( Cylinder_Translate ) + Cylinder_Translate = axis.normalize().multiply(height/2.) + Cylinder.translate( Cylinder_Translate ) + cylinder.Shape = Cylinder + + App.ActiveDocument.getObject( grp ).addObject( cylinder ) + cylinder_User_Name = cylinder.Label + Gui.ActiveDocument.getObject( cylinder_User_Name ).PointColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( cylinder_User_Name ).LineColor = (1.00,0.67,0.00) + Gui.ActiveDocument.getObject( cylinder_User_Name ).ShapeColor = (0.00,0.33,1.00) + Gui.ActiveDocument.getObject( cylinder_User_Name ).Transparency = 75 + return cylinder_User_Name, cylinder + + +def bounding_box(grp,ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info=0): + """ Create a bounding box. + """ + m_grp = grp + m_l_X = length_X + m_l_Y = length_Y + m_l_Z = length_Z + m_o_X = ori_X + m_o_Y = ori_Y + m_o_Z = ori_Z + global flag_for_face + flag_for_face = True + + if info != 0: + print_msg("Xmin, Ymin, Zmin : \n" + + str(m_o_X) + " , " + str(m_o_Y) + " , " + str(m_o_Z)) + print_msg("Lengths m_l_X , m_l_Y , m_l_Z : \n" + + str(m_l_X) + " , " + str(m_l_Y) + " , " + str(m_l_Z)) + + if (m_l_X != 0.0) and (m_l_Y != 0.0): + try: + m_pl_0 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), + App.Rotation(0.0,0.0,0.0)) + m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Y, + placement=m_pl_0,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 0 not done !") + try: + m_pl_1 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z+m_l_Z), + App.Rotation(0.0,0.0,0.0)) + m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Y, + placement=m_pl_1,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 1 not done !") + + if (m_l_X != 0.0) and (m_l_Z != 0.0): + try: + m_pl_2 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), + App.Rotation(0.0,0.0,90)) + m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Z, + placement=m_pl_2,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 2 not done !") + try: + m_pl_3 = App.Placement(App.Vector(m_o_X,m_o_Y+m_l_Y,m_o_Z), + App.Rotation(0.0,0.0,90)) + m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Z, + placement=m_pl_3,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 3 not done !") + + if (m_l_Y != 0.0) and (m_l_Z != 0.0): + try: + m_pl_4 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), + App.Rotation(90,0.0,90)) + m_rect = Draft.makeRectangle(length=m_l_Y,height=m_l_Z, + placement=m_pl_4,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 4 not done !") + try: + m_pl_5 = App.Placement(App.Vector(m_o_X+m_l_X,m_o_Y,m_o_Z), + App.Rotation(90,0.0,90)) + m_rect = Draft.makeRectangle(length=m_l_Y,height=m_l_Z, + placement=m_pl_5,face=flag_for_face,support=None) + addObjectToGrp(m_rect,m_grp,info=info) + definePropOfActiveObj() + except: + printError_msg("Rectangle 5 not done !") + + #if (m_l_X != 0.0) and (m_l_Y != 0.0) and (m_l_Z != 0.0): + try: + if (m_l_X == 0.0): + m_l_X = 0.5 + m_o_X = m_o_X - 0.25 + if (m_l_Y == 0.0): + m_l_Y = 0.5 + m_o_Y = m_o_Y - 0.25 + if (m_l_Z == 0.0): + m_l_Z = 0.5 + m_o_Z = m_o_Z - 0.25 + m_pnt = App.Vector(m_o_X ,m_o_Y,m_o_Z) + print_point(m_pnt, msg="m_pnt") + # adds object to the document group + box = App.ActiveDocument.addObject("Part::Feature", "BBox") + #By default pnt=Vector(0,0,0) and dir=Vector(0,0,1) + Box_face = Part.makeBox(m_l_X,m_l_Y,m_l_Z,m_pnt) + #print_msg("Box_face :" + str(Box_face) ) + box.Shape = Box_face + m_grp.addObject( box ) + Gui.activeDocument().activeObject().Transparency = (50) + print_msg("Bounding Box created !") + except: + printError_msg("Bounding Box not created !") +#============================================================================== + + def plot_originObject(): createFolders('Origin') - try: - if not(App.ActiveDocument.getObject("Origin_Point")): + try: + if not(App.ActiveDocument.getObject("Origin_Point")): Line_Color = (1.00,0.33,0.00) Shape_Color = (0.00,1.00,0.50) Transparency = 75 @@ -930,7 +1387,7 @@ def plot_originObject(): Gui.ActiveDocument.getObject(Origin_User_Name).PointColor = (0.33, 0.00, 1.00) Gui.ActiveDocument.getObject(Origin_User_Name).PointSize = 4.00 Gui.ActiveDocument.getObject("Origin_Point").Visibility=False - + #Work-AxisX AX_Length = 300 PX_A = Base.Vector(AX_Length, 0, 0) @@ -943,7 +1400,7 @@ def plot_originObject(): Gui.ActiveDocument.getObject(Axis_User_Name).LineColor = (1.00,0.00,0.00) Gui.ActiveDocument.getObject(Axis_User_Name).PointColor = (1.00,0.00,0.00) Gui.ActiveDocument.getObject("Ori_X_Axis").Visibility=False - + #Work-AxisY AY_Length = 300 PY_A = Base.Vector(0, AY_Length, 0) @@ -956,7 +1413,7 @@ def plot_originObject(): Gui.ActiveDocument.getObject(Axis_User_Name).LineColor = (0.00,0.67,0.00) Gui.ActiveDocument.getObject(Axis_User_Name).PointColor = (0.00,0.67,0.00) Gui.ActiveDocument.getObject("Ori_Y_Axis").Visibility=False - + #Work-AxisZ AZ_Length = 300 PZ_A = Base.Vector(0,0 , AZ_Length) @@ -969,7 +1426,7 @@ def plot_originObject(): Gui.ActiveDocument.getObject(Axis_User_Name).LineColor = (0.33,0.00,1.00) Gui.ActiveDocument.getObject(Axis_User_Name).PointColor = (0.33,0.00,1.00) Gui.ActiveDocument.getObject("Ori_Z_Axis").Visibility=False - + # Work-PlaneXY PXY_A_SIZE = 300 PXY_A = Base.Vector(PXY_A_SIZE, PXY_A_SIZE, 0) @@ -988,9 +1445,9 @@ def plot_originObject(): Gui.ActiveDocument.getObject(PlaneXY_User_Name).ShapeColor = Shape_Color Gui.ActiveDocument.getObject(PlaneXY_User_Name).Transparency = Transparency Gui.ActiveDocument.getObject("XY_WPlane").Visibility=False - + # Work-PlaneXY - PXZ_A_SIZE = 300 + PXZ_A_SIZE = 300 PXZ_A = Base.Vector(PXZ_A_SIZE, 0, PXZ_A_SIZE) PXZ_B = PXZ_A + Base.Vector(-2.0*PXZ_A_SIZE, 0, 0) PXZ_C = PXZ_A + Base.Vector(-2.0*PXZ_A_SIZE, 0, -2.0*PXZ_A_SIZE) @@ -1007,7 +1464,7 @@ def plot_originObject(): Gui.ActiveDocument.getObject(PlaneXZ_User_Name).ShapeColor = Shape_Color Gui.ActiveDocument.getObject(PlaneXZ_User_Name).Transparency = Transparency Gui.ActiveDocument.getObject("XZ_WPlane").Visibility=False - + # Work-PlaneZY PYZ_A_SIZE = 300 PYZ_A = Base.Vector(0, PYZ_A_SIZE, PYZ_A_SIZE) @@ -1027,57 +1484,131 @@ def plot_originObject(): Gui.ActiveDocument.getObject(PlaneYZ_User_Name).Transparency = Transparency Gui.ActiveDocument.getObject("YZ_WPlane").Visibility=False except: - printError_msg("Could not Create Origin objects !") + printError_msg("Could not Create Origin objects !") - -def plot_point(Vector_point, part, name, grp="WorkPoints"): - if not(App.ActiveDocument.getObject( grp )): - App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) - point = App.ActiveDocument.addObject( part, name ) - point.Shape = Part.Vertex( Vector_point ) - App.ActiveDocument.getObject( grp ).addObject(point) - point_User_Name = point.Label - Gui.ActiveDocument.getObject( point_User_Name ).PointColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( point_User_Name ).PointSize = 5.00 - return point_User_Name - - -def plot_centerObjectPoint(): - """ Plot the center point of all selected Objects together. +def bBox_toggled(flag): + """ Respond to the change of bounding box flag. """ + global centerOfMass + centerOfMass = True + if flag == True: + centerOfMass = False + +def plot_centerObjectPoint(): + """ Create a Point at center location of all selected Object(s). + if flag centerOfMass=True + This point is the MEAN location of all center of Mass (if exist) of all objects. + if flag centerOfMass=False + This point is the center of the Global X,Y,Z bounding box of all objects. + This bounding box alway exists (especially for draft objects). + Be aware this point is not necessary the center of Mass of all Objects! + """ + global centerOfMass + msg=0 createFolders('WorkPoints') error_msg = "Unable to create Center Point of Object(s) : \nSelect at least one Object !" - result_msg = " : Center Point of Object(s) created !" - m_actDoc = get_ActiveDocument(info=0) - name = "CenterObjects" + flag_centerOfMass=centerOfMass + if flag_centerOfMass: + result_msg = " : Mean of Center of Mass of Object(s) created !" + name = "MeanCenterMass" + else: + result_msg = " : Center Point of global bounding box of Object(s) created !" + name = "CenterBBObject" part = "Part::Feature" - if m_actDoc.Name: - # Return a list of SelectionObjects for a given document name. - m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) - m_objs = [selobj.Object for selobj in m_selEx] - Vector_Objects_Center = centerObjectsPoint(m_objs,info=0) - if Vector_Objects_Center != None: - Center_User_Name = plot_point(Vector_Objects_Center, part, name) - print_msg(str(Center_User_Name) + result_msg ) + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: + return None + + # Return a list of SelectionObjects for a given document name. + m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) + m_objs = [selobj.Object for selobj in m_selEx] + m_objNames = [selobj.ObjectName for selobj in m_selEx] + m_num = len(m_objs) + if m_num >= 1: + if msg != 0: + print_msg( str(m_num) + " object(s) selected :\n" + str(m_objNames) ) + if flag_centerOfMass: + m_i = 0 + m_list = [] + m_c = None + Center_User_Name = None + for m_obj in m_objs: + if msg != 0: + print_msg( "Processing : " + str(m_objNames[m_i]) ) + try: + m_c = m_obj.Shape.CenterOfMass + if msg != 0: + print_msg( str(m_c) ) + + Center_User_Name = plot_point(m_c, part, name) + m_list.append(m_c) + except: + printError_msg( str(m_objNames[m_i]) + "\nThis object has no attribute 'Center of Mass' !\nSelect another one !\n") + break + if len(m_list) >=2: + m_mean = meanVectorsPoint(m_list,info=msg) + Center_User_Name = plot_point(m_mean, part, name) + print_point(m_mean,str(Center_User_Name) + result_msg + " at :") + else: + print_point(m_c,str(Center_User_Name) + result_msg + " at :") else: - printError_msg(error_msg) + Vector_Objects_Center = centerObjectsPoint(m_objs,info=msg) + if Vector_Objects_Center != None: + Center_User_Name = plot_point(Vector_Objects_Center, part, name) + print_point(Vector_Objects_Center,str(Center_User_Name) + result_msg + " at :") + else: + printError_msg(error_msg) + else: + printError_msg(error_msg) - -def plot_extremaLinePoint(): - """ Plot the first and last point of all selected Lines. + +def plot_NpointsPoint(): + """Create a Point at mean location of all selected points. """ + msg=0 + createFolders('WorkPoints') + error_msg = "Unable to create Center Point of Points : \nSelect at least 2 points !" + result_msg = " : Center Point of Points created !" + name = "CenterPoint" + part = "Part::Feature" + Selection = get_SelectedObjects(info=msg, printError=False) + try: + SelectedObjects = Selection + Number_of_Points = SelectedObjects[0] + if msg != 0: + print_msg("Number_of_Points=" + str(Number_of_Points)) + points = [] + if Number_of_Points >= 2 : + Point_List = SelectedObjects[3] + for m_point in Point_List: + points.append(m_point.Point) + if msg != 0: + print_point(m_point.Point, msg="Point : ") + Vector_Center = meanVectorsPoint(points,info=1) + + Center_User_Name = plot_point(Vector_Center, part, name) + print_point(Vector_Center,str(Center_User_Name) + result_msg + " at :") + except: + printError_msg(error_msg) + + +def plot_extremaLinePoint(): + """ Create Points at start and end location of each selected Line(s). + """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create First and Last Line Point(s) : \nSelect at least one Line !" result_msg = " : First and Last Line Point(s) created !" name = "extremumPoint" part = "Part::Feature" - Selection = get_SelectedObjects() - try: + Selection = get_SelectedObjects(info=msg, printError=False) + try: SelectedObjects = Selection - Number_of_Edges = SelectedObjects[1] + Number_of_Edges = SelectedObjects[1] #print_msg("Number_of_Edges=" + str(Number_of_Edges)) if Number_of_Edges >= 1: - Edge_List = SelectedObjects[4] + Edge_List = SelectedObjects[4] for i in range( Number_of_Edges ): #print_msg(str(Edge_List[i])) edge = Edge_List[i] @@ -1085,29 +1616,83 @@ def plot_extremaLinePoint(): Vector_B = edge.valueAt( edge.Length ) #print_point(Vector_A, msg="First Point : ") #print_point(Vector_B, msg="Last Point : ") - + Center_User_Name = plot_point(Vector_A, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_A,str(Center_User_Name) + result_msg + " at :") Center_User_Name = plot_point(Vector_B, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_B,str(Center_User_Name) + result_msg + " at :") else: printError_msg(error_msg) except: printError_msg(error_msg) +def numberLinePart(value): + """ Respond to the change in extension value from the spin box. + """ + try: + # First we check if a valid number have been entered + global m_numberLinePart + if str(value) == '-': + return + m_numberLinePart = int(value) + print_msg("New number is :" + str(m_numberLinePart)) + except ValueError: + printError_msg("Number must be valid !") + + def plot_centerLinePoint(): - """ Plot the mid point of all selected Lines. + """ Create a Point at mid point location of each selected Line(s). """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create Mid Line Point(s) : \nSelect at least one Line !" result_msg = " : Mid Line Point(s) created !" name = "MidPoint" part = "Part::Feature" - Selection = get_SelectedObjects() - try: + global m_numberLinePart + if not (m_numberLinePart >= 2 and m_numberLinePart <= 10) : + m_numberLinePart = 2 + Selection = get_SelectedObjects(info=msg, printError=False) + try: SelectedObjects = Selection - Number_of_Edges = SelectedObjects[1] + Number_of_Edges = SelectedObjects[1] + #print_msg("Number_of_Edges=" + str(Number_of_Edges)) + if Number_of_Edges >= 1: + Edge_List = SelectedObjects[4] + for i in range( Number_of_Edges ): + if m_numberLinePart == 2: + #print_msg(str(Edge_List[i])) + Vector_Line_Center = centerLinePoint(Edge_List[i],info=1) + #print_point(Vector_Line_Center, msg="MidPoint : ") + + Center_User_Name = plot_point(Vector_Line_Center, part, name) + print_point(Vector_Line_Center,str(Center_User_Name) + result_msg + " at :") + else: + for j in range( 1, m_numberLinePart ): + Vector_Line_Center = centerLinePoints(Edge_List[i], j , m_numberLinePart, info=1) + Center_User_Name = plot_point(Vector_Line_Center, part, name) + print_point(Vector_Line_Center,str(Center_User_Name) + result_msg + " at :") + pass + else: + printError_msg(error_msg) + except: + printError_msg(error_msg) + + +def plot_centerLinePoint2(): + """ Create a Point at mid point location of each selected Line(s). + """ + msg=0 + createFolders('WorkPoints') + error_msg = "Unable to create Mid Line Point(s) : \nSelect at least one Line !" + result_msg = " : Mid Line Point(s) created !" + name = "MidPoint" + part = "Part::Feature" + Selection = get_SelectedObjects(info=msg, printError=False) + try: + SelectedObjects = Selection + Number_of_Edges = SelectedObjects[1] #print_msg("Number_of_Edges=" + str(Number_of_Edges)) if Number_of_Edges >= 1: Edge_List = SelectedObjects[4] @@ -1115,9 +1700,9 @@ def plot_centerLinePoint(): #print_msg(str(Edge_List[i])) Vector_Line_Center = centerLinePoint(Edge_List[i],info=1) #print_point(Vector_Line_Center, msg="MidPoint : ") - + Center_User_Name = plot_point(Vector_Line_Center, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_Line_Center,str(Center_User_Name) + result_msg + " at :") else: printError_msg(error_msg) except: @@ -1126,7 +1711,7 @@ def plot_centerLinePoint(): def distanceLinePoint(value): """ Respond to the change in distance value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_distanceLinePoint @@ -1140,17 +1725,17 @@ def distanceLinePoint(value): def plot_alongLinePoint(): - """ Plot a point at a certain distance along the line respecting to the choosen + """ Plot a point at a certain distance along the line respecting to the choosen reference starting point. """ msg=0 createFolders('WorkPoints') - error_msg = "Unable to create a point along a Line : \nSelect one Edge AND one point only!" + error_msg = "Unable to create a point along a Line : \nSelect one Edge and one Point only!" result_msg = " : Point along a Line created !" name = "PointLine" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) - try: + Selection = get_SelectedObjects(info=msg, printError=False) + try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] Number_of_Edges = SelectedObjects[1] @@ -1176,9 +1761,9 @@ def plot_alongLinePoint(): Vector_Translate = Vector_Translate.normalize() * m_distanceLinePoint #print_point(Vector_Translate, msg="Vector_Translate") Vector_Line_Point = Vector_C + Vector_Translate - + Center_User_Name = plot_point(Vector_Line_Point, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_Line_Point,str(Center_User_Name) + result_msg + " at :") else: printError_msg("The Point and the line MUST be aligned !") else: @@ -1186,46 +1771,67 @@ def plot_alongLinePoint(): except: printError_msg(error_msg) - def plot_centerCirclePoint(): - """ Plot the center point of all selected Circles. + """ Plot the center point of all selected Circles and Ellipses. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create Center Circle Point(s) : \nSelect at least one Edge of Circle !" result_msg = " : Center Circle Point(s) created !" name = "CenterCircle" part = "Part::Feature" - Selection = get_SelectedObjects() - try: - SelectedObjects = Selection - Number_of_Edges = SelectedObjects[1] - if Number_of_Edges >= 1: - Edge_List = SelectedObjects[4] - for i in range( Number_of_Edges ): - try: - Edge_List[i].Curve.Radius - #Center = Edge_List[i].centerOfCurvatureAt( 0.0 ) - Vector_Circle_Center = centerCirclePoint(Edge_List[i],info=1) - Center_User_Name = plot_point(Vector_Circle_Center, part, name) - print_msg(str(Center_User_Name) + result_msg ) - except: - printError_msg("Found One or More Non-Circular Edges") - else: - printError_msg(error_msg) - except: + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: + return None + + # Return a list of SelectionObjects for a given document name. + m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) + m_objs = [selobj.Object for selobj in m_selEx] + m_objNames = [selobj.ObjectName for selobj in m_selEx] + m_num = len(m_objs) + if m_num >= 1: + if msg != 0: + print_msg( str(m_num) + " object(s) selected :\n" + str(m_objNames) ) + m_i = 0 + for m_obj in m_objs: + if msg != 0: + print_msg( "Processing : " + str(m_objNames[m_i]) ) + + try: + m_c = m_obj.Shape.Curve.Center + Center_User_Name = plot_point(m_c, part, name) + print_point(m_c,str(Center_User_Name) + result_msg + " at :") + except AttributeError: + SelectedObjects = get_SelectedObjects() + Number_of_Edges = SelectedObjects[1] + if Number_of_Edges >= 1: + Edge_List = SelectedObjects[4] + for i in range( Number_of_Edges ): + try: + Edge_List[i].Curve.Radius + Vector_Circle_Center = centerCirclePoint(Edge_List[i],info=0) + Center_User_Name = plot_point(Vector_Circle_Center, part, name) + print_point(Vector_Circle_Center,str(Center_User_Name) + result_msg + " at :") + except: + printError_msg("Found One or More Non-Circular Edges") + else: + printError_msg(error_msg) + + else: printError_msg(error_msg) - + def plot_centerFacePoint(): """ Plot the center point of all selected Planes. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create Center Face Point(s) : \nSelect at least one Plane surface !" result_msg = " : Center Face Point(s) created !" name = "CenterFace" part = "Part::Feature" - Selection = get_SelectedObjects() + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Planes = SelectedObjects[2] @@ -1235,27 +1841,28 @@ def plot_centerFacePoint(): try: Selected_Plane = Plane_List[i] Vector_Plane_Center = Selected_Plane.CenterOfMass - + Center_User_Name = plot_point(Vector_Plane_Center, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_Plane_Center,str(Center_User_Name) + result_msg + " at :") except: printError_msg("Non Planar Surface !") else: - printError_msg(error_msg) + printError_msg(error_msg) except: - printError_msg(error_msg) + printError_msg(error_msg) def plot_lineFacePoint(): """ Plot the intersection point between one Line and one plane. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create (Line,Face) Intersection : \nSelect one Line and one Plane surface !" result_msg = " : (Line,Face) Intersection created !" name = "LineFacePoint" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) - try: + Selection = get_SelectedObjects(info=msg) + try: SelectedObjects = Selection Number_of_Edges = SelectedObjects[1] Number_of_Planes = SelectedObjects[2] @@ -1271,31 +1878,32 @@ def plot_lineFacePoint(): print_point(Vector_B, msg="Point B : ") Reference_Plane = Plane_List[0] Plane_Normal = Reference_Plane.normalAt(0,0) - print_msg("Plane_Normal is : " + str(Plane_Normal)) + print_msg("Plane_Normal is : " + str(Plane_Normal)) Plane_Point = Reference_Plane.CenterOfMass print_point(Plane_Point,"Plane_Point is : ") - + Vector_T = intersecLinePlane(Vector_A, Vector_B, Plane_Normal, Plane_Point, info=0) - + Center_User_Name = plot_point(Vector_T, part, name) - print_msg(str(Center_User_Name) + result_msg ) + print_point(Vector_T,str(Center_User_Name) + result_msg + " at :") else: printError_msg(error_msg) except: printError_msg(error_msg) - + def plot_pointLinePoint(): """ Plot the intersection point T on a Line given one Line and One Point C. The Vector TC is perpendicular to the line. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create (Point,Line) Intersection : \nSelect one Line and one Point not on the Line !" result_msg = " : (Point,Line) Intersection and symetric are created !" name = "PointLinePoint" part = "Part::Feature" - Selection = get_SelectedObjects(info=1) - try: + Selection = get_SelectedObjects(info=msg) + try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] Number_of_Edges = SelectedObjects[1] @@ -1305,11 +1913,14 @@ def plot_pointLinePoint(): Vector_A = Edge_List[0].valueAt( 0.0 ) Vector_B = Edge_List[0].valueAt( Edge_List[0].Length ) Vector_C = Point_List[0].Point - + Vector_T, Distance, Vector_Tprime = intersecPerpendicularLine(Vector_A, Vector_B, Vector_C, info=0) - + Center_User_Name = plot_point(Vector_T, part, name) - plot_point(Vector_Tprime, part, name) + print_point(Vector_T,str(Center_User_Name) + result_msg + " at :") + Center_User_Name2 = plot_point(Vector_Tprime, part, name) + print_point(Vector_Tprime,str(Center_User_Name2) + result_msg + " at :") + print_msg(str(Center_User_Name) + result_msg + " at a distance from the line of " + str(Distance)) else: printError_msg(error_msg) @@ -1321,13 +1932,14 @@ def plot_pointFacePoint(): """ Plot the intersection point T on a Plane given one Plane and One Point C. The Vector TC is perpendicular to the plane. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create (Point,Face) Intersection : \nSelect one Face and one Point not on the Face !" result_msg = " : (Point,Face) Intersection and symetric are created !" name = "PointFacePoint" part = "Part::Feature" - Selection = get_SelectedObjects(info=1) - try: + Selection = get_SelectedObjects(info=msg) + try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] Number_of_Planes = SelectedObjects[2] @@ -1336,29 +1948,71 @@ def plot_pointFacePoint(): if (Number_of_Points == 1) and (Number_of_Planes == 1): Point_List = SelectedObjects[3] Plane_List = SelectedObjects[5] - + Selected_Plane = Plane_List[0] Vector_C = Point_List[0].Point - + Plane_Point = Selected_Plane.CenterOfMass Plane_Normal = Selected_Plane.normalAt(0,0) - + Vector_B = Vector_C + Plane_Normal - + Vector_T = intersecLinePlane(Vector_C, Vector_B, Plane_Normal, Plane_Point, info=0) - + Center_User_Name = plot_point(Vector_T, part, name) - print_msg(str(Center_User_Name) + result_msg ) - + print_point(Vector_T,str(Center_User_Name) + result_msg + " at :") + else: printError_msg(error_msg) except: printError_msg(error_msg) +def plot_2LinesPoint(): + """ Plot one or two Point(s) at minimum distance of two Lines. + """ + msg=0 + createFolders('WorkPoints') + error_msg = "Unable to create (Line,Line) Intersection(s) : \nSelect two Lines !" + result_msg = " : (Line,Line) Intersection(s) are created !" + name = "Intersection" + part = "Part::Feature" + Selection = get_SelectedObjects(info=msg) + try: + SelectedObjects = Selection + Number_of_Edges = SelectedObjects[1] + if Number_of_Edges == 2: + Edge_List = SelectedObjects[4] + f1 = Edge_List[0] + f2 = Edge_List[1] + #print_msg(str(f1)) + #print_msg(str(f2)) + d = f1.distToShape(f2) + #print_msg(str(d)) + Distance = d[0] + Vector_A = d[1][0][0] + #print_point(Vector_A,"Vector_A is : ") + Vector_B = d[1][0][1] + if abs(Distance) <= 1.e-14: + Center_User_Name = plot_point(Vector_A, part, name) + print_msg(str(Center_User_Name) + result_msg ) + else: + Center_User_Name = plot_point(Vector_A, part, name) + print_point(Vector_A,str(Center_User_Name) + result_msg + " at :") + Center_User_Name = plot_point(Vector_B, part, name) + print_point(Vector_B,str(Center_User_Name) + result_msg + " at :") + print_msg(str(Center_User_Name) + result_msg + " at a distance of " + str(Distance)) + else: + printError_msg(error_msg) + + except: + printError_msg(error_msg) + + def plot_clickForPoint(): - """ Plot a Point at location of a mouse click. + """ Plot a Point at location of a mouse click. """ + createFolders('WorkPoints') global m_callback #print_msg("plot_clickForPoint" ) #view = Gui.ActiveDocument.ActiveView @@ -1370,51 +2024,43 @@ def plot_clickForPoint(): def plot_baseObjectPoint(): """ Plot base point of all selected objects. """ + msg=0 createFolders('WorkPoints') error_msg = "Unable to create Base point of Object(s): \nSelect at least one Object !" result_msg = " : Base point of Object(s) created !" - m_actDoc = get_ActiveDocument(info=0) name = "BasePoint" part = "Part::Feature" - if m_actDoc.Name: - # Return a list of SelectionObjects for a given document name. - m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) - m_objs = [selobj.Object for selobj in m_selEx] - m_num = len(m_objs) - if m_num >= 1: - for m_i in range(0,m_num): - m_base = m_objs[m_i].Placement.Base - if m_base != None: - Center_User_Name = plot_point(m_base, part, name) - print_msg(str(Center_User_Name) + result_msg ) - else: - printError_msg(error_msg) - - -def plot_axis(Vector_A, Vector_B, part, name, grp="WorkAxis"): - if not(App.ActiveDocument.getObject( grp )): - App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) - axis = App.ActiveDocument.addObject(part, name) - axis.Shape = Part.makeLine(Vector_A, Vector_B) - App.ActiveDocument.getObject( grp ).addObject(axis) - axis_User_Name = axis.Label - Gui.ActiveDocument.getObject(axis_User_Name).LineColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject(axis_User_Name).PointColor = (1.00,0.67,0.00) - return axis_User_Name, axis + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: + return None + + # Return a list of SelectionObjects for a given document name. + m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) + m_objs = [selobj.Object for selobj in m_selEx] + m_num = len(m_objs) + if m_num >= 1: + for m_i in range(0,m_num): + m_base = m_objs[m_i].Placement.Base + if m_base != None: + Center_User_Name = plot_point(m_base, part, name) + print_point(m_base,str(Center_User_Name) + result_msg + " at :") + else: + printError_msg(error_msg) def plot_centerObjectAxes(): """ Create 3 Axes XY, and Z at center point of all selected objects. """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Axes : \nSelect at least one object !" result_msg = " : Axes created !" - m_actDoc=App.activeDocument() - message = "Active Document is : " + str(m_actDoc.Name) - print_msg(message) + + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc.Name == None: - printError_msg("No Active document selected !") return None + # Return a list of SelectionObjects for a given document name. m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) m_objs = [selobj.Object for selobj in m_selEx] @@ -1432,7 +2078,7 @@ def plot_centerObjectAxes(): AX_Length = 10. PX_A = Base.Vector(AX_Length, 0, 0) PX_B = Base.Vector(-AX_Length, 0, 0) - Axis_X = Part.makeLine(Center+PX_A, Center+PX_B) + Axis_X = Part.makeLine(Center+PX_A, Center+PX_B) Axis = App.ActiveDocument.addObject("Part::Feature","X_Axis") Axis.Shape = Axis_X App.ActiveDocument.getObject("WorkAxis").addObject(Axis) @@ -1479,7 +2125,7 @@ def plot_centerObjectAxes(): def extensionTwoPointsAxis(value): """ Respond to the change in extension value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_extensionTwoPointsAxis @@ -1488,18 +2134,21 @@ def extensionTwoPointsAxis(value): m_extensionTwoPointsAxis = float(value) print_msg("New extension is :" + str(m_extensionTwoPointsAxis)) except ValueError: - printError_msg("Extension must be valid number !") + printError_msg("Extension must be valid number !") -def plot_twoPointsAxis(): +def plot_2PointsAxis(): + """ Create an Axis with the 2 points selected as ends. + """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Axis : \nSelect two points only !" result_msg = " : Axis created !" name = "Line from 2 Points" part = "Part::Feature" - Selection = get_SelectedObjects(info=1) + Selection = get_SelectedObjects(info=msg, printError=False) try: - SelectedObjects = Selection + SelectedObjects = Selection Number_of_Points = SelectedObjects[0] #print_msg(" Number_of_Points=" + str(Number_of_Points)) if Number_of_Points == 2: @@ -1508,16 +2157,16 @@ def plot_twoPointsAxis(): Axis_A = Point_List[0].Point Axis_B = Point_List[1].Point Axis_dir = Axis_B - Axis_A - Axis_E1 = Axis_B + Axis_E1 = Axis_B Axis_E2 = Axis_A if m_extensionTwoPointsAxis != 0.0: Axis_E1 = Axis_B + Axis_dir.normalize().multiply(m_extensionTwoPointsAxis) - if m_extensionTwoPointsAxis >= 0.0: + if m_extensionTwoPointsAxis >= 0.0: Axis_E2 = Axis_A - Axis_dir.normalize().multiply(m_extensionTwoPointsAxis) else: Axis_E2 = Axis_A + Axis_dir.normalize().multiply(m_extensionTwoPointsAxis) - + Axis_User_Name, axis = plot_axis(Axis_E1, Axis_E2, part, name) print_msg(str(Axis_User_Name) + result_msg ) @@ -1526,18 +2175,27 @@ def plot_twoPointsAxis(): except: printError_msg(error_msg) - + def plot_cylinderAxis(): + msg=1 createFolders('WorkAxis') error_msg = "Unable to create Cylinder Axis : \nSelect one cylindrical face only !" result_msg = " : Cylinder Axis created !" name = "Cylinder Axis" part = "Part::Feature" - Selection = get_SelectedObjects() + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: + return None + + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Faces = SelectedObjects[2] - #print_msg(" Number_of_Faces=" + str(Number_of_Faces)) + Number_of_Edges = SelectedObjects[1] + if msg != 0: + print_msg("Number_of_Faces=" + str(Number_of_Faces)) + print_msg("Number_of_Edges=" + str(Number_of_Edges)) if Number_of_Faces == 1: Face_list = SelectedObjects[5] Face = Face_list[0] @@ -1569,29 +2227,61 @@ def plot_cylinderAxis(): except: printError_msg("Not valid cylinder !") #print_msg("Circle_Center_1 = " + str(Circle_Center_1)) - #print_msg("Circle_Center_2 = " + str(Circle_Center_2)) + #print_msg("Circle_Center_2 = " + str(Circle_Center_2)) Axis_A = Circle_Center_1 Axis_B = Circle_Center_2 Axis_dir = Axis_B - Axis_A Axis_E1 = Axis_B + Axis_dir.multiply(0.1) Axis_E2 = Axis_A - Axis_dir.multiply(0.9) - + Axis_User_Name, axis = plot_axis(Axis_E1, Axis_E2, part, name) - + print_msg(str(Axis_User_Name) + result_msg ) + elif Number_of_Edges >= 1: + m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) + m_objs = [selobj.Object for selobj in m_selEx] + for m_obj in m_objs: +#============================================================================== +# look for sketch +# if hasattr(m_obj, 'TypeId'): +# m_type = m_obj.TypeId +# else: +# m_type = m_obj.Type +# if msg != 0: +# print_msg("m_obj.Type : " + str(m_obj.Type)) +#============================================================================== + + if hasattr(m_obj.Shape.Curve, 'Radius'): + print_msg('Radius') + m_r = m_obj.Shape.Curve.Radius + if hasattr(m_obj.Shape.Curve, 'MajorRadius'): + print_msg('MajorRadius') + m_r = m_obj.Shape.Curve.MajorRadius + m_a = m_obj.Shape.Curve.Axis + m_c = m_obj.Shape.Curve.Center + if m_r : + m_mult = m_r * 0.5 + else: + m_mult = 5 + Center_User_Name = plot_point(m_c, part, name) + Axis_User_Name, axis = plot_axis(m_c, m_c + m_a.multiply(m_mult), part, name) + Axis_User_Name, axis = plot_axis(m_c, m_c - m_a, part, name) + + print_msg(str(Axis_User_Name) + result_msg ) else: printError_msg(error_msg) except: printError_msg(error_msg) - - -def plot_twoLinesAxis(): + + +def plot_2LinesAxis(): + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Axis between 2 Lines : \nSelect two lines only !" result_msg = " : Axis between 2 Lines created !" name = "MidLine" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Edges = SelectedObjects[1] @@ -1603,33 +2293,35 @@ def plot_twoLinesAxis(): Vector_B = Edge_List[0].valueAt( Edge_List[0].Length ) #print_point(Vector_A, msg="Point A : ") #print_point(Vector_B, msg="Point B : ") - + Vector_C = Edge_List[1].valueAt( 0.0 ) Vector_D = Edge_List[1].valueAt( Edge_List[1].Length ) #print_point(Vector_C, msg="Point C : ") #print_point(Vector_D, msg="Point D : ") - + Vector_edge_1 = Vector_A + Vector_C Vector_edge_2 = Vector_B + Vector_D - + Axis_E1 = Vector_edge_1.multiply(0.5) Axis_E2 = Vector_edge_2.multiply(0.5) - + Axis_User_Name, axis = plot_axis(Axis_E1, Axis_E2, part, name) print_msg(str(Axis_User_Name) + result_msg ) except: printError_msg(error_msg) + def plot_planeAxis(): """ Plot 2 Axis perpendicular to a Plane and passing trougth center. """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Plane Axis : \nSelect at least one plane face !" result_msg = " : Plane Axis created !" name = "Axis" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Planes = SelectedObjects[2] @@ -1641,16 +2333,16 @@ def plot_planeAxis(): Selected_Plane = Plane_List[i] #print_msg(str(Selected_Plane)) Point_A = Selected_Plane.CenterOfMass - Length = Selected_Plane.Length * 0.1 + Length = Selected_Plane.Length * 0.1 #print_point(Point_A, msg="Point_A : ") #print_msg("Length = " + str(Length)) Normal = Selected_Plane.normalAt(0,0) Normal = Normal.normalize().multiply(Length) #print_point(Normal, msg="Normal : ") Point_B = App.Vector(Point_A) + Normal - Point_Bprime = App.Vector(Point_A) - Normal + Point_Bprime = App.Vector(Point_A) - Normal #Point_B = Point_B.normalize().multiply(Length) - + Axis_User_Name, axis = plot_axis(Point_B, Point_A, part, name) print_msg(str(Axis_User_Name) + result_msg ) Axis_User_Name, axis = plot_axis(Point_Bprime, Point_A, part, name) @@ -1660,12 +2352,34 @@ def plot_planeAxis(): else: printError_msg(error_msg) except: - printError_msg(error_msg) + printError_msg(error_msg) + +def extensionFaceNormal(value): + """ Respond to the change in extension value from the text box. + """ + try: + # First we check if a valid number have been entered + global m_extensionFaceNormal + if str(value) == '-': + return + m_extensionFaceNormal = float(value) + print_msg("New extension is :" + str(m_extensionFaceNormal)) + except ValueError: + printError_msg("Extension must be valid number !") + +def plot_faceNormal(): + """Create a normal Axis at click location of a Face. + """ + global m_callback + view = Gui.ActiveDocument.ActiveView + m_callback = view.addEventCallback("SoMouseButtonEvent",getClickedNormal) + + def extensionLinePointAxis(value): """ Respond to the change in extension value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_extensionLinePointAxis @@ -1675,64 +2389,69 @@ def extensionLinePointAxis(value): print_msg("New extension is :" + str(m_extensionLinePointAxis)) except ValueError: printError_msg("Extension must be valid number !") - + def plot_linePointAxis(): """ Plot an Axis perpendicular to an other axis and passing trougth a Point. - """ + """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Perpendicular Axis : \nSelect one Point and one Line only !" result_msg = " : Perpendicular Axis created !" name = "Perpendicular Line" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] Number_of_Edges = SelectedObjects[1] - #print_msg("Number_of_Edges=" + str(Number_of_Edges) + " Number_of_Points=" + str(Number_of_Points)) + if msg != 0: + print_msg("Number_of_Edges=" + str(Number_of_Edges) + + " Number_of_Points=" + str(Number_of_Points)) if (Number_of_Edges == 1) and (Number_of_Points) == 1 : Point_List = SelectedObjects[3] Edge_List = SelectedObjects[4] - #print_msg(str(Point_List)) - #print_msg(str(Edge_List)) + if msg != 0: + print_msg(str(Point_List)) + print_msg(str(Edge_List)) Vector_C = Point_List[0].Point Vector_A = Edge_List[0].valueAt( 0.0 ) Vector_B = Edge_List[0].valueAt( Edge_List[0].Length ) - - Vector_T, Distance, Vector_Tprime = intersecPerpendicularLine(Vector_A, Vector_B, Vector_C, info=0) - + + Vector_T, Distance, Vector_Tprime = intersecPerpendicularLine(Vector_A, Vector_B, Vector_C, info=msg) + print_msg("Distance from the Point to the Axis is : " + str(Distance) ) - + Axis_dir = Vector_C - Vector_T - Axis_E1 = Vector_C + Axis_E1 = Vector_C Axis_E2 = Vector_T - + if m_extensionLinePointAxis != 0.0: Axis_E1 = Vector_C + Axis_dir.normalize().multiply(m_extensionLinePointAxis) - if m_extensionLinePointAxis >= 0.0: + if m_extensionLinePointAxis >= 0.0: Axis_E2 = Vector_T - Axis_dir.normalize().multiply(m_extensionLinePointAxis) else: Axis_E2 = Vector_T + Axis_dir.normalize().multiply(m_extensionLinePointAxis) - + Axis_User_Name, axis = plot_axis(Axis_E1, Axis_E2, part, name) print_msg(str(Axis_User_Name) + result_msg ) else: - printError_msg(error_msg) + printError_msg(error_msg) except: printError_msg(error_msg) - - + + def plot_pointLineAxis(): """ Plot an Axis paralell to an other axis and passing trougth a Point. """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Parallel Axis : \nSelect one Point and one Line only !" result_msg = " : Paralell Axis created !" name = "Parallel Line" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] @@ -1750,12 +2469,12 @@ def plot_pointLineAxis(): Vector_Translate = (Vector_Cprime - Vector_C) Vector_Aprime = Vector_A + Vector_Translate Vector_Bprime = Vector_B + Vector_Translate - + Axis_User_Name, axis = plot_axis(Vector_Aprime, Vector_Bprime, part, name) print_msg(str(Axis_User_Name) + result_msg ) else: - printError_msg(error_msg) + printError_msg(error_msg) except: printError_msg(error_msg) @@ -1763,12 +2482,13 @@ def plot_pointLineAxis(): def plot_linePlaneAxis(): """ Plot an Axis on a Plane by projection from another Axis. """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create projection Axis onto a Plane : \nSelect one Plane and one Line !" result_msg = " : Projection Axis onto a Plane created !" name = "Line" - part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + part = "Part::Feature" + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Edges = SelectedObjects[1] @@ -1787,39 +2507,40 @@ def plot_linePlaneAxis(): # Projection of A and B onto the Plane Aprime and Bprime Vector_A = Point_A + Plane_Normal Vector_B = Point_B + Plane_Normal - + Point_Aprime = intersecLinePlane(Point_A, Vector_A, Plane_Normal, Plane_Point, info=0) Point_Bprime = intersecLinePlane(Point_B, Vector_B, Plane_Normal, Plane_Point, info=0) # Plot them plot_point(Point_Aprime, part, "PointFacePoint") plot_point(Point_Bprime, part, "PointFacePoint") Axis_User_Name, axis = plot_axis(Point_Aprime, Point_Bprime, part, name) - + print_msg(str(Axis_User_Name) + result_msg ) - else: - printError_msg(error_msg) + else: + printError_msg(error_msg) except: printError_msg(error_msg) - + def plot_clickForAxis(): - """ Plot an axis at location of 2 mouse clicks.. + """ Plot an axis at location of 2 mouse clicks.. """ global m_callback #print_msg("plot_clickForAxis" ) view = Gui.ActiveDocument.ActiveView m_callback = view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),getClickedAxis) - -def plot_twoPlanesAxis(): + +def plot_2PlanesAxis(): """ Plot the intersection Axis between two planes. """ + msg=0 createFolders('WorkAxis') error_msg = "Unable to create Axis between 2 Planes : \nSelect two Planes not parallel !" result_msg = " : Axis between 2 Planes created !" name = "Line" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=0) m_xmax, m_xmin, m_ymax, m_ymin, m_zmax, m_zmin = minMaxObjectsLimits(m_objs,info=0) try: @@ -1840,7 +2561,7 @@ def plot_twoPlanesAxis(): Plane_Point2 = Selected_Plane2.CenterOfMass #print_point(Plane_Point1 , msg="Plane_Point1 : ") #print_point(Plane_Point2 , msg="Plane_Point2 : ") - + Axis_dir = intersecPlanePlane(Plane_Normal1, Plane_Point1, Plane_Normal2, Plane_Point2, info=0) #print_point(Axis_dir , msg="Axis_dir : ") @@ -1853,26 +2574,26 @@ def plot_twoPlanesAxis(): Vertx = [] Vertx.append(App.Vector(0.0, 0.0, 0.0)) Vertx.append(App.Vector(0.0, 0.0, 0.0)) - + min_val, max_val = init_min_max() dist_to_center_min = max_val - # For the first plane look after all edges and look at + # For the first plane look after all edges and look at # intersections of the edges with the second plane for j in range(Number_of_Edges): A = Selected_Plane1.Edges[j].valueAt( 0.0 ) B = Selected_Plane1.Edges[j].valueAt(Selected_Plane1.Edges[j].Length ) #print_point(A , msg="A : ") #print_point(B , msg="B : ") - T = intersecLinePlane(A, B, Plane_Normal2, Plane_Point2, info=0) + T = intersecLinePlane(A, B, Plane_Normal2, Plane_Point2, info=0) if T != None: print_point(T , msg="T : ") - D = T - Plane_Point1 - dist_to_center = math.sqrt(D.dot(D)) + D = T - Plane_Point1 + dist_to_center = math.sqrt(D.dot(D)) #print_msg("D=" + str(D)) #print_msg("dist_to_center=" + str(dist_to_center)) if dist_to_center < dist_to_center_min: dist_to_center_min = dist_to_center - Vertx[0] = T + Vertx[0] = T #Center_User_Name = plot_point(Vertx[0], part, name) #print_msg("Selected_Plane2=" + str(Selected_Plane2)) #print_msg("Selected_Plane2.Edges=" + str(Selected_Plane2.Edges)) @@ -1893,38 +2614,44 @@ def plot_twoPlanesAxis(): #print_msg("dist_to_center=" + str(dist_to_center)) if dist_to_center < dist_to_center_min: dist_to_center_min = dist_to_center - Vertx[1] = T + Vertx[1] = T #Center_User_Name = plot_point(Vertx[1], part, name) #print_msg("Selected_Points=" + str(Vertx)) #Number_of_Points = len(Vertx) - #print_msg("Number_of_Points=" + str(Number_of_Points)) - C = centerVectorsPoint(Vertx,info=0) + #print_msg("Number_of_Points=" + str(Number_of_Points)) + #C = centerBBVectorsPoint(Vertx,info=0) + C = meanVectorsPoint(Vertx,info=1) #print_point(C , msg="C : ") if C != None: extension = m_xmax - m_xmin if extension < m_ymax - m_ymin: - extension = m_ymax - m_ymin + extension = m_ymax - m_ymin if extension < m_zmax - m_zmin: extension = m_zmax - m_zmin extension = extension/2 A = C - Axis_dir.normalize().multiply(extension*1.3) - B = C + Axis_dir.normalize().multiply(extension*1.3) + B = C + Axis_dir Axis_User_Name, axis = plot_axis(A, B, part, name) print_msg(str(Axis_User_Name) + result_msg ) else: printError_msg(error_msg) - + except: - printError_msg(error_msg) - + printError_msg(error_msg) + def plot_baseObjectAxes(): + msg=0 createFolders('Origin') error_msg = "Unable to create Axes : \nSelect at least one object !" result_msg = " : Axes created !" - m_actDoc = get_ActiveDocument(info=0) + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: + return None + # Return a list of SelectionObjects for a given document name. m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) m_objs = [selobj.Object for selobj in m_selEx] @@ -1933,7 +2660,7 @@ def plot_baseObjectAxes(): printError_msg(error_msg) return CommonCenter = centerObjectsPoint(m_objs,info=1) - for m_i in range(0,m_num): + for m_i in range(0,m_num): m_base = m_objs[m_i].Placement.Base print_msg("Base =" + str(m_base)) print_msg("Center=" + str(CommonCenter)) @@ -1946,7 +2673,7 @@ def plot_baseObjectAxes(): AX_Length = 10. PX_A = Base.Vector(AX_Length, 0, 0) PX_B = Base.Vector(-AX_Length, 0, 0) - Axis_X = Part.makeLine(m_base+PX_A, m_base+PX_B) + Axis_X = Part.makeLine(m_base+PX_A, m_base+PX_B) Axis = App.ActiveDocument.addObject("Part::Feature","X_Axis") Axis.Shape = Axis_X App.ActiveDocument.getObject("WorkAxis").addObject(Axis) @@ -1990,87 +2717,259 @@ def plot_baseObjectAxes(): else: printError_msg(error_msg) -def plot_plane(Edge_Length1, Edge_Length2, Plane_Point, Plane_Normal, part, name, grp="WorkPlanes"): - if not(App.ActiveDocument.getObject( grp )): - App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) - plane = App.ActiveDocument.addObject(part, name) - - Plane_face = Part.makePlane( Edge_Length1, Edge_Length2, Plane_Point, Plane_Normal ) - Plane_Center = Plane_face.CenterOfMass - Plane_Translate = Plane_Point - Plane_Center - Plane_face.translate( Plane_Translate ) - plane.Shape = Plane_face - - App.ActiveDocument.getObject( grp ).addObject( plane ) - plane_User_Name = plane.Label - Gui.ActiveDocument.getObject( plane_User_Name ).PointColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( plane_User_Name ).LineColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( plane_User_Name ).ShapeColor = (0.00,0.33,1.00) - Gui.ActiveDocument.getObject( plane_User_Name ).Transparency = 75 - return plane_User_Name, plane +def radiusCircle(value): + """ Respond to the change in radius value from the text box. + """ + try: + # First we check if a valid number have been entered + global m_radiusCircle + if str(value) == '-': + return + m_radiusCircle = float(value) + print_msg("New extension is :" + str(m_radiusCircle)) + except ValueError: + printError_msg("Extension must be valid number !") -def plot_threePointsPlane(): +def plot_linecenterCircle(): + """Select an Axis and a Point to create a Circle + centered on the Point, perpendicular to the Axis + with the given radius. + """ + msg=0 + global m_radiusCircle + createFolders('WorkCircles') + error_msg = "Unable to create a Circle : \nSelect one Edge and one Point only!" + result_msg = " : Circle centered on a Point created !" + name = "Circle" + part = "Part::Feature" + grp = "WorkCircles" + Selection = get_SelectedObjects(info=msg, printError=False) + + try: + SelectedObjects = Selection + Number_of_Points = SelectedObjects[0] + Number_of_Edges = SelectedObjects[1] + if msg != 0: + print_msg("Number_of_Edges=" + str(Number_of_Edges) + + " Number_of_Points=" + str(Number_of_Points)) + if (Number_of_Edges == 1) and (Number_of_Points) == 1 : + Point_List = SelectedObjects[3] + Edge_List = SelectedObjects[4] + if msg != 0: + print_msg(str(Point_List)) + print_msg(str(Edge_List)) + Vector_C = Point_List[0].Point + Vector_A = Edge_List[0].valueAt( 0.0 ) + Vector_B = Edge_List[0].valueAt( Edge_List[0].Length ) + Vector_dir = (Vector_B - Vector_A) + + Circle_User_Name, circle = plot_circle(m_radiusCircle, Vector_C, Vector_dir, part, name, grp) + print_msg(str(Circle_User_Name) + result_msg ) + else: + printError_msg(error_msg) + except: + printError_msg(error_msg) + + +def plot_linepointCircle(): + """Select an Axis and a Point to create a Circle + centered on the Axis and tangenting the Point. + """ + msg=0 + createFolders('WorkCircles') + error_msg = "Unable to create a Circle : \nSelect one Edge and one Point only!" + result_msg = " : Circle tangented to a Point created !" + name = "Circle" + part = "Part::Feature" + grp = "WorkCircles" + Selection = get_SelectedObjects(info=msg, printError=False) + try: + SelectedObjects = Selection + Number_of_Points = SelectedObjects[0] + Number_of_Edges = SelectedObjects[1] + if msg != 0: + print_msg("Number_of_Edges=" + str(Number_of_Edges) + + " Number_of_Points=" + str(Number_of_Points)) + if (Number_of_Edges == 1) and (Number_of_Points) == 1 : + Point_List = SelectedObjects[3] + Edge_List = SelectedObjects[4] + if msg != 0: + print_msg(str(Point_List)) + print_msg(str(Edge_List)) + Vector_C = Point_List[0].Point + Vector_A = Edge_List[0].valueAt( 0.0 ) + Vector_B = Edge_List[0].valueAt( Edge_List[0].Length ) + Vector_dir = (Vector_B - Vector_A) + + Vector_T, Distance, Vector_Tprime = intersecPerpendicularLine(Vector_A, Vector_B, Vector_C, info=msg) + + Circle_User_Name, circle = plot_circle(Distance, Vector_T, Vector_dir, part, name, grp) + print_msg(str(Circle_User_Name) + result_msg ) + + else: + printError_msg(error_msg) + except: + printError_msg(error_msg) + + +def plot_3pointsCircle(): + """Select 3 Points to create a Circle. + """ + msg=0 + createFolders('WorkCircles') + error_msg = "Unable to create a Circle : \nSelect 3 Points only!" + result_msg = " : Circle from 3 points created !" + name = "Circle" + part = "Part::Feature" + grp = "WorkCircles" + Selection = get_SelectedObjects(info=msg, printError=False) + try: + SelectedObjects = Selection + Number_of_Points = SelectedObjects[0] + if Number_of_Points == 3: + Point_List = SelectedObjects[3] + + P1 = Point_List[0].Point + P2 = Point_List[1].Point + P3 = Point_List[2].Point + + l = ((P1 - P2).cross(P2 - P3)).Length + + P1P2 = (P2 - P1).Length + P2P3 = (P3 - P2).Length + P3P1 = (P1 - P3).Length + r=0.0 + try: + # Circle radius. + r = P1P2 * P2P3 * P3P1 / 2 / l + except: + printError_msg("The three points are aligned !") + else: + # Normal + Vector1 = P2 - P1 + Vector2 = P3 - P1 + V_Normal = Vector1.cross( Vector2 ) + # Sphere center. + a = P2P3**2 * (P1 - P2).dot(P1 - P3) / 2 / l**2 + b = P3P1**2 * (P2 - P1).dot(P2 - P3) / 2 / l**2 + c = P1P2**2 * (P3 - P1).dot(P3 - P2) / 2 / l**2 + P1.multiply(a) + P2.multiply(b) + P3.multiply(c) + Center = P1 + P2 + P3 + + Circle_User_Name, circle = plot_circle(r, Center, V_Normal, part, name, grp ) + print_msg(str(Circle_User_Name) + result_msg + "radius = " + str(r)) + else: + printError_msg(error_msg) + except: + printError_msg(error_msg) + + +def plot_3pointsEllipse(): + """Select a center and 2 Points to create an Ellipse. + """ + msg=0 + createFolders('WorkCircles') + error_msg = "Unable to create a Ellipse : \nSelect one Center and 2 Points only!" + result_msg = " : Ellipse from 3 points created !" + name = "Ellipse" + part = "Part::Feature" + grp = "WorkCircles" + Selection = get_SelectedObjects(info=msg, printError=False) + try: + SelectedObjects = Selection + Number_of_Points = SelectedObjects[0] + if (Number_of_Points == 3): + Point_List = SelectedObjects[3] + if msg != 0: + print_msg(str(Point_List)) + P1 = Point_List[0].Point + Center = P1 + P2 = Point_List[1].Point + P3 = Point_List[2].Point + if msg != 0: + print_point(Center,"Center = :") + print_point(P2,"P2 = :") + print_point(P3,"P3 = :") + + Ellipse_User_Name, ellipse = plot_ellipse(P2, P3, Center, part, name, grp) + print_msg(str(Ellipse_User_Name) + result_msg ) + else: + printError_msg(error_msg) + except: + printError_msg(error_msg) + + +def plot_3PointsPlane(): """ Create a Plane from 3 Points. """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Plane : \nSelect three points only !" result_msg = " : Plane created !" name = "WorkPlane" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: - SelectedObjects = Selection + SelectedObjects = Selection Number_of_Points = SelectedObjects[0] - #print_msg("Number_of_Points=" + str(Number_of_Points)) + if msg != 0: + print_msg("Number_of_Points=" + str(Number_of_Points)) points = [] if Number_of_Points == 3 : Point_List = SelectedObjects[3] - #print_msg(str(Points_List)) + if msg != 0: + print_msg(str(Points_List)) + Point_A = Point_List[0].Point points.append(Point_A) Point_B = Point_List[1].Point points.append(Point_B) Point_C = Point_List[2].Point points.append(Point_C) - #print_point(Point_A, msg="Point_A : ") - #print_point(Point_B, msg="Point_B : ") - #print_point(Point_C, msg="Point_C : ") - - Vector_Center = centerVectorsPoint(points, info=0) + if msg != 0: + print_point(Point_A, msg="Point_A : ") + print_point(Point_B, msg="Point_B : ") + print_point(Point_C, msg="Point_C : ") + + Vector_Center = meanVectorsPoint(points,info=msg) + #Vector_Center = centerBBVectorsPoint(points, info=0) xmax, xmin, ymax, ymin, zmax, zmin = minMaxVectorsLimits(points,info=0) #print_point(Vector_Center, msg="Center of A, B and C : ") - + length = xmax - xmin if (ymax - ymin) > length: length = ymax - ymin if (zmax - zmin) > length: length = zmax - zmin print_msg("length = " +str(length)) - + Edge_Vector = Point_B - Point_A #Edge_Length = Edge_Vector.Length Edge_Length = length * 1.5 AC_Vector = Point_C - Point_A Plane_Point = Vector_Center Plane_Normal = Edge_Vector.cross( AC_Vector ) - + Plane_User_Name, plane = plot_plane(Edge_Length, Edge_Length, Plane_Point, Plane_Normal, part, name) print_msg(str(Plane_User_Name) + result_msg ) except: printError_msg(error_msg) - + def plot_axisPointPlane(): """ Create a plane passing trougth a Line and a Point. """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Plane : \nSelect one Line and one Point only !" result_msg = " : Plane created !" name = "WorkPlane" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] @@ -2091,24 +2990,25 @@ def plot_axisPointPlane(): #print_point(Point_A, msg="Point_A : ") #print_point(Point_B, msg="Point_B : ") #print_point(Point_C, msg="Point_C : ") - - Vector_Center = centerVectorsPoint(points, info=0) + + #Vector_Center = centerBBVectorsPoint(points, info=0) + Vector_Center = meanVectorsPoint(points,info=0) xmax, xmin, ymax, ymin, zmax, zmin = minMaxVectorsLimits(points,info=0) #print_point(Vector_Center, msg="Center of A, B and C : ") - + length = xmax - xmin if (ymax - ymin) > length: length = ymax - ymin if (zmax - zmin) > length: length = zmax - zmin print_msg("length = " +str(length)) - + Edge_Vector = Point_B - Point_A Edge_Length = length * 1.5 AC_Vector = Point_C - Point_A Plane_Point = Vector_Center Plane_Normal = Edge_Vector.cross( AC_Vector ) - + Plane_User_Name, plane = plot_plane(Edge_Length, Edge_Length, Plane_Point, Plane_Normal, part, name) print_msg(str(Plane_User_Name) + result_msg ) else: @@ -2116,17 +3016,19 @@ def plot_axisPointPlane(): except: printError_msg(error_msg) + def plot_perpendicularAxisPointPlane(): """ Create a Plane perpendicular to a Line a crossing a Point. - """ + """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Plane : \nSelect one Line and one point only !" result_msg = " : Plane created !" name = "WorkPlane" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: - SelectedObjects = Selection + SelectedObjects = Selection Number_of_Points = SelectedObjects[0] Number_of_Edges = SelectedObjects[1] #print_msg("Number_of_Points=" + str(Number_of_Points) + " Number_of_Edges=" + str(Number_of_Edges)) @@ -2140,7 +3042,7 @@ def plot_perpendicularAxisPointPlane(): #print_point(Vector_B, msg="Vector_B : ") #print_point(Vector_C, msg="Vector_C : ") # Intersection point T on a Line given one Line and One Point C. - if colinearVectors(Vector_A, Vector_B, Vector_C, info=1): + if colinearVectors(Vector_A, Vector_B, Vector_C, info=1): Vector_T = Vector_C Distance = Edge_List[0].Length else: @@ -2149,16 +3051,16 @@ def plot_perpendicularAxisPointPlane(): Plane_Normal = Vector_B - Vector_A Plane_Point = Vector_T + (Vector_C - Vector_T).multiply(0.5) Edge_Length = Distance * 1.5 - + Plane_User_Name, plane = plot_plane(Edge_Length, Edge_Length, Plane_Point, Plane_Normal, part, name) print_msg(str(Plane_User_Name) + result_msg ) - except: + except: printError_msg(error_msg) - - + + def extensionPlanePointPlane(value): """ Respond to the change in extension value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_extensionPlanePointPlane @@ -2168,17 +3070,18 @@ def extensionPlanePointPlane(value): print_msg("New extension is :" + str(m_extensionPlanePointPlane)) except ValueError: printError_msg("Extension must be valid number !") - - + + def plot_planePointPlane(): """ Create a plane passing through a Point and parallel to a given Plane. - """ + """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Plane : \nSelect one Plane and one Point only !" result_msg = " : Plane created !" name = "WorkPlane" part = "Part::Feature" - Selection = get_SelectedObjects() + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection Number_of_Points = SelectedObjects[0] @@ -2188,24 +3091,24 @@ def plot_planePointPlane(): Points_List = SelectedObjects[3] Plane_List = SelectedObjects[5] #print_msg(str(Points_List)) - #print_msg(str(Plane_List)) + #print_msg(str(Plane_List)) Point_C = Points_List[0].Point Reference_Plane = Plane_List[0] Edge_Length = Reference_Plane.Length / 4.0 + m_extensionPlanePointPlane Plane_Normal = Reference_Plane.normalAt(0,0) Plane_Point = Point_C - + Plane_User_Name, plane = plot_plane(Edge_Length, Edge_Length, Plane_Point, Plane_Normal, part, name) print_msg(str(Plane_User_Name) + result_msg ) else: - printError_msg(error_msg) + printError_msg(error_msg) except: - printError_msg(error_msg) + printError_msg(error_msg) def anglePlaneAxisPlane(value): """ Respond to the change in angle value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_anglePlaneAxisPlane @@ -2218,15 +3121,16 @@ def anglePlaneAxisPlane(value): def plot_planeAxisPlane(): - """ Use a plane and a line to create Plane perpedicular + """ Use a plane and a line to create Plane perpedicular to the first Plane and crossing the Line """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Planes : \nSelect one Line and one Plane only !" result_msg = " : Plane created !" name = "WorkPlane" part = "Part::Feature" - Selection = get_SelectedObjects(info=0) + Selection = get_SelectedObjects(info=msg, printError=False) try: SelectedObjects = Selection #Number_of_Points = SelectedObjects[0] @@ -2247,24 +3151,24 @@ def plot_planeAxisPlane(): # Projection of A and B onto the Plane Aprime and Bprime Vector_A = Point_A + Plane_Normal Vector_B = Point_B + Plane_Normal - + Point_Aprime = intersecLinePlane(Point_A, Vector_A, Plane_Normal, Plane_Point, info=0) Point_Bprime = intersecLinePlane(Point_B, Vector_B, Plane_Normal, Plane_Point, info=0) # Plot them #plot_point(Point_Aprime, part, "PointFacePoint") #plot_point(Point_Bprime, part, "PointFacePoint") #plot_axis(Point_Aprime, Point_Bprime, part, "Line from 2 Points") - + Edge_Vector = Point_Bprime - Point_Aprime Edge_Length = Edge_List[0].Length * 1.3 - + Point_MidPoint = Point_Bprime + Point_Aprime - Point_MidPoint = Point_MidPoint.multiply(0.5) - + Point_MidPoint = Point_MidPoint.multiply(0.5) + Vector_Normal = Edge_Vector.cross(Plane_Normal) - + Plane_User_Name, plane = plot_plane(Edge_Length, Edge_Length, Point_MidPoint, Vector_Normal, part, name) - + print_msg("New plane is :" + str(plane)) if m_anglePlaneAxisPlane != 0.0: rot_angle = m_anglePlaneAxisPlane @@ -2274,24 +3178,24 @@ def plot_planeAxisPlane(): print_msg("rotation = " + str(m_rot)) print_msg("rotation axis = " + str(rot_axis)) m_place = App.Placement(plane.Placement) - m_base1 = m_place.Base + m_base1 = m_place.Base print_msg("base1 = " + str(m_base1)) m_rot1 = m_place.Rotation print_msg("rot1 = " + str(m_rot1)) m_rot = m_rot.multiply(m_rot1) m_newplace = App.Placement(m_base1,m_rot,m_center-m_base1) plane.Placement = m_newplace - + print_msg(str(Plane_User_Name) + result_msg ) - else: - printError_msg(error_msg) + else: + printError_msg(error_msg) except: printError_msg(error_msg) def lengthPlane(value): """ Respond to the change in Plane length value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_lengthPlane @@ -2305,7 +3209,7 @@ def lengthPlane(value): def widthPlane(value): """ Respond to the change in Plane length value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_widthPlane @@ -2317,18 +3221,26 @@ def widthPlane(value): printError_msg("Plane length must be valid number !") +def plot_faceTangentPlane(): + """Create a tanget Plane at click location of a Face. + """ + global m_callback + view = Gui.ActiveDocument.ActiveView + m_callback = view.addEventCallback("SoMouseButtonEvent",getClickedTangent) + + def plot_clickForPlane(): - """ Create a Plane at location of one mouse click in the view or + """ Create a Plane at location of one mouse click in the view or onto a clicked object or at a pre-selected point location. """ + msg=0 createFolders('WorkPlanes') - - m_actDoc=get_ActiveDocument(info=1) - if m_actDoc == None: - printError_msg("No Active document selected !") + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc.Name == None: return None - + m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) if len(m_selEx) >= 1: SelectedObjects = get_SelectedObjects(info=1) @@ -2342,34 +3254,34 @@ def plot_clickForPlane(): # Set the base of the plane at location of mouse click Plane_Point = Point_List[-1].Point # Create a Plane - Plane_User_Name, plane = plot_plane(m_lengthPlane, m_widthPlane, Plane_Point, Plane_Normal, part, name) + Plane_User_Name, plane = plot_plane(m_lengthPlane, m_widthPlane, Plane_Point, Plane_Normal, part, name) else: printError_msg("Either select first one Point and Click the button or \n" + "Click the button and one free mouse click in the view or" + - "Click the button and one mouse click on an object of the view !") + "Click the button and one mouse click on an object of the view !") else: - global m_callback + global m_callback #view = Gui.ActiveDocument.ActiveView view = get_ActiveView() #m_callback = view.addEventCallbackPivy(SoMouseButtonEvent.getClassTypeId(),getClickedPlane) m_callback = view.addEventCallback("SoMouseButtonEvent",getClickedPlane2) - + def plot_centerObjectPlanes(): """ Create 3 Planes XY, YZ and XZ at center point of all selected objects. """ + msg=0 createFolders('WorkPlanes') error_msg = "Unable to create Planes : \nSelect at least one objec !" result_msg = " : Planes created !" - m_actDoc=App.activeDocument() - message = "Active Document is : " + str(m_actDoc.Name) - print_msg(message) + + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc.Name == None: - printError_msg("No Active document selected !") return None + Line_Color = (1.00,0.33,0.00) Shape_Color = (0.00,1.00,0.50) - Transparency = 75 + Transparency = 75 # Return a list of SelectionObjects for a given document name. m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) m_objs = [selobj.Object for selobj in m_selEx] @@ -2380,7 +3292,7 @@ def plot_centerObjectPlanes(): Center = centerObjectsPoint(m_objs) if Center != None: xmax, xmin, ymax, ymin, zmax, zmin = minMaxObjectsLimits(m_objs, info=1) - + # Work-PlaneXY if xmax != xmin: PXY_A_SIZE = (xmax - xmin)*1.3 @@ -2455,12 +3367,13 @@ def plot_centerObjectPlanes(): Gui.ActiveDocument.getObject(PlaneYZ_User_Name).Transparency = Transparency Gui.ActiveDocument.getObject(PlaneYZ_User_Name).Visibility=True #Gui.ActiveDocument.getObject("YZ_WPlane").Visibility=True - print_msg(str(PlaneYZ_User_Name) + result_msg ) + print_msg(str(PlaneYZ_User_Name) + result_msg ) else: printError_msg(error_msg) -def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info=0): - """ returns 8 points ,12 edges and 6 planes from the bounding box + +def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info=0,plot=0): + """ Returns 8 points ,12 edges and 6 planes from the bounding box """ m_l_X = length_X m_l_Y = length_Y @@ -2471,56 +3384,24 @@ def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info= Points = [] Edges = [] Faces = [] - + Points.append(App.Vector(m_o_X,m_o_Y ,m_o_Z )) Points.append(App.Vector(m_o_X,m_o_Y+m_l_Y,m_o_Z )) Points.append(App.Vector(m_o_X,m_o_Y ,m_o_Z+m_l_Z )) Points.append(App.Vector(m_o_X,m_o_Y+m_l_Y,m_o_Z+m_l_Z )) - + Points.append(App.Vector(m_o_X+m_l_X,m_o_Y ,m_o_Z )) Points.append(App.Vector(m_o_X+m_l_X,m_o_Y+m_l_Y,m_o_Z )) Points.append(App.Vector(m_o_X+m_l_X,m_o_Y ,m_o_Z+m_l_Z)) Points.append(App.Vector(m_o_X+m_l_X,m_o_Y+m_l_Y,m_o_Z+m_l_Z)) - -# Part.Point() -# myVertex = myShape.Vertexes[0] -# print myVertex.Point -# > Vector (3, 2, 0) -# vec1 = Base.Vector(0,0,0) -# vec2 = Base.Vector(10,0,0) -# line = Part.Line(vec1,vec2) -# edge = line.toShape() -# -# edge1 = Part.makeLine((0,0,0), (10,0,0)) -# edge2 = Part.makeLine((10,0,0), (10,10,0)) -# wire1 = Part.Wire([edge1,edge2]) -# wire3.Length -# > 40.0 -# wire3.CenterOfMass -# > Vector (5, 5, 0) -# wire3.isClosed() -# > True -# wire2.isClosed() -# > False -# face = Part.Face(wire3) -# face.Area -# > 99.999999999999972 -# face.CenterOfMass -# > Vector (5, 5, 0) -# face.Length -# > 40.0 -# face.isValid() -# > True -# sface = Part.Face(wire2) -# face.isValid() -# > False - + m_list_of_edges = [ ( 0, 1), ( 1, 3), ( 3, 2), ( 2, 0), ( 4, 5), ( 5, 7), ( 7, 6), ( 6, 4), ( 0, 4), ( 1, 5), ( 3, 7), ( 2, 6) ] for i in m_list_of_edges: - print_msg( str(i) ) + if info != 0: + print_msg( str(i) ) line = Part.Line(Points[i[0]], Points[i[1]]) edge = line.toShape() wire = Part.Wire([edge]) @@ -2529,30 +3410,17 @@ def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info= mid_point = wire.CenterOfMass length = wire.Length Edges.append( ( i[0], i[1], (Points[i[0]], Points[i[1]]), edge, mid_point, length ) ) -# -# Edges.append( ( 0, 1, (Points[0], Points[1]) ) ) -# Edges.append( ( 1, 3, (Points[1], Points[3]) ) ) -# Edges.append( ( 3, 2, (Points[3], Points[2]) ) ) -# Edges.append( ( 2, 0, (Points[2], Points[0]) ) ) -# -# Edges.append( ( 4, 5, (Points[4], Points[5]) ) ) -# Edges.append( ( 5, 7, (Points[5], Points[7]) ) ) -# Edges.append( ( 7, 6, (Points[7], Points[6]) ) ) -# Edges.append( ( 6, 4, (Points[6], Points[4]) ) ) -# -# Edges.append( ( 0, 4, (Points[0], Points[4]) ) ) -# Edges.append( ( 1, 5, (Points[1], Points[5]) ) ) -# Edges.append( ( 3, 7, (Points[3], Points[7]) ) ) -# Edges.append( ( 2, 6, (Points[2], Points[6]) ) ) + m_list_of_faces = [ (2, 11, 6, 10), (0, 8, 4, 9), (3, 8, 7, 11), (1, 9, 5, 10), (7, 4, 5, 6), (3, 0, 1, 2) ] - + for i in m_list_of_faces: - print_msg( str(i) ) + if info != 0: + print_msg( str(i) ) wire = Part.Wire([Edges[i[0]][3], Edges[i[1]][3], Edges[i[2]][3], Edges[i[3]][3] ]) if wire.isClosed(): face = Part.Face(wire) @@ -2560,8 +3428,9 @@ def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info= length = face.Length if info != 0: Part.show(face) - Faces.append( ( i[0], i[1], i[2], i[3], (Edges[i[0]][3],Edges[i[1]][3],Edges[i[2]][3],Edges[i[3]][3]), face, mid_point, length ) ) - + Faces.append( ( i[0], i[1], i[2], i[3], (Edges[i[0]][3],Edges[i[1]][3],Edges[i[2]][3],Edges[i[3]][3]), face, mid_point, length ) ) + + # Print info if needed if info != 0: for m_i in range(len(Points)): print_point(Points[m_i], msg="Point_" + str(m_i) + " : ") @@ -2570,114 +3439,20 @@ def get_all_from_bounding_box(ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info= for m_i in range(len(Faces)): print_msg("face : " + str(Faces[m_i])) + # Plot them if needed + if plot != 0: + for m_i in range(len(Points)): + plot_point(Points[m_i], "Part::Feature", "point") + for m_i in range(len(Edges)): + #( 2, 6, (Points[2], Points[6]), edge, mid_point, length ) + plot_axis(Edges[m_i][2][0], Edges[m_i][2][1], "Part::Feature", "axis") + #for m_i in range(len(Faces)): + # ( 3, 0, 1, 2, (Edges[3][3],Edges[0][3],Edges[1][3],Edges[2][3]), face, mid_point, length ) + #print_msg("face : " + str(Faces[m_i])) + return Points, Edges, Faces - -def bounding_box(grp,ori_X,ori_Y,ori_Z,length_X,length_Y,length_Z,info=0): - """ Create a bounding box. - """ - m_grp = grp - m_l_X = length_X - m_l_Y = length_Y - m_l_Z = length_Z - m_o_X = ori_X - m_o_Y = ori_Y - m_o_Z = ori_Z - global flag_for_face - flag_for_face = True - - if info != 0: - print_msg("Xmin, Ymin, Zmin : \n" + - str(m_o_X) + " , " + str(m_o_Y) + " , " + str(m_o_Z)) - print_msg("Lengths m_l_X , m_l_Y , m_l_Z : \n" + - str(m_l_X) + " , " + str(m_l_Y) + " , " + str(m_l_Z)) - - if (m_l_X != 0.0) and (m_l_Y != 0.0): - try: - m_pl_0 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), - App.Rotation(0.0,0.0,0.0)) - m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Y, - placement=m_pl_0,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 0 not done !") - try: - m_pl_1 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z+m_l_Z), - App.Rotation(0.0,0.0,0.0)) - m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Y, - placement=m_pl_1,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 1 not done !") - - if (m_l_X != 0.0) and (m_l_Z != 0.0): - try: - m_pl_2 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), - App.Rotation(0.0,0.0,90)) - m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Z, - placement=m_pl_2,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 2 not done !") - try: - m_pl_3 = App.Placement(App.Vector(m_o_X,m_o_Y+m_l_Y,m_o_Z), - App.Rotation(0.0,0.0,90)) - m_rect = Draft.makeRectangle(length=m_l_X,height=m_l_Z, - placement=m_pl_3,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 3 not done !") - - if (m_l_Y != 0.0) and (m_l_Z != 0.0): - try: - m_pl_4 = App.Placement(App.Vector(m_o_X,m_o_Y,m_o_Z), - App.Rotation(90,0.0,90)) - m_rect = Draft.makeRectangle(length=m_l_Y,height=m_l_Z, - placement=m_pl_4,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 4 not done !") - try: - m_pl_5 = App.Placement(App.Vector(m_o_X+m_l_X,m_o_Y,m_o_Z), - App.Rotation(90,0.0,90)) - m_rect = Draft.makeRectangle(length=m_l_Y,height=m_l_Z, - placement=m_pl_5,face=flag_for_face,support=None) - addObjectToGrp(m_rect,m_grp,info=info) - definePropOfActiveObj() - except: - printError_msg("Rectangle 5 not done !") - - #if (m_l_X != 0.0) and (m_l_Y != 0.0) and (m_l_Z != 0.0): - try: - if (m_l_X == 0.0): - m_l_X = 0.5 - m_o_X = m_o_X - 0.25 - if (m_l_Y == 0.0): - m_l_Y = 0.5 - m_o_Y = m_o_Y - 0.25 - if (m_l_Z == 0.0): - m_l_Z = 0.5 - m_o_Z = m_o_Z - 0.25 - m_pnt = App.Vector(m_o_X ,m_o_Y,m_o_Z) - print_point(m_pnt, msg="m_pnt") - # adds object to the document group - box = App.ActiveDocument.addObject("Part::Feature", "BBox") - #By default pnt=Vector(0,0,0) and dir=Vector(0,0,1) - Box_face = Part.makeBox(m_l_X,m_l_Y,m_l_Z,m_pnt) - #print_msg("Box_face :" + str(Box_face) ) - box.Shape = Box_face - m_grp.addObject( box ) - Gui.activeDocument().activeObject().Transparency = (50) - print_msg("Bounding Box created !") - except: - printError_msg("Bounding Box not created !") - - + def plot_boundingBoxes(): """Create bounding boxes around each of selected object(s). """ @@ -2685,19 +3460,18 @@ def plot_boundingBoxes(): createFolders('WorkBoxes') error_msg = "Select at least one object !" result_msg = "Bounding box created !" - - m_actDoc=get_ActiveDocument(info=msg) + + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc.Name == None: - printError_msg("No Active document selected !") return None - + # Return a list of SelectionObjects for a given document name. m_selEx = Gui.Selection.getSelectionEx(m_actDoc.Name) m_objs = [selobj.Object for selobj in m_selEx] m_objNames = [selobj.ObjectName for selobj in m_selEx] m_num = len(m_objs) if m_num >= 1: - if msg != 0: + if msg != 0: print_msg( str(m_num) + " object(s) selected :\n" + str(m_objNames) ) m_i = 0 for m_obj in m_objs: @@ -2733,7 +3507,7 @@ def plot_boundingBoxes(): m_actDoc.recompute() m_i = m_i +1 - + print_msg(result_msg) else: printError_msg(error_msg) @@ -2746,10 +3520,11 @@ def plot_boundingBox(): createFolders('WorkBoxes') error_msg = "Select at least one object !" result_msg = "Bounding box created !" - + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc == None: return + m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=msg) Center = centerObjectsPoint(m_objs) if Center != None: @@ -2760,8 +3535,8 @@ def plot_boundingBox(): except: printError_msg("Could not Create '"+ str(m_dir) +"' Objects Group!") m_grp = m_actDoc.getObject( m_obj.Name ) - #print_msg("m_grp = " + str(m_grp)) - m_xmax, m_xmin, m_ymax, m_ymin, m_zmax, m_zmin = minMaxObjectsLimits(m_objs,info=0) + #print_msg("m_grp = " + str(m_grp)) + m_xmax, m_xmin, m_ymax, m_ymin, m_zmax, m_zmin = minMaxObjectsLimits(m_objs,info=0) # Length of BoundBox in X, Y and Z dimensions m_length_X = m_xmax - m_xmin m_length_Y = m_ymax - m_ymin @@ -2772,43 +3547,14 @@ def plot_boundingBox(): bounding_box(m_grp,m_ori_X,m_ori_Y,m_ori_Z,m_length_X,m_length_Y,m_length_Z,info=msg) m_actDoc.recompute() print_msg(result_msg) - + else: - printError_msg(error_msg) - - -def plot_cylinder(radius, height, point, axis, part, name, grp="WorkObjects"): - """ Creating a Cylinder in the view. - One of the Cylinder's extremities will be at the given point location. - The Cylinder's axis will be along given axis - Function used : makeCylinder(radius,height,[pnt,axis,angle]). - By default pnt=Vector(0,0,0),axis=Vector(0,0,1) and angle=360 - """ - if not(App.ActiveDocument.getObject( grp )): - App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) - - cylinder = App.ActiveDocument.addObject(part, name) - - Cylinder = Part.makeCylinder( radius, abs(height), point, axis ) - Cylinder_Center = Cylinder.CenterOfMass - Cylinder_Translate = point - Cylinder_Center - Cylinder.translate( Cylinder_Translate ) - Cylinder_Translate = axis.normalize().multiply(height/2.) - Cylinder.translate( Cylinder_Translate ) - cylinder.Shape = Cylinder - - App.ActiveDocument.getObject( grp ).addObject( cylinder ) - cylinder_User_Name = cylinder.Label - Gui.ActiveDocument.getObject( cylinder_User_Name ).PointColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( cylinder_User_Name ).LineColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( cylinder_User_Name ).ShapeColor = (0.00,0.33,1.00) - Gui.ActiveDocument.getObject( cylinder_User_Name ).Transparency = 75 - return cylinder_User_Name, cylinder - + printError_msg(error_msg) + def diameterCylinder(value): """ Respond to the change in diameter value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_diameterCylinder @@ -2822,7 +3568,7 @@ def diameterCylinder(value): def lengthCylinder(value): """ Respond to the change in length value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_lengthCylinder @@ -2840,19 +3586,18 @@ def plot_axisPointCylinder(): """ msg=0 createFolders('WorkObjects') - error_msg = "Unable to create a Cylinder : \nSelect one Axis AND one point only!" + error_msg = "Unable to create a Cylinder : \nSelect one Axis and one point only!" result_msg = " : Cylinder created !" name = "Cylinder" - part = "Part::Feature" - m_actDoc=get_ActiveDocument(info=msg) + part = "Part::Feature" global m_diameterCylinder global m_lengthCylinder - + + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc.Name == None: - printError_msg("No Active document selected !") return None - - Selection = get_SelectedObjects(info=msg) + + Selection = get_SelectedObjects(info=msg, printError=False) if Selection == None: return None try: @@ -2875,7 +3620,7 @@ def plot_axisPointCylinder(): print_point(Vector_C, msg="Reference Point : ") print_point(Vector_A, msg="Point A : ") print_point(Vector_B, msg="Point B : ") - + Cyl_User_Name, cylinder = plot_cylinder(m_diameterCylinder, m_lengthCylinder, Vector_C, Vector_A - Vector_B, part, name) print_msg(str(Cyl_User_Name) + result_msg ) else: @@ -2883,40 +3628,10 @@ def plot_axisPointCylinder(): except: printError_msg(error_msg) - -def plot_cube(length, width, height, point, axis, part, name, grp="WorkObjects"): - """ Creating a Cube in the view. - One of the Cube's extremities will be at the given point location. - The Cube's axis will be along given axis - Function used : makeBox(length,width,height,[pnt,axis]). - By default pnt=Vector(0,0,0) and axis=Vector(0,0,1) - """ - if not(App.ActiveDocument.getObject( grp )): - App.ActiveDocument.addObject("App::DocumentObjectGroup", grp) - - cube = App.ActiveDocument.addObject(part, name) - - Cube = Part.makeBox(length, width, abs(height), point, axis ) - Cube_Center = Cube.CenterOfMass - Cube_Translate = point - Cube_Center - Cube.translate( Cube_Translate ) - Cube_Translate = axis.normalize().multiply(height/2.) - Cube.translate( Cube_Translate ) - cube.Shape = Cube - - App.ActiveDocument.getObject( grp ).addObject( cube ) - cube_User_Name = cube.Label - - Gui.ActiveDocument.getObject( cube_User_Name ).PointColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( cube_User_Name ).LineColor = (1.00,0.67,0.00) - Gui.ActiveDocument.getObject( cube_User_Name ).ShapeColor = (0.00,0.33,1.00) - Gui.ActiveDocument.getObject( cube_User_Name ).Transparency = 75 - return cube_User_Name, cube - - + def sectionCube(value): """ Respond to the change in lenght,width value from the text box. - """ + """ try: # First we check if a valid number have been entered print_msg(str(value)) @@ -2929,9 +3644,10 @@ def sectionCube(value): except ValueError: printError_msg("Lenght,width must be valid number !") + def heightCube(value): """ Respond to the change in heigth value from the text box. - """ + """ try: # First we check if a valid number have been entered global m_heightCube @@ -2941,28 +3657,27 @@ def heightCube(value): print_msg("New height is :" + str(m_heightCube )) except ValueError: printError_msg("Height must be valid number !") - - + + def plot_axisPointCube(): """ Plot a cube with axis aligned on the selected axis and with center at the selected point. """ msg=0 createFolders('WorkObjects') - error_msg = "Unable to create a Cube : \nSelect one Axis AND one point only!" + error_msg = "Unable to create a Cube : \nSelect one Axis and one point only!" result_msg = " : Cube created !" name = "Cuboid" - part = "Part::Feature" - m_actDoc=get_ActiveDocument(info=msg) + part = "Part::Feature" global m_lengthCube global m_widthCube global m_heightCube - + + m_actDoc = get_ActiveDocument(info=msg) if m_actDoc.Name == None: - printError_msg("No Active document selected !") return None - - Selection = get_SelectedObjects(info=msg) + + Selection = get_SelectedObjects(info=msg, printError=False) if Selection == None: return None try: @@ -2984,16 +3699,776 @@ def plot_axisPointCube(): if msg != 0: print_point(Vector_C, msg="Reference Point : ") print_point(Vector_A, msg="Point A : ") - print_point(Vector_B, msg="Point B : ") - + print_point(Vector_B, msg="Point B : ") + Cube_User_Name, cube = plot_cube(m_lengthCube, m_widthCube, m_heightCube, Vector_C, Vector_A - Vector_B, part, name) - print_msg(str(Cube_User_Name) + result_msg ) + print_msg(str(Cube_User_Name) + result_msg ) else: printError_msg(error_msg) except: + printError_msg(error_msg) + + +def angleCutObject(value): + """ Respond to the change in angle value from the text box. + """ + try: + # First we check if a valid number have been entered + global m_angleCutObject + if str(value) == '-': + return + m_angleCutObject = float(value) + print_msg("New angle in degrees is :" + str(m_angleCutObject)) + except ValueError: + printError_msg("Angle must be valid number !") + + +def thicknessCutObject(value): + """ Respond to the change in extension value from the text box. + """ + try: + # First we check if a valid number have been entered + global m_thicknessCutObject + if str(value) == '-': + return + m_thicknessCutObject = float(value) + print_msg("New thickness is :" + str(m_thicknessCutObject)) + except ValueError: + printError_msg("Thickness must be valid number !") + + +def cut_selectObject(): + """ Select the Object to cut. + """ + global myDialog + global m_cut_selectObjects + msg=0 + error_msg = "Select in order:\n"+ \ + "First, one Object to cut and click 'Select Object' button,\n"+ \ + "Second, one cutting Line and click 'Select Cut Line' button,\n"+ \ + "Last, a reference Plane and click 'Select Ref. Plane' button!" + m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=msg, printError=False) + if m_num == 1: + m_cut_selectObjects.append([m_selEx, m_objs, m_objNames]) + m_text=str(m_objNames[0]) + myDialog.ui.info_cut_select_object.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + + else: + printError_msg(error_msg) + return + + # Activate the button_cut_select_line + myDialog.ui.button_cut_select_line.setEnabled(True) + + +def cut_selectLine(): + """ Select the Line to cut the Object along. + """ + global myDialog + global m_cut_selectObjects + msg=0 + error_msg = "Select in order:\n"+ \ + "First, one Object to cut and click 'Select Object' button,\n"+ \ + "Second, one cutting Line and click 'Select Cut Line' button,\n"+ \ + "Last, a reference Plane and click 'Select Ref. Plane' button!" + # TODO : check if really a line + m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=msg, printError=False) + if m_num == 1: + m_cut_selectObjects.append([m_selEx, m_objs, m_objNames]) + m_text=str(m_objNames[0]) + myDialog.ui.info_cut_select_axis.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + + else: + printError_msg(error_msg) + return + + # Activate the button_cut_select_plane + myDialog.ui.button_cut_select_plane.setEnabled(True) + + +def cut_selectPlane(): + """ Select the reference Plane to cut the Object from. + """ + global myDialog + global m_cut_selectObjects + msg=0 + error_msg = "Select in order:\n"+ \ + "First, one Object to cut and click 'Select Object' button,\n"+ \ + "Second, one cutting Line and click 'Select Cut Line' button,\n"+ \ + "Last, a reference Plane and click 'Select Ref. Plane' button!" + # TODO : check if really a plane + m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=msg, printError=False) + if m_num == 1: + m_cut_selectObjects.append([m_selEx, m_objs, m_objNames]) + m_text=str(m_objNames[0]) + myDialog.ui.info_cut_select_plane.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + else: + printError_msg(error_msg) + return + + # Activate the button_cut_apply + myDialog.ui.button_cut_apply.setEnabled(True) + + +def cut_reset(): + """ Select the reference Plane to cut the Object from. + """ + global myDialog + global m_cut_selectObjects + del m_cut_selectObjects[:] + m_text="" + + # deActivate the button_cut_select_line + myDialog.ui.button_cut_select_line.setEnabled(False) + # deActivate the button_cut_select_plane + myDialog.ui.button_cut_select_plane.setEnabled(False) + # deActivate the button_cut_apply + myDialog.ui.button_cut_apply.setEnabled(False) + myDialog.ui.info_cut_select_object.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + myDialog.ui.info_cut_select_axis.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + myDialog.ui.info_cut_select_plane.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + + +def plot_cutObject(): + """ Cut an object in 2 pieces, based on a cut line, a plane, + an angle regarding this plane and a thickness of the line. + """ + global myDialog + global m_cut_selectObjects + global m_angleCutObject + global m_thicknessCutObject + global verbose + msg=verbose + createFolders('WorkObjects') + error_msg = "Select in order:\n"+ \ + "First, one Object to cut and click 'Select Object' button,\n"+ \ + "Second, one cutting Line and click 'Select Cut Line' button,\n"+ \ + "Last, a reference Plane and click 'Select Ref. Plane' button!" + result_msg = "Cut object done into WorkFeatures/WorkObjects/" + name = "Part" + part = "Part::Feature" + + m_actDoc = get_ActiveDocument(info=0) + if m_actDoc == None: + return + + m_num = len(m_cut_selectObjects) + if m_num == 3: + #[m_selEx, m_objs, m_objNames] + # Get the Object + m_cut_obj = m_cut_selectObjects[0] + # Get the Line + m_cut_line = m_cut_selectObjects[1] + # Get the Plane + m_ref_plane = m_cut_selectObjects[2] + if msg == 1: + print_msg("Object to cut =" + str(m_cut_obj[2]) + + "\nCutting Line =" + str(m_cut_line[2]) + + "\nRef. Plane =" + str(m_ref_plane[2])) + # Check if we have correct shapes + SubObjects_Inside = m_cut_line[0][0].SubObjects + SubObject = SubObjects_Inside[0] + if msg == 1: + print_msg( "SubObject = " + str(SubObject) ) + if SubObject.ShapeType != "Edge": + printError_msg(error_msg) + return + m_Edge = SubObject + SubObjects_Inside = m_ref_plane[0][0].SubObjects + SubObject = SubObjects_Inside[0] + if msg == 1: + print_msg( "SubObject = " + str(SubObject) ) + if SubObject.ShapeType != "Face": + printError_msg(error_msg) + return + m_Plane = SubObject + + m_Obj = m_cut_obj[1][0] + try: + m_Obj.Shape + except: + printError_msg( "This object has no attribute 'Shape' ! Select another one !\n") + return + m_Obj_name = m_cut_obj[2][0] + try: + m_dir=str(m_Obj_name)+"_Cut" + m_newdir=App.ActiveDocument.getObject("WorkObjects").newObject("App::DocumentObjectGroup", str(m_dir)) + m_dir=m_newdir.Name + except: + printError_msg("Could not Create '"+ str(m_dir) +"' Objects Group!") + return + + if msg == 1: + print_msg( "Processing : " + str(m_Obj_name)) + print_msg( "Into the group : " + str(m_dir)) + + # Get Line's limits + Point_A = m_Edge.valueAt(0.0) + Point_B = m_Edge.valueAt(m_Edge.Length) + Point_C = centerLinePoint(m_Edge) + if msg == 1: + print_msg( "\nGet Line's limits") + Point_A_User_Name = plot_point(Point_A, part, "Point_A", grp=str(m_dir)) + print_point(Point_A, msg=str(Point_A_User_Name) + ", (internal Point_A) : ") + Point_B_User_Name = plot_point(Point_B, part, "Point_B", grp=str(m_dir)) + print_point(Point_B, msg=str(Point_B_User_Name) + ", (internal Point_B) : ") + Point_C_User_Name = plot_point(Point_C, part, "Point_C", grp=str(m_dir)) + print_point(Point_C, msg=str(Point_C_User_Name) + ", (internal Point_C) : ") + print_msg( "Distance : " + str(m_Edge.Length)) + + + # Get object's limits + m_xmax, m_xmin, m_ymax, m_ymin, m_zmax, m_zmin = minMaxObjectsLimits(m_cut_obj[1][0:],info=0) + + # Length of BoundBox in X, Y and Z dimensions + m_length_X = m_xmax - m_xmin + m_length_Y = m_ymax - m_ymin + m_length_Z = m_zmax - m_zmin + m_length_list = [m_length_X, m_length_Y, m_length_Z] + m_length_max = max(m_length_list) + m_ori_X = m_xmin + m_ori_Y = m_ymin + m_ori_Z = m_zmin + + # Get Points, Edges, Faces from the bounding box Object dimensions + Points, BB_Edges, Faces = get_all_from_bounding_box(m_ori_X,m_ori_Y,m_ori_Z,m_length_X,m_length_Y,m_length_Z,info=0,plot=0) + +#============================================================================== + # Looking for the min distance between center of line and center + # of faces of the bounding box. An selection of this Plane + min_val, max_val = init_min_max() + m_min_distance = max_val + Plane_Point1 = None + Plane_Normal1 = None + Selected_Plane1 = Faces[0][5] + for m_i in range(len(Faces)): + #( 3, 0, 1, 2, (BB_Edges[3][3],BB_Edges[0][3],BB_Edges[1][3],BB_Edges[2][3]), face, mid_point, length ) + m_distance = distanceBetween(Point_C, Faces[m_i][6]) + if m_distance < m_min_distance: + m_min_distance = m_distance + Selected_Plane1 = Faces[m_i][5] + Plane_Point1 = Faces[m_i][6] + Plane_Normal1 = Selected_Plane1.normalAt(0,0) + if Plane_Point1 == None: + printError_msg("Plane_Point1 is Null!") + return + if Plane_Normal1 == None: + printError_msg("Plane_Normal1 is Null!") + return +#============================================================================== + +#============================================================================== + # Select the second plane of the bounding box parallel to this first one + Plane_Point2 = None + Plane_Normal2 = None + Selected_Plane2 = Faces[0][5] + for m_i in range(len(Faces)): + Plane_Normal = Faces[m_i][5].normalAt(0,0) + if Plane_Normal != Plane_Normal1: + cross_product = Plane_Normal.cross(Plane_Normal1) + if abs(cross_product.x) <= 1e-12 and abs(cross_product.y) <= 1e-12 and abs(cross_product.z) <= 1e-12: + Selected_Plane2 = Faces[m_i][5] + Plane_Point2 = Faces[m_i][6] + Plane_Normal2 = Selected_Plane2.normalAt(0,0) + break + if Plane_Point2 == None: + printError_msg("Plane_Point2 is Null!") + return + if Plane_Normal2 == None: + printError_msg("Plane_Normal2 is Null!") + return + if msg == 1: + print_msg( "\nGet Bounding Planes info") + print_msg( "MIN Distance : " + str(m_min_distance) ) + Point_Face01_User_Name = plot_point(Plane_Point1, part, "Point_Face01", grp=str(m_dir)) + print_point(Plane_Point1, msg=str(Point_Face01_User_Name) + ", (internal Point_Face01) : ") + Point_Face02_User_Name = plot_point(Plane_Point2, part, "Point_Face02", grp=str(m_dir)) + print_point(Plane_Point2, msg=str(Point_Face02_User_Name) + ", (internal Point_Face02) : ") + +#============================================================================== + +#============================================================================== + # Build The Plane Crossing the Line and making an angle with the Ref. Plane + Ref_Plane = m_Plane + Plane_Point = Ref_Plane.CenterOfMass + Plane_Normal = Ref_Plane.normalAt(0,0) + # Projection of A and B onto the Ref Plane A0 and B0 + Vector_A = Point_A + Plane_Normal + Vector_B = Point_B + Plane_Normal + Point_A0 = intersecLinePlane(Point_A, Vector_A, Plane_Normal, Plane_Point, info=0) + Point_B0 = intersecLinePlane(Point_B, Vector_B, Plane_Normal, Plane_Point, info=0) + # Plot them if needed + if msg == 1: + print_msg( "\nProjection of A and B onto the Ref Plane in A0 and B0") + Point_A0_User_Name = plot_point(Point_A0, part, "Point_A0", grp=str(m_dir)) + Point_B0_User_Name = plot_point(Point_B0, part, "Point_B0", grp=str(m_dir)) + print_point(Point_A0, msg=str(Point_A0_User_Name) + ", (internal Point_A0) : ") + print_point(Point_B0, msg=str(Point_B0_User_Name) + ", (internal Point_B0) : ") + + AxisA0B0_User_Name, AxisA0B0 = plot_axis(Point_A0, Point_B0, part, "LineA0-B0", grp=str(m_dir)) + + Point_A1 = Point_A0 + Point_B1 = Point_B0 + # Get intersections of this line with the Edges of the Ref. Plane + # To update points A0 and B0 into A1 and B1 + Number_of_Intersec, Intersec_Points = intersecPoints(AxisA0B0.Shape, Ref_Plane, info=0) + if msg == 1: + print_msg( "\nIntersections of A0B0 line with the edges of Ref. Plane : A1 and B1") + print_msg("Number_of_Intersec = " + str(Number_of_Intersec)) + if Number_of_Intersec == 0: + printError_msg("No intersection point between projection of the Line and Object !") + return + if Number_of_Intersec == 1: + printError_msg("Only one intersection point between projection of the Line and Object ! No cut possible !") + return + if Number_of_Intersec == 2: + Point_A1 = Intersec_Points[0] + Point_B1 = Intersec_Points[1] + if msg == 1: + Point_A1_User_Name = plot_point(Point_A1, part, "Point_A1", grp=str(m_dir)) + print_point(Point_A1, msg=str(Point_A1_User_Name) + ", (internal Point_A1) : ") + Point_B1_User_Name = plot_point(Point_B1, part, "Point_B1", grp=str(m_dir)) + print_point(Point_B1, msg=str(Point_B1_User_Name) + ", (internal Point_B1) : ") + + # Line onto Ref Plane + Edge_Vector = Point_B1 - Point_A1 + Edge_Length = m_length_max * 1.5 * 2 + # Mid point + Point_MidPoint = Point_B1 + Point_A1 + Point_MidPoint = Point_MidPoint.multiply(0.5) + # Attachement Point + Attach_Point = Point_MidPoint + # Normal + Vector_Normal = Edge_Vector.cross(Plane_Normal) + + # Build a cutting Plane + if msg == 1: + print_msg( "\nBuild a cutting Plane") + + Plane_Point = Attach_Point + Plane_Normal = Edge_Vector.cross(Plane_Normal) + # Get projection of Plane_Point1 to cutting Plane + C1 = Plane_Point1 + B1 = C1 + Plane_Normal + T1 = intersecLinePlane(C1, B1, Plane_Normal, Plane_Point, info=0) + # Get projection of Plane_Point2 to cutting Plane + C2 = Plane_Point2 + B2 = C2 + Plane_Normal + T2 = intersecLinePlane(C2, B2, Plane_Normal, Plane_Point, info=0) + # New Attachement Point + Attach_Point = T2 - T1 + Attach_Point = Attach_Point.multiply(0.5) + Attach_Point = Point_MidPoint + Attach_Point + # Build a cutting Plane + cutting_plane = None + Plane_cutting_User_Name, cutting_plane = plot_plane(Edge_Length, Edge_Length, Attach_Point, Vector_Normal, part, "Cutting_plane", grp=str(m_dir)) + if cutting_plane == None: + printError_msg("Unable to create Cutting plane !") + return + + # Rotate the cutting Plane if needed + if m_angleCutObject != 0.0: + rot_angle = m_angleCutObject + rot_axis = Edge_Vector + m_center = Point_MidPoint + m_rot = App.Rotation(rot_axis,rot_angle) + if msg == 1: + print_msg("rotation = " + str(m_rot)) + print_msg("rotation axis = " + str(rot_axis)) + m_place = App.Placement(cutting_plane.Placement) + m_base1 = m_place.Base + if msg == 1: + print_msg("base1 = " + str(m_base1)) + m_rot1 = m_place.Rotation + if msg == 1: + print_msg("rot1 = " + str(m_rot1)) + m_rot = m_rot.multiply(m_rot1) + m_newplace = App.Placement(m_base1,m_rot,m_center-m_base1) + cutting_plane.Placement = m_newplace + + Attach_Point = cutting_plane.Shape.CenterOfMass + Vector_Normal = cutting_plane.Shape.normalAt(0,0) + # Duplicate the cutting Plane and move if thickness not null + if m_thicknessCutObject != 0.0: + Attach_Point2 = Vector_Normal - Attach_Point + Attach_Point2 = Attach_Point + Attach_Point2.normalize().multiply(0.5 * m_thicknessCutObject) + # Build a cutting Plane + cutting_plane2 = None + Plane_cutting2_User_Name, cutting_plane2 = plot_plane(Edge_Length, Edge_Length, Attach_Point2, Vector_Normal, part, "Cutting_plane", grp=str(m_dir)) + if cutting_plane2 == None: + printError_msg("Unable to create Cutting plane 2 !") + return + + Attach_Point3 = Vector_Normal - Attach_Point + Attach_Point3 = Attach_Point + Attach_Point3.normalize().multiply(-0.5 * m_thicknessCutObject) + # Build a cutting Plane + cutting_plane3 = None + Plane_cutting3_User_Name, cutting_plane3 = plot_plane(Edge_Length, Edge_Length, Attach_Point3, Vector_Normal, part, "Cutting_plane", grp=str(m_dir)) + if cutting_plane3 == None: + printError_msg("Unable to create Cutting plane 3 !") + return + + + + + +#============================================================================== + + # Just need to find the intersection line between cutting Plane and + # the object (nearest bounding Plane) + cut_plane = cutting_plane.Shape + near_plane = Selected_Plane1 + if msg == 1: + print_msg(str(cut_plane)) + print_msg(str(near_plane)) + + cut_plane_Normal = cut_plane.normalAt(0,0) + near_plane_Normal = near_plane.normalAt(0,0) + if msg == 1: + print_msg( "\nFind the intersection line between cutting Plane and the object (nearest plane of bounding box)") + print_point(cut_plane_Normal, msg="Normal1 : ") + print_point(near_plane_Normal, msg="Normal2 : ") + + cut_plane_Point = cut_plane.CenterOfMass + near_plane_Point = near_plane.CenterOfMass + if msg == 1: + print_point(cut_plane_Point , msg="cut_plane_Point : ") + print_point(near_plane_Point , msg="near_plane_Point : ") + + Axis_dir = intersecPlanePlane(cut_plane_Normal, cut_plane_Point, near_plane_Normal, near_plane_Point, info=msg) + + if Axis_dir == None: + printError_msg("Not able to find an intersection between the cutting Plane and the Object !") + return + + # Intersection Line found + Intersecline = None + Vertx = [] + Distx = [] + Vertx_names = [] + + min_val, max_val = init_min_max() + dist_to_center_min = max_val + # For the first plane look after all edges and look at + # intersections of the edges with the second plane + Number_of_Edges = len(cut_plane.Edges) + for j in range(Number_of_Edges): + A = cut_plane.Edges[j].valueAt( 0.0 ) + B = cut_plane.Edges[j].valueAt(cut_plane.Edges[j].Length ) + T = intersecLinePlane(A, B, near_plane_Normal, near_plane_Point, info=0) + if T != None: + D = T - cut_plane_Point + dist_to_center = math.sqrt(D.dot(D)) + if dist_to_center < dist_to_center_min: + dist_to_center_min = dist_to_center + Vertx.append(T) + Distx.append(dist_to_center) + +#============================================================================== +# Number_of_Edges = len(near_plane.Edges) +# dist_to_center_min = max_val +# for jj in range(Number_of_Edges): +# A = near_plane.Edges[jj].valueAt( 0.0 ) +# B = near_plane.Edges[jj].valueAt(near_plane.Edges[jj].Length ) +# T = intersecLinePlane(A, B, cut_plane_Normal, cut_plane_Point, info=0) +# if T != None: +# D = T - near_plane_Point +# dist_to_center = math.sqrt(D.dot(D)) +# if dist_to_center < dist_to_center_min: +# dist_to_center_min = dist_to_center +# Vertx.append(T) +# Distx.append(dist_to_center) +#============================================================================== + + if msg == 1: + for k in range(len(Vertx)): + Point_User_Name = plot_point(Vertx[k], part, "Edge_point", grp=str(m_dir)) + Vertx_names.append(str(Point_User_Name)) + print_point(Vertx[k], msg=str(Point_User_Name) + ", (internal Edge_point) : ") + + C = meanVectorsPoint(Vertx,info=0) + + if msg == 1: + Edge_point_C_User_Name = plot_point(C, part, "Edge_point_C", grp=str(m_dir)) + print_point(C, msg=str(Edge_point_C_User_Name) + ", (internal Edge_point_C) : ") + + if C != None: + extension = max(Distx) + A = C - Axis_dir.normalize().multiply(extension*1.5) + B = C + Axis_dir + IntersecLine_User_Name, Intersecline = plot_axis(A, B, part, "IntersecLine", grp=str(m_dir)) +#============================================================================== + +#============================================================================== + # Look for A2 and B2 intersection of Intersecline and edges of the object + # (nearest plane of bounding box : Selected_Plane1) + Point_A2 = Point_A1 + Point_B2 = Point_B1 + # Get intersections of this line with the Edges of the Face + # To update Point_A1 and Point_B1 into Point_A2 and Point_B2 + Number_of_Intersec, Intersec_Points = intersecPoints(Intersecline.Shape, Selected_Plane1, info=0) + if msg == 1: + print_msg( "\nLook for A2 and B2 intersection of Intersecline and edges of the object (nearest plane of bounding box)") + print_msg("Number_of_Intersec = " + str(Number_of_Intersec)) + + if Number_of_Intersec == 0: + printError_msg("No intersection point between Intersecline and Object !") + return + if Number_of_Intersec == 1: + printError_msg("Only one intersection point between Intersecline and Object ! No cut possible !") + return + if Number_of_Intersec == 2: + Point_A2 = Intersec_Points[0] + Point_B2 = Intersec_Points[1] + if msg == 1: + print_msg( "Intersections of Intersecline with the Edges of the Face :") + Point_A2_User_Name = plot_point(Intersec_Points[0], part, "Point_A2", grp=str(m_dir)) + print_point(Point_A2, msg=str(Point_A2_User_Name) + ", (internal Point_A2) : ") + Point_B2_User_Name = plot_point(Intersec_Points[1], part, "Point_B2", grp=str(m_dir)) + print_point(Point_B2, msg=str(Point_B2_User_Name) + ", (internal Point_B2) : ") + +#============================================================================== + +#============================================================================== + # Now we need to extrude the cutting Plane + BB_edges_names = [] + # First get 2 Vectors in which direction to extrude from Point_A2 + Vector_extrude1 = App.Vector(0.0,0.0,0.0) + Vector_extrude2 = App.Vector(0.0,0.0,0.0) + for m_i in range(len(BB_Edges)): + #( 2, 6, (Points[2], Points[6]), edge, mid_point, length ) + if msg == 1: + Axis_User_Name, Axis = plot_axis(BB_Edges[m_i][2][0], BB_Edges[m_i][2][1], part, "bb_edge", grp=str(m_dir)) + BB_edges_names.append(str(Axis_User_Name)) + if colinearVectors(BB_Edges[m_i][2][0], Point_A2, BB_Edges[m_i][2][1], info=0, precision=1e-10): + # Plot them + if msg == 1: + Point_A2_prime_User_Name = plot_point(BB_Edges[m_i][2][0], part, "Point_A2_prime", grp=str(m_dir)) + print_point(BB_Edges[m_i][2][0], msg=str(Point_A2_prime_User_Name) + ", (internal Point_A2_prime) : ") + Point_A2_second_User_Name = plot_point(BB_Edges[m_i][2][1], part, "Point_A2_second", grp=str(m_dir)) + print_point(BB_Edges[m_i][2][1], msg=str(Point_A2_second_User_Name) + ", (internal Point_A2_second) : ") + + Vector_extrude1 = BB_Edges[m_i][2][0] - Point_A2 + Vector_extrude2 = Point_A2 - BB_Edges[m_i][2][1] + + if Vector_extrude1 == App.Vector(0.0,0.0,0.0): + for m_i in range(len(BB_Edges)): + #( 2, 6, (Points[2], Points[6]), edge, mid_point, length ) + if msg == 1: + Axis_User_Name, Axis = plot_axis(BB_Edges[m_i][2][0], BB_Edges[m_i][2][1], part, "bb_edge", grp=str(m_dir)) + BB_edges_names.append(str(Axis_User_Name)) + if colinearVectors(BB_Edges[m_i][2][0], Point_B2, BB_Edges[m_i][2][1], info=0, precision=1e-10): + # Plot them + if msg == 1: + Point_A2_prime_User_Name = plot_point(BB_Edges[m_i][2][0], part, "Point_B2_prime", grp=str(m_dir)) + print_point(BB_Edges[m_i][2][0], msg=str(Point_A2_prime_User_Name) + ", (internal Point_B2_prime) : ") + Point_A2_second_User_Name = plot_point(BB_Edges[m_i][2][1], part, "Point_B2_second", grp=str(m_dir)) + print_point(BB_Edges[m_i][2][1], msg=str(Point_A2_second_User_Name) + ", (internal Point_B2_second) : ") + + Vector_extrude1 = BB_Edges[m_i][2][0] - Point_B2 + Vector_extrude2 = Point_B2 - BB_Edges[m_i][2][1] + + if Vector_extrude1 == App.Vector(0.0,0.0,0.0): + printError_msg("Vector_extrude1 is Null!") + return + + if Vector_extrude2 == App.Vector(0.0,0.0,0.0): + printError_msg("Vector_extrude2 is Null!") + return + + # Get the max length of the bounding box + Vector_extrude1 = Vector_extrude1.normalize().multiply(m_length_max) + Vector_extrude2 = Vector_extrude2.normalize().multiply(m_length_max) + # Extrude a bit after the extreme edges with a 45 deg angle (diagonal) + Vector_extrude1 = Vector_extrude1.multiply(1.5).multiply(2) + Vector_extrude2 = Vector_extrude2.multiply(-1.5).multiply(2) + if msg == 1: + print_msg("Vector_extrude1 = " + str(Vector_extrude1)) + print_msg("Vector_extrude2 = " + str(Vector_extrude2)) + + # Get the shape of the cutting Plane + plane_shape = cutting_plane.Shape + if msg == 1: + print_msg("plane = " + str(cutting_plane)) + print_msg("plane_shape = " + str( plane_shape)) + + # We extrude in the first direction + extrude1 = plane_shape.extrude(Vector_extrude1) + if msg == 1: + print_msg("extrude1 = " + str(extrude1)) + m_extrude1_name = str(m_Obj_name) + "_" + str(name) + "extrude01" + Extrude1 = App.ActiveDocument.addObject(part,m_extrude1_name) + App.ActiveDocument.getObject(str(m_dir)).addObject(Extrude1) + m_extrude1_name = Extrude1.Name + Extrude1.Shape = extrude1 + + # We extrude in the second direction + extrude2 = plane_shape.extrude(Vector_extrude2) + if msg == 1: + print_msg("extrude2 = " + str(extrude2)) + m_extrude2_name = str(m_Obj_name) + "_" + str(name) + "extrude02" + Extrude2 = App.ActiveDocument.addObject(part,m_extrude2_name) + App.ActiveDocument.getObject(str(m_dir)).addObject(Extrude2) + m_extrude2_name = Extrude2.Name + Extrude2.Shape = extrude2 + + # if thickness not null + if m_thicknessCutObject != 0.0: + plane_shape2 = cutting_plane2.Shape + plane_shape3 = cutting_plane3.Shape + Vector_extrude3 = Attach_Point3 - Attach_Point2 + Vector_extrude4 = Attach_Point2 - Attach_Point3 + + extrude1b = plane_shape2.extrude(Vector_extrude3) + if msg == 1: + print_msg("extrude1b = " + str(extrude1b)) + m_extrude1b_name = str(m_Obj_name) + "_" + str(name) + "extrude01b" + Extrude1b = App.ActiveDocument.addObject(part,m_extrude1b_name) + App.ActiveDocument.getObject(str(m_dir)).addObject(Extrude1b) + m_extrude1b_name = Extrude1b.Name + Extrude1b.Shape = extrude1b + + extrude2b = plane_shape3.extrude(Vector_extrude4) + if msg == 1: + print_msg("extrude2b = " + str(extrude2b)) + m_extrude2b_name = str(m_Obj_name) + "_" + str(name) + "extrude02b" + Extrude2b = App.ActiveDocument.addObject(part,m_extrude2b_name) + App.ActiveDocument.getObject(str(m_dir)).addObject(Extrude2b) + m_extrude2b_name = Extrude2b.Name + Extrude2b.Shape = extrude2b +#============================================================================== + +#============================================================================== + # Let's duplicate the Object + m_obj2 = m_actDoc.copyObject(m_Obj) + m_obj3 = m_actDoc.copyObject(m_Obj) + App.ActiveDocument.getObject(str(m_dir)).addObject(m_obj2) + App.ActiveDocument.getObject(str(m_dir)).addObject(m_obj3) + Obj2_User_Name = m_obj2.Name + Obj3_User_Name = m_obj3.Name + + # and Split in two parts + m_diff1_name = str(m_Obj_name) + "_01_" + str(name) + Diff1 = App.ActiveDocument.addObject( part, m_diff1_name ) + Diff1.Shape = m_obj2.Shape.cut(extrude1) + if m_thicknessCutObject != 0.0: + Diff1.Shape = Diff1.Shape.cut(extrude1b) + App.ActiveDocument.getObject(str(m_dir)).addObject(Diff1) + + m_diff2_name = str(m_Obj_name) + "_02_" + str(name) + Diff2 = App.ActiveDocument.addObject( part, m_diff2_name ) + Diff2.Shape = m_obj3.Shape.cut(extrude2) + if m_thicknessCutObject != 0.0: + Diff2.Shape = Diff2.Shape.cut(extrude2b) + App.ActiveDocument.getObject(str(m_dir)).addObject(Diff2) +#============================================================================== + +#============================================================================== + # Hide intermediate objects + if msg == 1: + Gui.ActiveDocument.getObject(str(Point_A_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_B_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_C_User_Name)).Visibility=False + + Gui.ActiveDocument.getObject(str(Point_Face01_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_Face02_User_Name)).Visibility=False + + Gui.ActiveDocument.getObject(str(Point_A0_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_B0_User_Name)).Visibility=False + + Gui.ActiveDocument.getObject(str(Point_A1_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_B1_User_Name)).Visibility=False + + for k in range(len(Vertx)): + Gui.ActiveDocument.getObject(str(Vertx_names[k])).Visibility=False + Gui.ActiveDocument.getObject(str(Edge_point_C_User_Name)).Visibility=False + + Gui.ActiveDocument.getObject(str(Point_A2_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_B2_User_Name)).Visibility=False + for k in range(len(BB_edges_names)): + Gui.ActiveDocument.getObject(str(BB_edges_names[k])).Visibility=False + + Gui.ActiveDocument.getObject(str(Point_A2_prime_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Point_A2_second_User_Name)).Visibility=False + + Gui.ActiveDocument.getObject(str(m_extrude1_name)).Visibility=False + Gui.ActiveDocument.getObject(str(m_extrude2_name)).Visibility=False + if m_thicknessCutObject != 0.0: + Gui.ActiveDocument.getObject(str(m_extrude1b_name)).Visibility=False + Gui.ActiveDocument.getObject(str(m_extrude2b_name)).Visibility=False + + Gui.ActiveDocument.getObject(str(Obj2_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Obj3_User_Name)).Visibility=False + + # hide lines + Gui.ActiveDocument.getObject(str(AxisA0B0_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(IntersecLine_User_Name)).Visibility=False + + # hide the cutting planes + Gui.ActiveDocument.getObject(str(Plane_cutting_User_Name)).Visibility=False + if m_thicknessCutObject != 0.0: + Gui.ActiveDocument.getObject(str(Plane_cutting2_User_Name)).Visibility=False + Gui.ActiveDocument.getObject(str(Plane_cutting3_User_Name)).Visibility=False + + # hide the Original + Gui.ActiveDocument.getObject(str(m_Obj_name)).Visibility=False +#============================================================================== +#============================================================================== + # Remove intermediate objects + if msg == 0: + App.getDocument(str(m_actDoc.Name)).removeObject(m_extrude1_name) + App.getDocument(str(m_actDoc.Name)).removeObject(m_extrude2_name) + if m_thicknessCutObject != 0.0: + App.getDocument(str(m_actDoc.Name)).removeObject(m_extrude1b_name) + App.getDocument(str(m_actDoc.Name)).removeObject(m_extrude2b_name) + App.getDocument(str(m_actDoc.Name)).removeObject(Obj2_User_Name) + App.getDocument(str(m_actDoc.Name)).removeObject(Obj3_User_Name) +#============================================================================== + print_msg( str(m_diff1_name) + result_msg + str(m_dir) ) + print_msg( str(m_diff2_name) + result_msg + str(m_dir) ) + + del BB_edges_names[:] + del Distx[:] + del Vertx[:] + del Vertx_names[:] + else: printError_msg(error_msg) + cut_reset() + +def object_align2view(): + """ Place your object selected to the position ActiveView (camera) + __author__ = "Mario52" + """ + # revoir le point de rotation + msg=0 + error_msg = "Select one object !" + + m_actDoc = get_ActiveDocument(info=msg) + if m_actDoc == None: + return None + + m_num, m_selEx, m_objs, m_objNames = get_InfoObjects(info=msg) + Center = centerObjectsPoint(m_objs) + if Center != None: + pl = FreeCAD.Placement() + pl.Rotation = Gui.ActiveDocument.ActiveView.getCameraOrientation() + pl.Base = App.Vector(0,0,0) + for m_objName in m_objNames: + App.ActiveDocument.getObject(m_objName).Placement=pl + + else: + printError_msg(error_msg) + + #sel = Gui.Selection.getSelection() + #Nameelement = sel[0].Name + #pl = FreeCAD.Placement() + #pl.Rotation = Gui.ActiveDocument.ActiveView.getCameraOrientation() + #pl.Base = FreeCAD.Vector(0.0,0.0,0.0) + #App.ActiveDocument.getObject(Nameelement).Placement=pl + + def view_align(): """ Set the current view perpendicular to the selected Face, Edge or 2 points selected @@ -3011,82 +4486,81 @@ def view_align(): m_cam = Gui.ActiveDocument.ActiveView.getCameraNode() m_camValues = m_cam.position.getValue() m_pos = App.Vector( (m_camValues[0], m_camValues[1], m_camValues[2],) ) - + for m_i in range(m_num): Sel_i_Object = m_selEx[m_i] SubObjects_Inside = Sel_i_Object.SubObjects - SubObject = SubObjects_Inside[0] - + SubObject = SubObjects_Inside[0] + if SubObject.ShapeType == "Vertex": Selected_Points.append(SubObject) Number_of_Points = len(Selected_Points) if Number_of_Points == 2: m_Vertex1 = Selected_Points[0] - m_dist1 = m_pos.sub(Selected_Points[0].Point) - m_Vertex2 = Selected_Points[1] + m_dist1 = m_pos.sub(Selected_Points[0].Point) + m_Vertex2 = Selected_Points[1] m_dist2 = m_pos.sub(Selected_Points[1].Point) - + #print_msg("dist1=" + str(m_dist1.Length) + "\ndist2=" + str(m_dist2.Length)) if m_dist1.Length < m_dist2.Length: alignCamera(m_Vertex1.Point,m_Vertex2.Point,False) else: alignCamera(m_Vertex1.Point,m_Vertex2.Point,True) - + elif SubObject.ShapeType == "Edge": m_Vertex1 = SubObject.Vertexes[0] - m_dist1 = m_pos.sub(SubObject.valueAt( 0.0 )) - m_Vertex2 = SubObject.Vertexes[1] + m_dist1 = m_pos.sub(SubObject.valueAt( 0.0 )) + m_Vertex2 = SubObject.Vertexes[1] m_dist2 = m_pos.sub(SubObject.valueAt( SubObject.Length )) - + #print_msg("dist1=" + str(m_dist1.Length) + "\ndist2=" + str(m_dist2.Length)) if m_dist1.Length < m_dist2.Length: alignCamera(m_Vertex1.Point,m_Vertex2.Point,False) else: alignCamera(m_Vertex1.Point,m_Vertex2.Point,True) - + elif SubObject.ShapeType == "Face": m_faceSel = Sel_i_Object.SubObjects[0] m_dir = m_faceSel.normalAt(0,0) m_dir = m_faceSel.Surface.Axis m_edge = Part.makeLine(m_faceSel.CenterOfMass, m_faceSel.CenterOfMass.add(m_dir)) - + m_Vertex1 = m_edge.Vertexes[0] - m_dist1 = m_pos.sub(m_faceSel.CenterOfMass) + m_dist1 = m_pos.sub(m_faceSel.CenterOfMass) m_Vertex2 = m_edge.Vertexes[1] m_dist2 = m_pos.sub(m_faceSel.CenterOfMass.add(m_dir)) - + #print_msg("dist1=" + str(m_dist1.Length) + "\ndist2=" + str(m_dist2.Length)) if m_dist1.Length < m_dist2.Length: alignCamera(m_Vertex1.Point,m_Vertex2.Point,False) else: alignCamera(m_Vertex1.Point,m_Vertex2.Point,True) else: - printError_msg(error_msg) + printError_msg(error_msg) else: printError_msg(error_msg) - -#################################################################################### + +#################################################################################### try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s - -#################################################################################### +#################################################################################### class WorkFeatureTab(): def __init__(self): # Get main window self.m_main = self.getMainWindow() - + # Get Tab panel self.m_tab = self.getComboView(self.m_main) - + if self.m_tab.count() == 2: # Create a new fake dialog self.m_fake_dialog = QtGui.QDialog() self.m_tab.addTab(self.m_fake_dialog,"") - + # Create a new dialog for WorkFeatureTab self.m_dialog = QtGui.QDialog() # Add the dialog in a new tab or focus on it if already exists @@ -3098,18 +4572,27 @@ class WorkFeatureTab(): if "Work Features" == str(_fromUtf8(self.m_tab.tabText(i))): self.m_tab.removeTab(int(i)) break - + self.m_tab.addTab(self.m_dialog,"Work Features") - + self.ui = WFGui.Ui_Form() self.ui.setupUi(self.m_dialog) self.m_tab.setCurrentIndex(3) - + # Connect to functions - self.connections_for_button_pressed = { + self.connections_for_checkbox_toggled = { + "checkBox_object_center" : "bBox_toggled", + } + self.connections_for_button_clicked = { + "button_WF_quit" : "quit_clicked", + } + #self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked) # quit + + self.connections_for_button_pressed = { "button_origin" : "plot_originObject", - + "button_object_center" : "plot_centerObjectPoint", + "button_Npoints_center" : "plot_NpointsPoint", "button_line_center" : "plot_centerLinePoint", "button_line_extrema" : "plot_extremaLinePoint", "button_point_on_line" : "plot_alongLinePoint", @@ -3118,71 +4601,135 @@ class WorkFeatureTab(): "button_line_face_point" : "plot_lineFacePoint", "button_point_line_point" : "plot_pointLinePoint", "button_point_face_point" : "plot_pointFacePoint", + "button_twolines_point" : "plot_2LinesPoint", "button_click_for_point" : "plot_clickForPoint", "button_object_base_point" : "plot_baseObjectPoint", - + "button_object_axis" : "plot_centerObjectAxes", - "button_twopoints_axis" : "plot_twoPointsAxis", - "button_cylinder_axis" : "plot_cylinderAxis", - "button_twolines_axis" : "plot_twoLinesAxis", + "button_twopoints_axis" : "plot_2PointsAxis", + "button_cylinder_axis" : "plot_cylinderAxis", + "button_twolines_axis" : "plot_2LinesAxis", "button_plane_axis" : "plot_planeAxis", + "button_face_normal" : "plot_faceNormal", "button_point_line_axis" : "plot_pointLineAxis", "button_line_point_axis" : "plot_linePointAxis", "button_line_plane_axis" : "plot_linePlaneAxis", - "button_2Planes_axis" : "plot_twoPlanesAxis", - + "button_twoplanes_axis" : "plot_2PlanesAxis", "button_object_base_axes" : "plot_baseObjectAxes", - - "button_threepoints_plane" : "plot_threePointsPlane", + + "button_linecenter_circle" : "plot_linecenterCircle", + "button_linepoint_circle" : "plot_linepointCircle", + "button_3points_circle" : "plot_3pointsCircle", + "button_3points_ellipse" : "plot_3pointsEllipse", + + "button_threepoints_plane" : "plot_3PointsPlane", "button_axisandpoint_plane" : "plot_axisPointPlane", "button_axis_point_plane" : "plot_perpendicularAxisPointPlane", - "button_planeandpoint_plane" : "plot_planePointPlane", + "button_planeandpoint_plane" : "plot_planePointPlane", "button_planeandaxis_plane" : "plot_planeAxisPlane", + "button_face_tangent" : "plot_faceTangentPlane", "button_click_for_plane" : "plot_clickForPlane", "button_object_center_planes" : "plot_centerObjectPlanes", - + "button_boundingboxes" : "plot_boundingBoxes", "button_boundingbox" : "plot_boundingBox", "button_cylinder_create" : "plot_axisPointCylinder", "button_cube_create" : "plot_axisPointCube", - - "button_alignview" : "view_align", - - } - self.connections_for_text_changed = { + + "button_alignview" : "view_align", + + "button_cut_select_object" : "cut_selectObject", + "button_cut_select_line" : "cut_selectLine", + "button_cut_select_plane" : "cut_selectPlane", + + "button_cut_reset" : "cut_reset", + "button_cut_apply" : "plot_cutObject", + + } + self.connections_for_text_changed = { "distance_point_on_line" : "distanceLinePoint", - + "extension_twopoints_axis" : "extensionTwoPointsAxis", + "extension_face_normal" : "extensionFaceNormal", "extension_line_point_axis" : "extensionLinePointAxis", - + + "radius_circle" : "radiusCircle", + "extension_planePointPlane" : "extensionPlanePointPlane", "angle_planeandaxis_plane" : "anglePlaneAxisPlane", - + "diameter_cylinder" : "diameterCylinder", "length_cylinder" : "lengthCylinder", "section_cube" : "sectionCube", "height_cube" : "heightCube", + + "angle_cut_object" : "angleCutObject", + "thickness_cut_object" : "thicknessCutObject", "length_plane" : "lengthPlane", "width_plane" : "widthPlane", + "length_plane_2" : "lengthPlane", + "width_plane_2" : "widthPlane", } - + + self.connections_for_spin_changed = { + "spin_line_center" : "numberLinePart", + } + + self.connections_for_radiobutton_clicked = { + "radioButton_verbose" : "verbose_toggled", + } + + for m_key, m_val in self.connections_for_button_clicked.items(): + #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) + QtCore.QObject.connect(getattr(self.ui, str(m_key)), + QtCore.SIGNAL("clicked()"),getattr(self,str(m_val))) + + for m_key, m_val in self.connections_for_button_pressed.items(): #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) QtCore.QObject.connect(getattr(self.ui, str(m_key)), QtCore.SIGNAL("pressed()"),globals()[str(m_val)]) - - + + for m_key, m_val in self.connections_for_text_changed.items(): #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) QtCore.QObject.connect(getattr(self.ui, str(m_key)), - QtCore.SIGNAL(_fromUtf8("textChanged(QString)")),globals()[str(m_val)]) - #QtCore.SIGNAL(QtCore.QString.fromUtf8("textChanged(QString)")),globals()[str(m_val)]) + QtCore.SIGNAL(_fromUtf8("textChanged(QString)")),globals()[str(m_val)]) + #QtCore.SIGNAL(QtCore.QString.fromUtf8("textChanged(QString)")),globals()[str(m_val)]) + + for m_key, m_val in self.connections_for_spin_changed.items(): + #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) + QtCore.QObject.connect(getattr(self.ui, str(m_key)), + QtCore.SIGNAL("valueChanged(int)"),globals()[str(m_val)]) + + for m_key, m_val in self.connections_for_checkbox_toggled.items(): + #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) + QtCore.QObject.connect(getattr(self.ui, str(m_key)), + QtCore.SIGNAL(_fromUtf8("toggled(bool)")),globals()[str(m_val)]) + + + for m_key, m_val in self.connections_for_radiobutton_clicked.items(): + #print_msg( "Connecting : " + str(m_key) + " and " + str(m_val) ) + QtCore.QObject.connect(getattr(self.ui, str(m_key)), + QtCore.SIGNAL(_fromUtf8("clicked(bool)")),globals()[str(m_val)]) + self.m_dialog.show() - - + m_text=str(myRelease) + self.ui.label_release.setText(QtGui.QApplication.translate("Form", m_text, None, QtGui.QApplication.UnicodeUTF8)) + + + def quit_clicked(self): # quit + #self.m_dialog.hide() + self.m_dialog.close() + if self.m_tab.count() >= 2: + for i in range(2,self.m_tab.count()): + if "Work Features" == str(_fromUtf8(self.m_tab.tabText(i))): + self.m_tab.removeTab(int(i)) + break + def getMainWindow(self): """ Returns the main window """ @@ -3195,7 +4742,7 @@ class WorkFeatureTab(): return i raise Exception("No main window found") - + def getComboView(self,window): """ Returns the main Tab. """ @@ -3204,7 +4751,8 @@ class WorkFeatureTab(): if str(i.objectName()) == "Combo View": return i.findChild(QtGui.QTabWidget) raise Exception("No tab widget found") - - + + if __name__ == '__main__': myDialog = WorkFeatureTab() + \ No newline at end of file diff --git a/start_WF.FCMacro b/start_WF.FCMacro index 7292679..a3b2218 100644 --- a/start_WF.FCMacro +++ b/start_WF.FCMacro @@ -1,2 +1,18 @@ -import WorkFeature -WorkFeature.WorkFeatureTab() +# -*- coding: utf-8 -*- +import sys +import os.path + +try: + # try import + import WorkFeature +except: + # get the path of the current python script + m_current_path = os.path.realpath(__file__) + m_current_path = os.path.dirname(m_current_path) + # check if this path belongs to the PYTHONPATH variable and if not add it + if not sys.path.__contains__(str(m_current_path)): + sys.path.append(str(m_current_path)) + # retry import now + import WorkFeature + +WorkFeature.myDialog = WorkFeature.WorkFeatureTab()