Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active August 12, 2021 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mario52a/0596ad522b151806d5970586a5051e4b to your computer and use it in GitHub Desktop.
Save mario52a/0596ad522b151806d5970586a5051e4b to your computer and use it in GitHub Desktop.
Macro utility for create unique wire with many wires, the type wire created is selected to MakeWire, Bspline, BsplineCurve, BsplineCurve + Arc, Polygon, Bezier curve
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2016 2017 2018 2019 2020 <mario52> *
* *
* This file is a supplement to the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
** **
* Use at your own risk. The author assumes no liability for data loss. *
* It is advised to backup your data frequently. *
* If you do not trust the software do not use it. *
** **
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
#Macro_DXF_to_Shape 01/11/2015 /_00 13/02/2020_00
#
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.16.6706 (Git)
#Build type: Release
#Branch: releases/FreeCAD-0-16
#Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
#Python version: 2.7.8
#Qt version: 4.8.7
#Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17
#
__title__ ="Macro_DXF_to_Shape"
__author__ = "mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = " modified 00.00"
__date__ = "2020/09/04" #YYYY/MM/DD
__Comment__ = "Still in development and not finished"
__Web__ = ""
__Wiki__ = ""
__IconL__ = ""
__IconW__ = ""
__Help__ = ""
__Status__ = "prototype Not finished"
__Requires__ = ""
__Communication__ = ""
# original modifie Curve : line 1835 28/11/2016 mouse mode 01-02-2017
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, math, PartGui, FreeCADGui
import FreeCAD
App = FreeCAD
Gui = FreeCADGui
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
import OpenSCAD2Dgeom
import os
import copy
# reproduire une serie de lignes pour en faire une seule et doit fonctionner avec sweep ici sauver dans le fichier les vecteurs
global path ;
#path = FreeCAD.ConfigGet("AppHomePath") # app install
#path = FreeCAD.ConfigGet("UserAppData") # user app config
path = "C:/Provisoire400/"+"DXF_ASC/" # your path
App.Console.PrintMessage("Path temporary file : " + path + "\n")
global sel ; sel = "" # selection
global nomFichier ; nomFichier = "FCDataTest_XYZ.asc"# temporary file
global OpenName ; OpenName = ""
global lecture ; lecture = 1 # writeData= 0 readData= 1
global revers ; revers = 0 # 0=Reversed 1=Forward 2=Neutral
global createLine ; createLine = 1 # 1=Create line 0=not line
global typeLine ; typeLine = 0 # 0=makeWire 1=BSpline 2=BSplineCurve
global typeArc ; typeArc = 0 # 0=False 1=True
global wireClose ; wireClose = 0 # 0=False 1=True
global wireFace ; wireFace = 0 # 0=False 1=True
global pointsPerMm ; pointsPerMm = 1.0 # precision
global createCloud ; createCloud = 0 # 1=create Cloud
global createShell ; createShell = 0 # 1=create a Shell with a Cloud
global createPoint ; createPoint = 0 # 1=create points
global savedata ; savedata = 0 # save datas 0=XYZ 1=XY 2=YZ 3=XZ
global pp ; pp = [] # list coordinates XYZ
global objectLabel ; objectLabel = "" # object selected
global text ; text = "" # text for display
global comptData ; comptData = 0 # compteur datas
global comptDataSaved ; comptDataSaved = 0 # compteur datas saved in file
global sautData ; sautData = 1 # saut coordonnees
global lineCreate ; lineCreate = "" # create object line
global myCircle ; myCircle = "" # test myCircle
global mySweep ; mySweep = "" # test mySweep
global mySweepSolid ; mySweepSolid = 1 # mySweepSolid 1=yes 0=no
global mySweepFrenet ; mySweepFrenet = 1 # mySweepFrenet 1=yes 0=no
global txtBegin ; txtBegin = "" # txtBegin Begin line
global txtEnd ; txtEnd = "" # txtEnd End Line
global createZero ; createZero = 0 # create the zero in the file coordinate
global rgbPoints ; rgbPoints = [] # rgb color points cloud
global diamCircle ; diamCircle = 0.5 # diameter circle test sweep
global verbose ; verbose = 1 # colore the lines
global suppressBegin ; suppressBegin = 0 # suppress the x first carachter data loaded (cas:X10.0 Y15.0 Z20.0)
global suppressEnd ; suppressEnd = 0 # suppress the x first carachter data loaded (cas:X10.0 Y15.0 Z20.0)
global check_To_Mouse ; check_To_Mouse = 0 # check To Mouse
global vecteurSou ; vecteurSou = "" # vecteur mode Souris #FreeCAD.Vector(0,0,0)
global vecteurSou_Comp; vecteurSou_Comp= 0 # compteur de coordonnees
global file_Mouse ; file_Mouse = "" # file_Mouse
global pointsRead ; pointsRead = [] #
global pointsName ; pointsName = [] #
global Switch_TE_Zoom ; Switch_TE_Zoom = 0 # switch zoom
global s ; s = "" # resident
global ui ; ui = ""
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
#ajouter affiner la forme
#App.ActiveDocument.addObject('Part::Feature','Extrude_DWire').Shape=App.ActiveDocument.Extrude_DWire.Shape.removeSplitter()
#>>> App.ActiveDocument.ActiveObject.Label=App.ActiveDocument.Extrude_DWire.Label
#>>> Gui.ActiveDocument.Extrude_DWire.hide()
#>>>
#>>> Gui.ActiveDocument.ActiveObject.ShapeColor=Gui.ActiveDocument.Extrude_DWire.ShapeColor
#>>> Gui.ActiveDocument.ActiveObject.LineColor=Gui.ActiveDocument.Extrude_DWire.LineColor
#>>> Gui.ActiveDocument.ActiveObject.PointColor=Gui.ActiveDocument.Extrude_DWire.PointColor
#>>> App.ActiveDocument.recompute()
#>>>
####chrono####
import time
global depart ; depart = 0.0
global arrivee; arrivee = 0.0
def Chrono(sec):
#time.strftime('%X %x %Z')#'15:44:07 12/14/19 Paris, Madrid'
global depart
global arrivee
if sec == 0:
depart = time.time()#time.clock()
App.Console.PrintMessage("Chrono begin : "+str(time.strftime('%X'))+"\n")
else:
arrivee = time.time()#time.clock()
App.Console.PrintMessage("Chrono end : "+str(time.strftime('%X'))+"\n")
parcouru = ((arrivee - depart)/60.0)
App.Console.PrintError("Time execution : "+str("%.3f" % parcouru)+" min"+"\n\n")
FreeCADGui.updateGui()
####chrono####
global objectPlacementAngle ; objectPlacementAngle = ""
def objectRealPlacement3D(obj):
global objectPlacementAngle
try:
objectPlacement = obj.Shape.Placement
####
objectPlacementBase = FreeCAD.Vector(objectPlacement.Base)
####
objectWorkCenter = objectPlacementBase
####
objectPlacementAngle = objectPlacement.Rotation.toEuler()
if hasattr(obj, "getGlobalPlacement"):
globalPlacement = obj.getGlobalPlacement()
globalPlacementBase = FreeCAD.Vector(globalPlacement.Base)
objectRealPlacement3D = globalPlacementBase.add(objectWorkCenter).sub(objectPlacementBase)
objectPlacementAngle = globalPlacement.Rotation.toEuler()
else:
objectRealPlacement3D = objectWorkCenter
return objectRealPlacement3D
except Exception:
return FreeCAD.Vector(0.0, 0.0, 0.0)
class Ui_MainWindow(object):
def __init__(self):
self.red = 1.0
self.green = 0.0
self.blue = 0.0
self.alpha = 0.0
self.pointFont = 8.0
def setupUi(self, MainWindow):
global path
global pp
global pointsPerMm
global ui
self.window = MainWindow
self.fontGlobal_08 = QtGui.QFont() # pour compatibilite Windows Linux pour tous les textes
self.fontGlobal_08.setFamily("Arial") # pour compatibilite Windows Linux pour tous les textes
self.fontGlobal_08.setPointSize(self.pointFont)# pour compatibilite Windows Linux pour tous les textes
#self.xxxxx.setFont(self.fontGlobal_08) # Windows Linux
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(311, 655)
MainWindow.setMinimumSize(QtCore.QSize(311, 655))
MainWindow.setMaximumSize(QtCore.QSize(311, 655))
MainWindow.move(925, 115)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.GBox_00_Configuration = QtGui.QGroupBox(self.centralwidget)
self.GBox_00_Configuration.setGeometry(QtCore.QRect(10, 10, 291, 241))
self.GBox_00_Configuration.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_00_Configuration.setFlat(False)
self.GBox_00_Configuration.setObjectName(_fromUtf8("GBox_00_Configuration"))
self.GBox_01_Orientation = QtGui.QGroupBox(self.GBox_00_Configuration)
self.GBox_01_Orientation.setGeometry(QtCore.QRect(10, 20, 131, 81))
self.GBox_01_Orientation.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_01_Orientation.setObjectName(_fromUtf8("GBox_01_Orientation"))
self.RB_01_01_Reversed = QtGui.QRadioButton(self.GBox_01_Orientation)
self.RB_01_01_Reversed.setGeometry(QtCore.QRect(10, 20, 82, 17))
self.RB_01_01_Reversed.setFont(self.fontGlobal_08) # Windows Linux
self.RB_01_01_Reversed.setChecked(True)
self.RB_01_01_Reversed.setToolTip("Revese the coordinates (If Orientation='Reversed')")
self.RB_01_01_Reversed.setObjectName(_fromUtf8("RB_01_01_Reversed"))
self.RB_01_01_Reversed.clicked.connect(self.on_RB_01_01_Reversed_clicked) # connect radioButton_3 on def "on_RB_01_01_Reversed_clicked:"
self.RB_01_02_Forward = QtGui.QRadioButton(self.GBox_01_Orientation)
self.RB_01_02_Forward.setGeometry(QtCore.QRect(10, 40, 82, 17))
self.RB_01_02_Forward.setFont(self.fontGlobal_08) # Windows Linux
self.RB_01_02_Forward.setObjectName(_fromUtf8("RB_01_02_Forward"))
self.RB_01_02_Forward.setToolTip("Revese the coordinates (If Orientation='Forward')")
self.RB_01_02_Forward.clicked.connect(self.on_RB_01_02_Forward_clicked) # connect on def "on_RB_01_02_Forward_clicked:"
self.RB_01_03_Neutral = QtGui.QRadioButton(self.GBox_01_Orientation)
self.RB_01_03_Neutral.setGeometry(QtCore.QRect(10, 60, 82, 17))
self.RB_01_03_Neutral.setFont(self.fontGlobal_08) # Windows Linux
self.RB_01_03_Neutral.setObjectName(_fromUtf8("RB_01_03_Neutral"))
self.RB_01_03_Neutral.setToolTip("Neutral")
self.RB_01_03_Neutral.clicked.connect(self.on_RB_01_03_Neutral_clicked) # connect on def "on_RB_01_03_Neutral_clicked:"
self.CB_01_01_Reverse = QtGui.QCheckBox(self.GBox_01_Orientation)
self.CB_01_01_Reverse.setGeometry(QtCore.QRect(70, 60, 81, 17))
self.CB_01_01_Reverse.setFont(self.fontGlobal_08) # Windows Linux
self.CB_01_01_Reverse.setObjectName(_fromUtf8("CB_01_01_Reverse"))
self.CB_01_01_Reverse.setEnabled(False)
self.CB_01_01_Reverse.setToolTip("Force reverse coordinates")
self.CB_01_01_Reverse.clicked.connect(self.on_CB_01_01_Reverse_clicked) # connect on def "on_CB_01_01_Reverse_clicked"
self.Label_04_01 = QtGui.QLabel(self.GBox_00_Configuration)
self.Label_04_01.setGeometry(QtCore.QRect(10, 105, 271, 16))
self.Label_04_01.setFont(self.fontGlobal_08) # Windows Linux
self.Label_04_01.setObjectName(_fromUtf8("Label_04_01"))
self.Label_04_01.setToolTip("Give the perimeter of the selection ronded '0.1'" + "\n"
"Parenthesis Give the number points: perimeter / precision" + "\n"
" (the wire must be selected)")
self.DSB_00_01_Precision = QtGui.QDoubleSpinBox(self.GBox_00_Configuration)
self.DSB_00_01_Precision.setGeometry(QtCore.QRect(10, 120, 131, 22))
self.DSB_00_01_Precision.setFont(self.fontGlobal_08) # Windows Linux
self.DSB_00_01_Precision.setPrefix(_fromUtf8(""))
self.DSB_00_01_Precision.setDecimals(5)
self.DSB_00_01_Precision.setMinimum(0.00001)
self.DSB_00_01_Precision.setMaximum(99999.99999)
self.DSB_00_01_Precision.setValue(1.0)
self.DSB_00_01_Precision.setObjectName(_fromUtf8("DSB_00_01_Precision"))
self.DSB_00_01_Precision.setToolTip("Give the precision desidered")
# self.DSB_00_01_Precision.valueChanged.connect(self.on_DSB_00_01_Precision_valueChanged) # connect on def "on_DSB_00_01_Precision_valueChanged"
self.DSB_00_01_Precision.valueChanged[float].connect(self.on_DSB_00_01_Precision_valueChanged) # connect on def "on_DSB_00_01_Precision_valueChanged"
self.GBox_02_Type_Line = QtGui.QGroupBox(self.GBox_00_Configuration)
self.GBox_02_Type_Line.setGeometry(QtCore.QRect(150, 20, 131, 121))
self.GBox_02_Type_Line.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_02_Type_Line.setCheckable(True)
self.GBox_02_Type_Line.setObjectName(_fromUtf8("GBox_02_Type_Line"))
self.GBox_02_Type_Line.setToolTip("If the checkBox Type Line is unchecked" + "\n"
"you created one point cloud with the coordinates" + "\n"
"Disponible Point cloud and Points")
self.GBox_02_Type_Line.clicked.connect(self.on_GBox_02_Type_Line_clicked) # connect on def "on_GBox_02_Type_Line_clicked:"
self.RB_02_01_MakeWire = QtGui.QRadioButton(self.GBox_02_Type_Line)
self.RB_02_01_MakeWire.setGeometry(QtCore.QRect(10, 20, 82, 17))
self.RB_02_01_MakeWire.setFont(self.fontGlobal_08) # Windows Linux
self.RB_02_01_MakeWire.setChecked(True)
self.RB_02_01_MakeWire.setObjectName(_fromUtf8("RB_02_01_MakeWire"))
self.RB_02_01_MakeWire.setToolTip("Create wires")
self.RB_02_01_MakeWire.clicked.connect(self.on_RB_02_01_MakeWire_clicked) # connect on def "on_RB_02_01_MakeWire_clicked:"
self.RB_02_02_BSpline = QtGui.QRadioButton(self.GBox_02_Type_Line)
self.RB_02_02_BSpline.setGeometry(QtCore.QRect(10, 40, 82, 17))
self.RB_02_02_BSpline.setFont(self.fontGlobal_08) # Windows Linux
self.RB_02_02_BSpline.setObjectName(_fromUtf8("RB_02_02_BSpline"))
self.RB_02_02_BSpline.setToolTip("Create BSpline")
self.RB_02_02_BSpline.clicked.connect(self.on_RB_02_02_BSpline_clicked) # connect on def "on_RB_02_02_BSpline_clicked:"
self.RB_02_03_BSplineCurve = QtGui.QRadioButton(self.GBox_02_Type_Line)
self.RB_02_03_BSplineCurve.setGeometry(QtCore.QRect(10, 60, 91, 17))
self.RB_02_03_BSplineCurve.setFont(self.fontGlobal_08) # Windows Linux
self.RB_02_03_BSplineCurve.setObjectName(_fromUtf8("RB_02_03_BSplineCurve"))
self.RB_02_03_BSplineCurve.setToolTip("Create BSplineCurve")
self.RB_02_03_BSplineCurve.clicked.connect(self.on_RB_02_03_BSplineCurve_clicked) # connect on def "on_RB_02_03_BSplineCurve_clicked:"
self.CB_02_01_Arc = QtGui.QCheckBox(self.GBox_02_Type_Line)
self.CB_02_01_Arc.setGeometry(QtCore.QRect(95, 60, 70, 17))
self.CB_02_01_Arc.setFont(self.fontGlobal_08) # Windows Linux
self.CB_02_01_Arc.setEnabled(False)
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setObjectName(_fromUtf8("CB_02_01_Arc"))
self.CB_02_01_Arc.setToolTip("Create BSplineCurve Arc")
self.CB_02_01_Arc.clicked.connect(self.on_CB_02_01_Arc_clicked) # connect on def "on_CB_02_01_Arc_clicked"
self.RB_02_04_MakePolygon = QtGui.QRadioButton(self.GBox_02_Type_Line)
# self.RB_02_04_MakePolygon.setEnabled(False)
self.RB_02_04_MakePolygon.setGeometry(QtCore.QRect(10, 80, 111, 17))
self.RB_02_04_MakePolygon.setFont(self.fontGlobal_08) # Windows Linux
self.RB_02_04_MakePolygon.setObjectName(_fromUtf8("RB_02_04_MakePolygon"))
self.RB_02_04_MakePolygon.setToolTip("Create Polygon")
self.RB_02_04_MakePolygon.clicked.connect(self.on_RB_02_04_MakePolygon_clicked) # connect on def "on_RB_02_04_MakePolygon_clicked:"
self.RB_02_05_MakeBezCurve = QtGui.QRadioButton(self.GBox_02_Type_Line)
self.RB_02_05_MakeBezCurve.setGeometry(QtCore.QRect(10, 100, 82, 17))
self.RB_02_05_MakeBezCurve.setFont(self.fontGlobal_08) # Windows Linux
self.RB_02_05_MakeBezCurve.setObjectName(_fromUtf8("RB_02_05_MakeBezCurve"))
self.RB_02_05_MakeBezCurve.setToolTip("Create BezCurve")
self.RB_02_05_MakeBezCurve.clicked.connect(self.on_RB_02_05_MakeBezCurve_clicked) # connect on def "on_RB_02_05_MakeBezCurve_clicked:"
self.GBox_03_Options = QtGui.QGroupBox(self.GBox_00_Configuration)
self.GBox_03_Options.setGeometry(QtCore.QRect(10, 150, 131, 81))
self.GBox_03_Options.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_03_Options.setObjectName(_fromUtf8("GBox_03_Options"))
self.CB_03_01_Close = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_01_Close.setGeometry(QtCore.QRect(10, 20, 51, 17))
self.CB_03_01_Close.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_01_Close.setObjectName(_fromUtf8("CB_03_01_Close"))
self.CB_03_01_Close.setToolTip("Close the wire (if possible)")
self.CB_03_01_Close.clicked.connect(self.on_CB_03_01_Close_clicked) # connect on def "on_CB_03_01_Close_clicked"
self.CB_03_01a_To_Mouse = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_01a_To_Mouse.setGeometry(QtCore.QRect(10, 20, 81, 17))
self.CB_03_01a_To_Mouse.setVisible(False)
self.CB_03_01a_To_Mouse.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_01a_To_Mouse.setObjectName(_fromUtf8("CB_03_01a_To_Mouse"))
self.CB_03_01a_To_Mouse.setToolTip("Save the coordinate to point selected" + "\n"
"The coordinates saved are the coordinates on menu 'Save coordinates'" + "\n"
"The point selected (and saved) is marked hidden" + "\n"
"the points are restitute visible of the end function")
self.CB_03_01a_To_Mouse.clicked.connect(self.on_CB_03_01a_To_Mouse_clicked) # connect on def "on_CB_03_01_Close_clicked"
self.CB_03_01b_CloseFo = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_01b_CloseFo.setGeometry(QtCore.QRect(69, 20, 61, 17))
self.CB_03_01b_CloseFo.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_01b_CloseFo.setObjectName(_fromUtf8("CB_03_01b_CloseFo"))
self.CB_03_01b_CloseFo.setToolTip("Force close wire" + "\n"
"The coordinate [first] is adding in [latest] coordinate")
self.CB_03_01b_CloseFo.clicked.connect(self.on_CB_03_01_Close_clicked) # connect on def "on_CB_03_01_Close_clicked"
self.CB_03_02_Create_Face = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_02_Create_Face.setGeometry(QtCore.QRect(10, 40, 101, 17))
self.CB_03_02_Create_Face.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_02_Create_Face.setObjectName(_fromUtf8("CB_03_02_Create_Face"))
self.CB_03_02_Create_Face.setToolTip("Create face (if possible)")
self.CB_03_02_Create_Face.clicked.connect(self.on_CB_03_02_Create_Face_clicked) # connect on def "on_CB_03_02_Create_Face_clicked"
self.CB_03_02b_Create_Cloud = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_02b_Create_Cloud.setVisible(False)
self.CB_03_02b_Create_Cloud.setGeometry(QtCore.QRect(10, 40, 111, 17))
self.CB_03_02b_Create_Cloud.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_02b_Create_Cloud.setObjectName(_fromUtf8("CB_03_02b_Create_Cloud"))
self.CB_03_02b_Create_Cloud.setToolTip("Create cloud")
self.CB_03_02b_Create_Cloud.clicked.connect(self.on_CB_03_02b_Create_Cloud_clicked) # connect on def "on_CB_03_02b_Create_Cloud_clicked"
self.CB_03_02bb_Create_Shell = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_02bb_Create_Shell.setVisible(False)
self.CB_03_02bb_Create_Shell.setGeometry(QtCore.QRect(85, 40, 46, 17))
self.CB_03_02bb_Create_Shell.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_02bb_Create_Shell.setObjectName(_fromUtf8("CB_03_02bb_Create_Shell"))
self.CB_03_02bb_Create_Shell.setToolTip("Create shell with the cloud")
self.CB_03_02bb_Create_Shell.clicked.connect(self.on_CB_03_02bb_Create_Shell_clicked) # connect on def "on_CB_03_02bb_Create_Shell_clicked"
self.CB_03_03_Create_Points = QtGui.QCheckBox(self.GBox_03_Options)
self.CB_03_03_Create_Points.setGeometry(QtCore.QRect(10, 60, 101, 17))
self.CB_03_03_Create_Points.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_03_Create_Points.setObjectName(_fromUtf8("CB_03_03_Create_Points"))
self.CB_03_03_Create_Points.setToolTip("Create coordinates points in the 3D view")
self.CB_03_03_Create_Points.clicked.connect(self.on_CB_03_03_Create_Points_clicked) # connect on def "on_CB_03_03_Create_Points_clicked"
self.PB_00_Mouse_Mode = QtGui.QPushButton(self.centralwidget)
self.PB_00_Mouse_Mode.setGeometry(QtCore.QRect(20, 180, 131, 61))
self.PB_00_Mouse_Mode.setFont(self.fontGlobal_08) # Windows Linux
self.PB_00_Mouse_Mode.setVisible(False)
self.PB_00_Mouse_Mode.setStyleSheet("color : #008500") # Color text
self.PB_00_Mouse_Mode.setObjectName(_fromUtf8("PB_00_Mouse_Mode"))
self.PB_00_Mouse_Mode.setToolTip("Click to quit the mouse Mode")
self.PB_00_Mouse_Mode.clicked.connect(self.on_PB_00_Mouse_Mode_clicked) # connect on def "on_PB_00_Mouse_Mode_clicked"
self.GBox_04_Coordinates = QtGui.QGroupBox(self.GBox_00_Configuration)
self.GBox_04_Coordinates.setGeometry(QtCore.QRect(149, 150, 131, 81))
self.GBox_04_Coordinates.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_04_Coordinates.setObjectName(_fromUtf8("GBox_04_Coordinates"))
self.RB_04_01_XYZ = QtGui.QRadioButton(self.GBox_04_Coordinates)
self.RB_04_01_XYZ.setGeometry(QtCore.QRect(10, 20, 51, 17))
self.RB_04_01_XYZ.setFont(self.fontGlobal_08) # Windows Linux
self.RB_04_01_XYZ.setChecked(True)
self.RB_04_01_XYZ.setObjectName(_fromUtf8("RB_04_01_XYZ"))
self.RB_04_01_XYZ.setToolTip("Save the coordinates X Y Z")
self.RB_04_01_XYZ.clicked.connect(self.on_RB_04_01_XYZ_clicked) # connect on def "on_RB_04_01_XYZ_clicked:"
self.RB_04_02_XY = QtGui.QRadioButton(self.GBox_04_Coordinates)
self.RB_04_02_XY.setGeometry(QtCore.QRect(10, 40, 51, 17))
self.RB_04_02_XY.setFont(self.fontGlobal_08) # Windows Linux
self.RB_04_02_XY.setObjectName(_fromUtf8("RB_04_02_XY"))
self.RB_04_02_XY.setToolTip("Save the coordinates X Y")
self.RB_04_02_XY.clicked.connect(self.on_RB_04_02_XY_clicked) # connect on def "on_RB_04_02_XY_clicked:"
self.RB_04_03_YZ = QtGui.QRadioButton(self.GBox_04_Coordinates)
self.RB_04_03_YZ.setGeometry(QtCore.QRect(10, 60, 51, 17))
self.RB_04_03_YZ.setFont(self.fontGlobal_08) # Windows Linux
self.RB_04_03_YZ.setObjectName(_fromUtf8("RB_04_03_YZ"))
self.RB_04_03_YZ.setToolTip("Save the coordinates Y Z")
self.RB_04_03_YZ.clicked.connect(self.on_RB_04_03_YZ_clicked) # connect on def "on_RB_04_03_YZ_clicked:"
self.RB_04_04_XZ = QtGui.QRadioButton(self.GBox_04_Coordinates)
self.RB_04_04_XZ.setGeometry(QtCore.QRect(70, 40, 51, 17))
self.RB_04_04_XZ.setFont(self.fontGlobal_08) # Windows Linux
self.RB_04_04_XZ.setObjectName(_fromUtf8("RB_04_04_XZ"))
self.RB_04_04_XZ.setToolTip("Save the coordinates X Z")
self.RB_04_04_XZ.clicked.connect(self.on_RB_04_04_XZ_clicked) # connect on def "on_RB_04_04_XZ_clicked:"
self.CB_04_01_Zero = QtGui.QCheckBox(self.GBox_04_Coordinates)
self.CB_04_01_Zero.setGeometry(QtCore.QRect(70, 60, 61, 17))
self.CB_04_01_Zero.setFont(self.fontGlobal_08) # Windows Linux
self.CB_04_01_Zero.setChecked(False)
self.CB_04_01_Zero.setEnabled(False)
self.CB_04_01_Zero.setObjectName(_fromUtf8("CB_04_01_Zero"))
self.CB_04_01_Zero.setToolTip("Save the coordinates slected for make 3 coordinates"+"\n"
"Example :"+"\n"
"XY = X Y 0.0"+"\n"
"XZ = X 0.0 Z"+"\n"
"YZ = 0.0 Y Z")
self.CB_04_01_Zero.clicked.connect(self.on_CB_04_01_Zero_clicked) # connect on def "on_CB_04_01_Zero_clicked:"
self.CB_04_02_Coma = QtGui.QCheckBox(self.GBox_04_Coordinates)
self.CB_04_02_Coma.setGeometry(QtCore.QRect(70, 20, 56, 18))
self.CB_04_02_Coma.setFont(self.fontGlobal_08) # Windows Linux
self.CB_04_02_Coma.setChecked(False)
self.CB_04_02_Coma.setObjectName(_fromUtf8("CB_04_01_Zero"))
self.CB_04_02_Coma.setToolTip("Save the coordinates with coma separator" + "\n"
"If this option is activated (colored green)" + "\n"
"the data is saved only with the Save button" + "\n"
"If the coma is detected in open file" + "\n"
"the button is automatically colored in green" + "\n"
"Example : X, Y, Z")
self.CB_04_02_Coma.clicked.connect(self.on_CB_04_02_Coma_clicked) # connect on def "on_CB_04_01_Zero_clicked:"
self.GBox_05_Data_Wire_Gui = QtGui.QGroupBox(self.centralwidget)
self.GBox_05_Data_Wire_Gui.setGeometry(QtCore.QRect(10, 260, 291, 241))
self.GBox_05_Data_Wire_Gui.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_05_Data_Wire_Gui.setObjectName(_fromUtf8("GBox_05_Data_Wire_Gui"))
self.GBox_05_Data_Wire_Gui.setToolTip("This section work with the wire creation"+"\n"
"The idea is : save the coordinates of wires in one temporary file for create a wire unique"+"\n"
"The direction of coordinates can be reversed added and saved in the file"+"\n"
"The read file give one object unique with the selected type line")
self.PB_05_01_Wire_For_Test = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_01_Wire_For_Test.setGeometry(QtCore.QRect(10, 150, 84, 23))
self.PB_05_01_Wire_For_Test.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_01_Wire_For_Test.setObjectName(_fromUtf8("PB_05_01_Wire_For_Test"))
self.PB_05_01_Wire_For_Test.setToolTip("Create the forme with the type line checked "+"\n"
"The direction of the line is displayed Begin...End "+"\n"
"The line type is displayed of the button "+"\n")
self.PB_05_01_Wire_For_Test.clicked.connect(self.on_PB_05_01_Wire_For_Test_clicked) # connect on def "on_PB_05_01_Wire_For_Test_clicked"
self.Label_05_01_Data = QtGui.QLabel(self.GBox_05_Data_Wire_Gui)
self.Label_05_01_Data.setGeometry(QtCore.QRect(10, 110, 271, 16))
self.Label_05_01_Data.setFont(self.fontGlobal_08) # Windows Linux
self.Label_05_01_Data.setObjectName(_fromUtf8("Label_05_01_Data"))
self.PB_05_03_Reuse = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_03_Reuse.setGeometry(QtCore.QRect(104, 150, 84, 23))
self.PB_05_03_Reuse.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_03_Reuse.setObjectName(_fromUtf8("PB_05_03_Reuse"))
self.PB_05_03_Reuse.setToolTip("Reuse the data in memory"+"\n"
"Reuse work with the type line selected")
self.PB_05_03_Reuse.clicked.connect(self.on_PB_05_03_Reuse_clicked) # connect on def "on_PB_05_03_Reuse_clicked"
self.PB_05_02_Reset_Data = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_02_Reset_Data.setGeometry(QtCore.QRect(198, 150, 84, 23))
self.PB_05_02_Reset_Data.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_02_Reset_Data.setObjectName(_fromUtf8("PB_05_02_Reset_Data"))
self.PB_05_02_Reset_Data.setToolTip("Reset the data in memory")
self.PB_05_02_Reset_Data.clicked.connect(self.on_PB_05_02_Reset_Data_clicked) # connect on def "on_PB_05_02_Reset_Data_clicked"
self.PB_05_04_ClearTE = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_04_ClearTE.setGeometry(QtCore.QRect(10, 210, 61, 23))
self.PB_05_04_ClearTE.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_04_ClearTE.setObjectName(_fromUtf8("PB_05_04_ClearTE"))
self.PB_05_04_ClearTE.setToolTip("Clean the window list data textEdit")
self.PB_05_04_ClearTE.clicked.connect(self.on_PB_05_04_ClearTE_clicked) # connect on def "on_PB_05_04_ClearTE_clicked"
self.PB_05_04b_Zoom = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_04b_Zoom.setGeometry(QtCore.QRect(76, 210, 18, 23))
self.PB_05_04b_Zoom.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_04b_Zoom.setObjectName(_fromUtf8("PB_05_04b_Zoom"))
self.PB_05_04b_Zoom.setToolTip("Zoom the window list data textEdit")
self.PB_05_04b_Zoom.clicked.connect(self.on_PB_05_04b_Zoom_clicked) # connect on def "on_PB_05_04b_Zoom_clicked"
self.PB_05_05_ClearRView = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_05_ClearRView.setGeometry(QtCore.QRect(104, 210, 84, 23))
self.PB_05_05_ClearRView.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_05_ClearRView.setObjectName(_fromUtf8("PB_05_05_ClearRView"))
self.PB_05_05_ClearRView.setToolTip("Clean the window Report view")
self.PB_05_05_ClearRView.clicked.connect(self.on_PB_05_05_ClearRView_clicked) # connect on def "on_PB_05_05_ClearRView_clicked"
self.PB_05_06_Del_Line = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_06_Del_Line.setGeometry(QtCore.QRect(198, 180, 84, 23)) #198, 210, 84, 23
self.PB_05_06_Del_Line.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_06_Del_Line.setObjectName(_fromUtf8("PB_05_06_Del_Line"))
self.PB_05_06_Del_Line.setToolTip("Delete the last line created (object)")
self.PB_05_06_Del_Line.clicked.connect(self.on_PB_05_06_Del_Line_clicked) # connect on def "on_PB_05_03_Reuse_clicked"
self.PB_05_07_Test_Sweep = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_07_Test_Sweep.setGeometry(QtCore.QRect(10, 180, 71, 23))
self.PB_05_07_Test_Sweep.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_07_Test_Sweep.setObjectName(_fromUtf8("PB_05_07_Test_Sweep"))
self.PB_05_07_Test_Sweep.setToolTip("Create sweep for testing")
self.PB_05_07_Test_Sweep.clicked.connect(self.on_PB_05_07_Test_Sweep_clicked) # connect on def "on_PB_05_07_Test_Sweep_clicked"
self.PB_05_08_Recompute = QtGui.QPushButton(self.GBox_05_Data_Wire_Gui)
self.PB_05_08_Recompute.setGeometry(QtCore.QRect(198, 210, 84, 23)) #198, 180, 84, 23
self.PB_05_08_Recompute.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_08_Recompute.setObjectName(_fromUtf8("PB_05_08_Recompute"))
self.PB_05_08_Recompute.setToolTip("recompute the 3D view")
self.PB_05_08_Recompute.clicked.connect(self.on_PB_05_08_Recompute_clicked) # connect on def "on_PB_05_08_Recompute_clicked"
self.TE_05_01_textEdit = QtGui.QTextEdit(self.GBox_05_Data_Wire_Gui)
self.TE_05_01_textEdit.setGeometry(QtCore.QRect(10, 20, 271, 81))
self.TE_05_01_textEdit.setFont(self.fontGlobal_08) # Windows Linux
self.TE_05_01_textEdit.setToolTip("display the last operation")
self.TE_05_01_textEdit.setObjectName(_fromUtf8("TE_05_01_textEdit"))
self.PBar_05_01_ProgressBar = QtGui.QProgressBar(self.GBox_05_Data_Wire_Gui)
self.PBar_05_01_ProgressBar.setGeometry(QtCore.QRect(10, 130, 270, 16))
self.PBar_05_01_ProgressBar.setToolTip(_fromUtf8(""))
# self.PBar_05_01_ProgressBar.setLayoutDirection(QtCore.Qt.LeftToRight)
self.PBar_05_01_ProgressBar.setAlignment(QtCore.Qt.AlignCenter)
self.PBar_05_01_ProgressBar.setMinimum(0)
self.PBar_05_01_ProgressBar.setValue(0)
# self.PBar_05_01_ProgressBar.setTextVisible(True)
self.PBar_05_01_ProgressBar.setOrientation(QtCore.Qt.Horizontal)
self.PBar_05_01_ProgressBar.setObjectName(_fromUtf8("PBar_05_01_ProgressBar"))
self.SP_05_01_Dia_Circle = QtGui.QSpinBox(self.GBox_05_Data_Wire_Gui)
self.SP_05_01_Dia_Circle.setGeometry(QtCore.QRect(90, 180, 42, 22))
self.SP_05_01_Dia_Circle.setFont(self.fontGlobal_08) # Windows Linux
self.SP_05_01_Dia_Circle.setValue(diamCircle)
self.SP_05_01_Dia_Circle.setSuffix(" r")
self.SP_05_01_Dia_Circle.setMinimum(1)
self.SP_05_01_Dia_Circle.setMaximum(99999)
self.SP_05_01_Dia_Circle.setObjectName(_fromUtf8("SP_05_01_Dia_Circle"))
self.SP_05_01_Dia_Circle.valueChanged.connect(self.on_SP_05_01_Dia_Circle_valueChanged) # connect on def "on_SP_05_01_Dia_Circle_valueChanged"
self.CB_05_01_Solid = QtGui.QCheckBox(self.GBox_05_Data_Wire_Gui)
self.CB_05_01_Solid.setGeometry(QtCore.QRect(140, 176, 51, 17))
self.CB_05_01_Solid.setFont(self.fontGlobal_08) # Windows Linux
self.CB_05_01_Solid.setChecked(True)
self.CB_05_01_Solid.setObjectName(_fromUtf8("CB_05_01_Solid"))
self.CB_05_01_Solid.setToolTip("Create solid sweep to see if the sweep is rigth")
self.CB_05_01_Solid.clicked.connect(self.on_CB_05_01_Solid_clicked) # connect on "def on_CB_05_01_Solid_clicked:"
self.CB_05_02_Frenet = QtGui.QCheckBox(self.GBox_05_Data_Wire_Gui)
self.CB_05_02_Frenet.setGeometry(QtCore.QRect(140, 190, 51, 17))
self.CB_05_02_Frenet.setFont(self.fontGlobal_08) # Windows Linux
self.CB_05_02_Frenet.setChecked(True)
self.CB_05_02_Frenet.setObjectName(_fromUtf8("CB_05_02_Frenet"))
self.CB_05_02_Frenet.setToolTip("Create frenet sweep")
self.CB_05_02_Frenet.clicked.connect(self.on_CB_05_02_Frenet_clicked) # connect on def "on_CB_05_02_Frenet_clicked:"
self.GBox_06_Data_File = QtGui.QGroupBox(self.centralwidget)
self.GBox_06_Data_File.setGeometry(QtCore.QRect(10, 510, 291, 51))
self.GBox_06_Data_File.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_06_Data_File.setObjectName(_fromUtf8("GBox_06_Data_File"))
self.GBox_06_Data_File.setToolTip("This section save the coordinate of wire in the temporary file")
self.PB_06_01_Save_Data_File = QtGui.QPushButton(self.GBox_06_Data_File)
self.PB_06_01_Save_Data_File.setGeometry(QtCore.QRect(10, 20, 51, 23))
self.PB_06_01_Save_Data_File.setFont(self.fontGlobal_08) # Windows Linux
self.PB_06_01_Save_Data_File.setObjectName(_fromUtf8("PB_06_01_Save_Data_File"))
self.PB_06_01_Save_Data_File.setToolTip("Save the coordinates in the temporary file")
self.PB_06_01_Save_Data_File.clicked.connect(self.on_PB_06_01_Save_Data_File_clicked) # connect on def "on_PB_06_01_Save_Data_File_clicked"
self.CB_06_01_Contigu_Data = QtGui.QCheckBox(self.GBox_06_Data_File)
self.CB_06_01_Contigu_Data.setGeometry(QtCore.QRect(65, 25, 51, 17))
self.CB_06_01_Contigu_Data.setFont(self.fontGlobal_08) # Windows Linux
self.CB_06_01_Contigu_Data.setChecked(False)
self.CB_06_01_Contigu_Data.setObjectName(_fromUtf8("CB_06_01_Contigu_Data"))
self.CB_06_01_Contigu_Data.setToolTip("If the second wire selected is contiguous" + "\n"
"check this checkbox for delette the first coordinate" + "\n"
" not create two coordinate with the same value")
# self.CB_06_01_Contigu_Data.clicked.connect(self.on_CB_06_01_Contigu_Data_clicked) # connect on "def on_CB_05_01_Solid_clicked:"
self.PB_06_02_Read_Data_File = QtGui.QPushButton(self.GBox_06_Data_File)
self.PB_06_02_Read_Data_File.setGeometry(QtCore.QRect(115, 20, 51, 23))
self.PB_06_02_Read_Data_File.setFont(self.fontGlobal_08) # Windows Linux
self.PB_06_02_Read_Data_File.setObjectName(_fromUtf8("PB_06_02_Read_Data_File"))
self.PB_06_02_Read_Data_File.setToolTip("Read the coordinates saved in the temporary file")
self.PB_06_02_Read_Data_File.clicked.connect(self.on_PB_06_02_Read_Data_File_clicked) # connect on def "PB_06_02_Read_Data_File"
self.SP_06_01_Step = QtGui.QSpinBox(self.GBox_06_Data_File)
self.SP_06_01_Step.setGeometry(QtCore.QRect(174, 20, 51, 22))
self.SP_06_01_Step.setFont(self.fontGlobal_08) # Windows Linux
self.SP_06_01_Step.setMinimum(1)
self.SP_06_01_Step.setMaximum(9999)
self.SP_06_01_Step.setObjectName(_fromUtf8("SP_06_01_Step"))
self.SP_06_01_Step.setToolTip("Step in read the coordinates")
self.SP_06_01_Step.valueChanged.connect(self.on_SP_06_01_Step_valueChanged) # connect on def "on_doubleSpinBox_2_valueChanged"
self.PB_06_03_Reset_Data_File = QtGui.QPushButton(self.GBox_06_Data_File)
self.PB_06_03_Reset_Data_File.setGeometry(QtCore.QRect(232, 20, 51, 23))
self.PB_06_03_Reset_Data_File.setFont(self.fontGlobal_08) # Windows Linux
self.PB_06_03_Reset_Data_File.setObjectName(_fromUtf8("PB_06_03_Reset_Data_File"))
self.PB_06_03_Reset_Data_File.setToolTip("Reset the coordinates in the temporary file")
self.PB_06_03_Reset_Data_File.clicked.connect(self.on_PB_06_03_Reset_Data_File_clicked) # connect on def "on_PB_06_03_Reset_Data_File_clicked"
self.GBox_07_Button = QtGui.QGroupBox(self.centralwidget)
self.GBox_07_Button.setGeometry(QtCore.QRect(10, 575, 291, 71))
self.GBox_07_Button.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_07_Button.setObjectName(_fromUtf8("GBox_07_Button"))
self.PB_01_Save = QtGui.QPushButton(self.GBox_07_Button)
self.PB_01_Save.setGeometry(QtCore.QRect(10, 10, 40, 23))
self.PB_01_Save.setFont(self.fontGlobal_08) # Windows Linux
self.PB_01_Save.setObjectName(_fromUtf8("PB_01_Save"))
self.PB_01_Save.setToolTip("Save the coordinates" + "\n"
"(Save the temporary file 'FCDataTest_XYZ' if exist)" + "\n"
"Create Wire, Bspline, Point .... for create coordinate in memory" + "\n"
"and save the coordinate with the 'Save DataT' button" + "\n"
"and now push the Save button")
self.PB_01_Save.clicked.connect(self.on_PB_01_Save_clicked) # connect on def "on_PB_01_Save_clicked"
self.PB_02_Read = QtGui.QPushButton(self.GBox_07_Button)
self.PB_02_Read.setGeometry(QtCore.QRect(57, 10, 40, 23))
self.PB_02_Read.setFont(self.fontGlobal_08) # Windows Linux
self.PB_02_Read.setObjectName(_fromUtf8("PB_02_Read"))
self.PB_02_Read.setToolTip("Read the file .asc, .pcd, .txt")
self.PB_02_Read.clicked.connect(self.on_PB_02_Read_clicked) # connect on def "on_PB_02_Read_clicked"
self.SP_01_suppressBegin = QtGui.QSpinBox(self.GBox_07_Button)
self.SP_01_suppressBegin.setGeometry(QtCore.QRect(105, 10, 42, 22))
self.SP_01_suppressBegin.setFont(self.fontGlobal_08) # Windows Linux
self.SP_01_suppressBegin.setValue(suppressBegin)
self.SP_01_suppressBegin.setSuffix(" >")
self.SP_01_suppressBegin.setMinimum(0)
self.SP_01_suppressBegin.setMaximum(99999)
self.SP_01_suppressBegin.setObjectName(_fromUtf8("SP_01_suppressBegin"))
self.SP_01_suppressBegin.setToolTip("Cut the string of x characters from the left" + "\n"
"Example :" + "\n"
"X12.042769Z1.390658Y0.0000" + "\n"
"X12.045179Z1.390658Y0.0000" + "\n"
"X12.047590Z1.390658Y0.0000" + "\n"
"X12.050000Z1.390658Y0.0000") #https://forum.freecadweb.org/viewtopic.php?f=3&t=4217&start=100
self.SP_01_suppressBegin.valueChanged.connect(self.on_SP_01_suppressBegin_valueChanged) # connect on def "on_SP_05_01_Dia_Circle_valueChanged"
self.SP_02_suppressEnd = QtGui.QSpinBox(self.GBox_07_Button)
self.SP_02_suppressEnd.setGeometry(QtCore.QRect(155, 10, 42, 22))
self.SP_02_suppressEnd.setFont(self.fontGlobal_08) # Windows Linux
self.SP_02_suppressEnd.setValue(suppressEnd)
self.SP_02_suppressEnd.setSuffix(" <")
self.SP_02_suppressEnd.setMinimum(0)
self.SP_02_suppressEnd.setMaximum(99999)
self.SP_02_suppressEnd.setObjectName(_fromUtf8("SP_02_suppressEnd"))
self.SP_02_suppressEnd.setToolTip("Cut the string of x characters from the rigth")
self.SP_02_suppressEnd.valueChanged.connect(self.on_SP_02_suppressEnd_valueChanged) # connect on def "on_SP_05_01_Dia_Circle_valueChanged"
self.PB_05_Dowgrade = QtGui.QPushButton(self.GBox_07_Button)
self.PB_05_Dowgrade.setGeometry(QtCore.QRect(205, 10, 40, 23))
self.PB_05_Dowgrade.setFont(self.fontGlobal_08) # Windows Linux
self.PB_05_Dowgrade.setObjectName(_fromUtf8("PB_05_Dowgrade"))
self.PB_05_Dowgrade.setToolTip("Downgrade the object")
self.PB_05_Dowgrade.clicked.connect(self.on_PB_05_Dowgrade_clicked) # connect on def "on_PB_05_Color_clicked"
self.PB_03_Reset = QtGui.QPushButton(self.GBox_07_Button)
self.PB_03_Reset.setGeometry(QtCore.QRect(10, 40, 40, 23))
self.PB_03_Reset.setFont(self.fontGlobal_08) # Windows Linux
self.PB_03_Reset.setObjectName(_fromUtf8("PB_03_Reset"))
self.PB_03_Reset.setToolTip("Reset the macro")
self.PB_03_Reset.clicked.connect(self.on_PB_03_Reset_clicked) # connect on def "on_PB_03_Reset_clicked"
self.PB_04_Color = QtGui.QPushButton(self.GBox_07_Button)
self.PB_04_Color.setGeometry(QtCore.QRect(57, 40, 40, 23))
self.PB_04_Color.setFont(self.fontGlobal_08) # Windows Linux
self.PB_04_Color.setObjectName(_fromUtf8("PB_04_Color"))
self.PB_04_Color.setToolTip("Color of object")
self.PB_04_Color.clicked.connect(self.on_PB_04_Color_clicked) # connect on def "on_PB_05_Color_clicked"
self.PB_07_Duplicate = QtGui.QPushButton(self.GBox_07_Button)
self.PB_07_Duplicate.setGeometry(QtCore.QRect(105, 40, 40, 23))
self.PB_07_Duplicate.setFont(self.fontGlobal_08) # Windows Linux
self.PB_07_Duplicate.setObjectName(_fromUtf8("PB_07_Duplicate"))
self.PB_07_Duplicate.setToolTip("Duplicate the edge(s)/face(s) selected")
self.PB_07_Duplicate.clicked.connect(self.on_PB_07_Duplicate_clicked) # connect on def "on_PB_05_Color_clicked"
self.PB_06_Quit = QtGui.QPushButton(self.GBox_07_Button)
self.PB_06_Quit.setGeometry(QtCore.QRect(205, 40, 40, 23))
self.PB_06_Quit.setFont(self.fontGlobal_08) # Windows Linux
self.PB_06_Quit.setObjectName(_fromUtf8("PB_06_Quit"))
self.PB_06_Quit.setToolTip("\n"+"Quit the macro"+"\n"
"A window open and asks if you want to keep the file" + "\n"
"If you wild save the temporary file, give a name and validate")
self.PB_06_Quit.clicked.connect(self.on_PB_06_Quit_clicked) # connect on def "on_PB_04_Quit_clicked"
self.CB_00_Verbose = QtGui.QCheckBox(self.GBox_07_Button)
self.CB_00_Verbose.setGeometry(QtCore.QRect(260, 10, 13, 17))
self.CB_00_Verbose.setFont(self.fontGlobal_08) # Windows Linux
self.CB_00_Verbose.setChecked(True)
self.CB_00_Verbose.setObjectName(_fromUtf8("CB_00_Verbose"))
self.CB_00_Verbose.setToolTip("Create lines with defaut color")
self.CB_00_Verbose.clicked.connect(self.on_CB_00_Verbose_clicked) # connect on def "on_CB_00_Verbose_clicked"
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle("FCDxf to Shape" + __version__)
MainWindow.setWindowIcon(QtGui.QIcon(path + "Macro_Dxf_to_Shape.png")) # change l'icone de la fenetre principale
MainWindow.setWindowFlags(Qt.WindowFlags(Qt.WindowMinimizeButtonHint)) # - ( max X )
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant
self.GBox_00_Configuration.setTitle("Configuration")
self.DSB_00_01_Precision.setSuffix(" mm")
self.GBox_01_Orientation.setTitle("Orientation")
self.RB_01_01_Reversed.setText("Reversed")
self.RB_01_02_Forward.setText("Forward")
self.RB_01_03_Neutral.setText("Neutral")
self.CB_01_01_Reverse.setText("Reverse")
self.GBox_02_Type_Line.setTitle("Type Line")
self.RB_02_01_MakeWire.setText("MakeWire")
self.RB_02_02_BSpline.setText("BSpline")
self.RB_02_03_BSplineCurve.setText("BSplineCurve")
self.RB_02_04_MakePolygon.setText("Polygon")
self.RB_02_05_MakeBezCurve.setText("BezCurve")
self.CB_02_01_Arc.setText("Arc")
self.GBox_03_Options.setTitle("Options")
self.CB_03_01_Close.setText("Close")
self.CB_03_01a_To_Mouse.setText("To Mouse")
self.CB_03_01b_CloseFo.setText("Forced")
self.CB_03_02_Create_Face.setText("Create face")
self.CB_03_02b_Create_Cloud.setText("Create Cloud")
self.CB_03_02bb_Create_Shell.setText("Shell")
self.CB_03_03_Create_Points.setText("Create points")
self.GBox_04_Coordinates.setTitle("Save coordinates")
self.RB_04_01_XYZ.setText("X Y Z")
self.RB_04_02_XY.setText("X Y")
self.RB_04_03_YZ.setText("Y Z")
self.RB_04_04_XZ.setText("X Z")
self.CB_04_01_Zero.setText("Zero")
self.CB_04_02_Coma.setText("Coma")
self.GBox_05_Data_Wire_Gui.setTitle("Data wire Gui testing")
self.TE_05_01_textEdit.setText("List Data object saved in file")
self.Label_05_01_Data.setText("Data object : ")
self.Label_04_01.setText("Perim.(Se) : "+str("-.-"))
self.PB_05_01_Wire_For_Test.setText("Ok MakeWire")
self.PB_05_02_Reset_Data.setText("Reset data")
self.PB_05_03_Reuse.setText("Reuse")
self.PB_05_04_ClearTE.setText("Clear TEdit")
self.PB_05_04b_Zoom.setText("Z")
self.PB_05_06_Del_Line.setText("Del Test")
self.CB_05_01_Solid.setText("Solid")
self.CB_05_02_Frenet.setText("Frenet")
self.PB_05_05_ClearRView.setText("Clear RepV")
self.PB_05_07_Test_Sweep.setText("Test Sweep")
self.PB_05_08_Recompute.setText("Recompute")
self.GBox_06_Data_File.setTitle("Data file Temporary")
self.PB_06_01_Save_Data_File.setText("Save DT")
self.CB_06_01_Contigu_Data.setText("Cont.")
self.PB_06_02_Read_Data_File.setText("Read DT")
self.SP_06_01_Step.setSuffix(" Step")
self.PB_06_03_Reset_Data_File.setText("Reset DataT")
self.PB_00_Mouse_Mode.setText("Click for Quit\nMouse Mode\n")
self.PB_01_Save.setText("Save")
self.PB_02_Read.setText("Read")
self.PB_03_Reset.setText("Reset")
self.PB_04_Color.setText("Color")
self.PB_05_Dowgrade.setText("Explo")
self.PB_07_Duplicate.setText("Duplic")
self.PB_06_Quit.setText("Quit")
#Part.sortEdges()
def on_RB_01_01_Reversed_clicked(self): # on_RB_01_01_Reversed_clicked
global revers
revers = 0
self.CB_01_01_Reverse.setEnabled(False)
self.CB_01_01_Reverse.setChecked(False)
# print( "on_RB_01_01_Reversed_clicked ",str(revers))
def on_RB_01_02_Forward_clicked(self): # on_RB_01_02_Forward_clicked
global revers
revers = 1
self.CB_01_01_Reverse.setEnabled(False)
self.CB_01_01_Reverse.setChecked(False)
# print( "on_RB_01_02_Forward_clicked ",str(revers))
def on_RB_01_03_Neutral_clicked(self): # on_RB_01_03_Neutral_clicked
global revers
revers = 2
self.CB_01_01_Reverse.setEnabled(True)
self.CB_01_01_Reverse.setChecked(False)
# print( "on_RB_01_03_Neutral_clicked ",str(revers))
def on_CB_01_01_Reverse_clicked(self): # on_CB_01_01_Reverse_clicked
global revers
if self.CB_01_01_Reverse.isChecked():
revers = 3
else:
revers = 2
# print( "on_RB_01_03_Neutral_clicked ",str(revers))
def on_RB_02_01_MakeWire_clicked(self): # on_RB_02_01_MakeWire_clicked
global typeLine
global typeArc
typeLine = 0
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setEnabled(False)
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok MakeWire")
# print( "on_RB_02_01_MakeWire_clicked ",str(typeLine))
def on_GBox_02_Type_Line_clicked(self): # on_GBox_02_Type_Line_clicked
global createLine
global wireClose
global wireFace
global createCloud
global createShell
wireClose = 0
wireFace = 0
createCloud = 0
createShell = 0
if self.GBox_02_Type_Line.isChecked():
createLine = 1
# revers = 3
# self.RB_01_01_Reversed.setChecked(False)
# self.RB_01_02_Forward.setVisible(True)
# self.RB_01_03_Neutral.setVisible(True)
self.CB_03_01_Close.setVisible(True)
self.CB_03_01a_To_Mouse.setVisible(False)
self.PB_00_Mouse_Mode.setVisible(False)
self.CB_03_01b_CloseFo.setVisible(True)
self.CB_03_02_Create_Face.setVisible(True)
self.CB_03_02b_Create_Cloud.setVisible(False)
self.CB_03_02bb_Create_Shell.setVisible(False)
self.PB_05_01_Wire_For_Test.setText("Ok MakeWire")
else:
createLine = 0
# revers = 0
# self.RB_01_01_Reversed.setChecked(True)
# self.RB_01_02_Forward.setVisible(False)
# self.RB_01_03_Neutral.setVisible(False)
self.CB_03_01_Close.setChecked(False)
self.CB_03_01_Close.setVisible(False)
self.CB_03_01a_To_Mouse.setChecked(False)
self.CB_03_01a_To_Mouse.setVisible(True)
self.CB_03_01b_CloseFo.setChecked(False)
self.CB_03_01b_CloseFo.setVisible(False)
self.CB_03_02_Create_Face.setChecked(False)
self.CB_03_02_Create_Face.setVisible(False)
self.CB_03_02b_Create_Cloud.setChecked(False)
self.CB_03_02b_Create_Cloud.setEnabled(True)
self.CB_03_02b_Create_Cloud.setVisible(True)
if createCloud == 1:
self.CB_03_02bb_Create_Shell.setChecked(False)
self.CB_03_02bb_Create_Shell.setEnabled(True)
self.CB_03_02bb_Create_Shell.setVisible(True)
self.PB_05_01_Wire_For_Test.setText("Ok Points")
# print( "on_GBox_02_Type_Line_clicked ",str(createLine))
def on_RB_02_02_BSpline_clicked(self): # on_RB_02_02_BSpline_clicked
global typeLine
global typeArc
typeLine = 1
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setEnabled(False)
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok BSpline")
# print( "on_RB_02_02_BSpline_clicked ",str(typeLine))
def on_RB_02_03_BSplineCurve_clicked(self): # on_RB_02_03_BSplineCurve_clicked
global typeLine
global typeArc
typeLine = 2
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setEnabled(True)
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok BSplineCur.")
# print( "on_RB_02_03_BSplineCurve_clicked ",str(typeLine))
def on_CB_02_01_Arc_clicked(self): # on_CB_02_01_Arc_clicked
global typeArc
if self.RB_02_03_BSplineCurve.isChecked():
self.CB_02_01_Arc.setEnabled(True)
if self.CB_02_01_Arc.isChecked():
typeArc = 1
self.PB_05_01_Wire_For_Test.setText("Ok BSplineCur+")
else:
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok BSplineCur.")
else:
self.CB_02_01_Arc.setEnabled(False)
# print( "CB_02_01_Arc KO ",str(typeArc))
def on_RB_02_04_MakePolygon_clicked(self): # on_RB_02_04_MakePolygon_clicked
global typeLine
global typeArc
typeLine = 3
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setEnabled(False)
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok Polygon")
# print( "on_RB_02_04_MakePolygon_clicked ",str(typeLine))
def on_RB_02_05_MakeBezCurve_clicked(self): # on_RB_02_05_MakeBezCurve_clicked
global typeLine
global typeArc
typeLine = 4
self.CB_02_01_Arc.setChecked(False)
self.CB_02_01_Arc.setEnabled(False)
typeArc = 0
self.PB_05_01_Wire_For_Test.setText("Ok BezCurve")
# print( "on_RB_02_05_MakeBezCurve_clicked ",str(typeLine))
def mouse_Mode(self): # mouse mode
global vecteurSou
global vecteurSou_Comp
global pointsRead
global pp
pointsRead.append(str(vecteurSou[0])+" "+ str(vecteurSou[1])+" "+ str(vecteurSou[2])+"\n")
pp.append(FreeCAD.Vector(float(vecteurSou[0]),float(vecteurSou[1]),float(vecteurSou[2])))
Gui.ActiveDocument.getObject(pointsName[vecteurSou_Comp]).Visibility=False
self.TE_05_01_textEdit.append(str(vecteurSou_Comp) + ": " + str(vecteurSou))
# pp = pointsRead
# pp = copy.deepcopy(pointsRead)
vecteurSou_Comp += 1
self.TE_05_01_textEdit.verticalScrollBar().setValue(len(pointsRead)*((self.pointFont * 4))) #
self.TE_05_01_textEdit.verticalScrollBar().setSliderPosition(len(pointsRead)*((self.pointFont * 4))) #
# print( "mouse_Mode ",str(typeLine))
def on_CB_03_01a_To_Mouse_clicked(self): # on_CB_03_00_To_Mouse_clicked
global createCloud
global createPoint
global check_To_Mouse
global path
global nomFichier
global pp
global Switch_TE_Zoom
# print( path + nomFichier, " on_CB_03_01a_To_Mouse_clicked")
# print( pp)
# file = open(path + nomFichier, "w") # vide the temporary file # verifier
# file.close()
Switch_TE_Zoom = 0
ui.on_PB_05_04b_Zoom_clicked()
check_To_Mouse = 1
self.CB_03_02b_Create_Cloud.setChecked(False)
createCloud = 0
self.CB_03_02bb_Create_Shell.setChecked(False)
createShell = 0
self.CB_03_03_Create_Points.setChecked(False)
createPoint = 0
self.GBox_00_Configuration.setEnabled(False)
self.GBox_05_Data_Wire_Gui.setEnabled(False)
self.GBox_06_Data_File.setEnabled(False)
self.PB_00_Mouse_Mode.setVisible(True)
self.TE_05_01_textEdit.setText("Mode ToMouse")
# print( "on_CB_03_01a_To_Mouse_clicked ", (check_To_Mouse))
def on_PB_00_Mouse_Mode_clicked(self): # quit Mouse_Mode
global check_To_Mouse
global vecteurSou_Comp
global pointsRead
global pointsName
global path
global nomFichier
global pp
global Switch_TE_Zoom
# try:
# file = open(path + nomFichier, "w") # open the file r=read w=write a=append
# for i in pointsRead:
# file.write(i)
# X, Y, Z = i.split(" ")
# pp.append(FreeCAD.Vector(float(X),float(Y),float(Z))) # append the coordinates XYZ
# file.close()
# except Exception:
# App.Console.PrintWarning( "Error in creation file" + "\n")
# pp = copy.deepcopy(pointsRead)
print( pp)
#ici
self.GBox_02_Type_Line.setChecked(True)
ui.on_GBox_02_Type_Line_clicked()
# ui.on_PB_05_01_Wire_For_Test_clicked()
ui.on_PB_06_01_Save_Data_File_clicked()
# ui.createWire()
Switch_TE_Zoom = 1
ui.on_PB_05_04b_Zoom_clicked()
# try:
# for obj in FreeCAD.ActiveDocument.Objects: # deslectionne tout
# FreeCADGui.Selection.removeSelection(obj)
# except Exception:
# None
for object in pointsName:
print( object)
Gui.ActiveDocument.getObject(object).Visibility=True
# try:
FreeCADGui.Selection.removeSelection(App.ActiveDocument.getObject(object)) # deslectionne
# except Exception:
# None
check_To_Mouse = 0
vecteurSou_Comp = 0
del pointsRead[:]
del pointsName[:]
self.CB_03_01a_To_Mouse.setChecked(False)
self.GBox_00_Configuration.setEnabled(True)
self.GBox_05_Data_Wire_Gui.setEnabled(True)
self.GBox_06_Data_File.setEnabled(True)
self.PB_00_Mouse_Mode.setVisible(False)
# print( "on_PB_00_Mouse_Mode_clicked ")
def on_CB_03_01_Close_clicked(self): # on_CB_03_01_Close_clicked
global wireClose
wireClose = 0
if self.CB_03_01_Close.isChecked():
wireClose = 1
if self.CB_03_01b_CloseFo.isChecked():
wireClose = 2
# print( "CB_01_Close ", str(wireClose))
def on_CB_03_02_Create_Face_clicked(self): # on_CB_03_02_Create_Face_clicked
global wireFace
if self.CB_03_02_Create_Face.isChecked():
wireFace = 1
else:
wireFace = 0
# print( "CB_02_Create_Face ", str(wireFace))
def on_CB_03_02b_Create_Cloud_clicked(self): # on_CB_03_02b_Create_Cloud_clicked
global createCloud
global createShell
createShell = 0
if self.CB_03_02b_Create_Cloud.isChecked():
createCloud = 1
self.CB_03_02bb_Create_Shell.setVisible(True)
else:
createCloud = 0
self.CB_03_02bb_Create_Shell.setVisible(False)
self.CB_03_02bb_Create_Shell.setChecked(False)
print( "on_CB_03_02b_Create_Cloud_clicked Cl Sh ", str(createCloud)," ", str(createShell))
def on_CB_03_02bb_Create_Shell_clicked(self): # on_CB_03_02bbCreate_Shell_clicked
global createCloud
global createShell
if createCloud == 1:
if self.CB_03_02bb_Create_Shell.isChecked():
createShell = 1
else:
createShell = 0
print( "on_CB_03_02bbCreate_Shell_clicked Cl Sh ", str(createCloud)," ", str(createShell))
def on_CB_03_03_Create_Points_clicked(self): # on_CB_03_03_Create_Points_clicked
global createPoint
if self.CB_03_03_Create_Points.isChecked():
createPoint = 1
else:
createPoint = 0
# print( "CB_03_Create_Points ", str(createPoint))
def on_RB_04_01_XYZ_clicked(self): # on_RB_04_01_XYZ_clicked
global savedata
global createZero
self.CB_04_01_Zero.setEnabled(False)
self.CB_04_01_Zero.setChecked(False)
savedata = 0
createZero = 0
self.RB_04_02_XY.setText("X Y")
self.RB_04_03_YZ.setText("Y Z")
self.RB_04_04_XZ.setText("X Z")
# print( "on_RB_04_01_XYZ_clicked ", str(savedata))
def on_RB_04_02_XY_clicked(self): # on_RB_04_02_XY_clicked
global savedata
self.CB_04_01_Zero.setEnabled(True)
savedata = 1
# print( "on_RB_04_02_XY_clicked ", str(savedata))
def on_RB_04_03_YZ_clicked(self): # on_RB_04_03_YZ_clicked
global savedata
self.CB_04_01_Zero.setEnabled(True)
savedata = 2
# print( "on_RB_04_03_YZ_clicked ", str(savedata))
def on_RB_04_04_XZ_clicked(self): # on_RB_04_04_XZ_clicked
global savedata
self.CB_04_01_Zero.setEnabled(True)
savedata = 3
# print( "on_RB_04_04_XZ_clicked ", str(savedata))
def on_CB_04_01_Zero_clicked(self):
global createZero
if self.CB_04_01_Zero.isChecked():
createZero = 1
self.RB_04_02_XY.setText("X Y 0")
self.RB_04_03_YZ.setText("0 Y Z")
self.RB_04_04_XZ.setText("X 0 Z")
else:
createZero = 0
self.RB_04_02_XY.setText("X Y")
self.RB_04_03_YZ.setText("Y Z")
self.RB_04_04_XZ.setText("X Z")
# print( "on_CB_04_01_Zero_clicked ", str(createZero))
def on_CB_04_02_Coma_clicked(self):
if self.CB_04_02_Coma.isChecked():
self.CB_04_02_Coma.setStyleSheet("background-color: green") # origin system
else:
self.CB_04_02_Coma.setStyleSheet("background-color: QPalette.Base") # origin system
print( "on_CB_04_02_Coma_clicked ", str(""))
def on_Label_04_01(self): # upgrade length ,value
global pointsPerMm
sel = FreeCADGui.Selection.getSelection()
perimetre = 0.0
try:
for j in enumerate(sel[0].Shape.Edges):
perimetre += (sel[0].Shape.Edges[j[0]].Length)
self.Label_04_01.setText("Perim.(Se) : "+str(round(perimetre,1))+" ("+ str(int((perimetre)/(pointsPerMm))+1) + ")")
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
except Exception:
None
# print( "on_Label_04_01 ")
def on_DSB_00_01_Precision_valueChanged(self,value): # on_DSB_00_01_Precision_valueChanged
global pointsPerMm
global ui
if value <= 1 :
self.DSB_00_01_Precision.setSingleStep(0.1)
else:
self.DSB_00_01_Precision.setSingleStep(1.0)
pointsPerMm = value
ff = ui
ff.on_Label_04_01()
# print( "on_DSB_00_01_Precision_valueChanged ",str(value))
def createWire(self): # Create wire
import FreeCADGui, FreeCAD
global OpenName
global pp
global createLine
global typeLine
global typeArc
global revers # 0=Reversed 1=Forward 2=Neutral
global wireFace
global wireClose
global createCloud
global createShell
global createPoint
global objectLabel
global pointsPerMm
global text
global lineCreate
global txtBegin
global txtEnd
global rgbPoints
def colored(text): # colored the line and text
import FreeCADGui, FreeCAD
global OpenName
global createLine
global createCloud
global createShell
global createPoint
global objectLabel
global pointsPerMm
global revers
global txtBegin
global txtEnd
global rgbPoints
global verbose
if revers == 0:
text += "_Reversed"
elif revers == 1:
text += "_Forward"
elif revers == 2:
text += "_Neutral"
elif revers == 3:
text += "_Neutral_Forced"
FreeCAD.ActiveDocument.ActiveObject.Label = objectLabel + " " + text + "_Prec(" + str(pointsPerMm) + ")" # give Label
self.TE_05_01_textEdit.append(objectLabel + " " + text + "_Prec(" + str(pointsPerMm) + ")")
if verbose == 1:
FreeCADGui.activeDocument().activeObject().LineColor = (self.red, self.green, self.blue) # give LineColor
FreeCADGui.activeDocument().activeObject().PointColor = (self.red, self.green, self.blue) # give PointColor
FreeCADGui.activeDocument().activeObject().ShapeColor = (self.red, self.green, self.blue) # give ShapeColor
try:
diagonale = FreeCAD.ActiveDocument.ActiveObject.Shape.BoundBox.DiagonalLength # diagonal object for Height text
except Exception:
diagonale = 60.0
if pp[1] == pp[len(pp)-2]:
txtBegin = Draft.makeText(["Begin"],point=FreeCAD.Vector(pp[0])) # create text Begin
else:
txtBegin = Draft.makeText(["Begin"],point=FreeCAD.Vector(pp[1])) # create text Begin
FreeCADGui.activeDocument().getObject(txtBegin.Label).FontSize = diagonale / 6.0
if verbose == 1:
FreeCADGui.activeDocument().getObject(txtBegin.Label).TextColor = (0.0, 1.0, 0.0)
txtBegin.Label = objectLabel + "_Begin"
txtEnd = Draft.makeText(["End"],point=FreeCAD.Vector(pp[len(pp)-2])) # create text End
FreeCADGui.activeDocument().getObject(txtEnd.Label).FontSize = diagonale / 6.0
if verbose == 1:
FreeCADGui.activeDocument().getObject(txtEnd.Label).TextColor = (1.0, 0.0, 0.0)
txtEnd.Label = objectLabel + "_End"
Gui.updateGui() # rafraichi l'ecran
self.Label_05_01_Data.setText("Number coordinates : " + str(len(pp)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
Gui.updateGui() # rafraichi l'ecran
try:
if len(pp) != 0:
self.PB_05_06_Del_Line.setStyleSheet("background-color: green") # green
if createCloud != 0: # create Cloud
import Points
pnt=Points.Points()
for i in range(len(pp)):
a = FreeCAD.Vector(float(pp[i][0]), float(pp[i][1]), float(pp[i][2]))
pnt.addPoints([a])
Points.show(pnt)
FreeCAD.ActiveDocument.ActiveObject.Label = "Points_" + OpenName # give cloud Label
if createShell == 1:
print("A faire")
# https://www.freecadweb.org/wiki/TopoShape_API
#################### adapter ######################
#https://forum.freecadweb.org/viewtopic.php?f=13&t=40000&start=10
# shape = App.ActiveDocument.Compound001.Shape
# p = shape.Vertexes
# h = 72.0 # diesen Wert erhält man aus der Bounding-Box
# w = 142.0
# s = 2.0 # diesen Wert erhält man durch Messen
# width = w/s + 1
# height = h/s + 1
# # Das erzeugt ein dict mit Index-Wert -> Punkt
# map={}
# for i in p:
# x=i.Point.x
# y=i.Point.y
# xi=x/s
# yi=y/s
# index=int(yi*width + xi)
# map[index]=i.Point
# # durch Sortieren kann man das an eine geordnete Punktewolke übergeben
# sorted_map={}
# for i in sorted(map.keys()):
# sorted_map[i] = map[i]
# import Points
# pts=Points.Points()
# pts.addPoints(list(sorted_map.values()))
# sp=App.ActiveDocument.addObject("Points::Structured", "Cloud")
# sp.Width=int(width)
# sp.Height=int(height)
# sp.Points=pts
# App.ActiveDocument.recompute()
##########################################
if createPoint != 0: # create points
self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
self.PBar_05_01_ProgressBar.setMaximum(len(pp)) # ProgressBar
self.TE_05_01_textEdit.append("Create " + str(len(pp)) + " points ")
for i in range(len(pp)):
Draft.makePoint(pp[i]) # create points
try:
FreeCADGui.activeDocument().activeObject().PointColor = (rgbPoints[i][0],rgbPoints[i][1],rgbPoints[i][2])
except Exception:
FreeCADGui.activeDocument().activeObject().PointColor = (self.red, self.green, self.blue)
self.PBar_05_01_ProgressBar.setValue(i+1) # ProgressBar
self.PBar_05_01_ProgressBar.setValue(0) # ProgressBar
# self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
# self.PBar_05_01_ProgressBar.setMaximum(0) # ProgressBar
if createLine == 1:
if typeLine == 1:
# try:
#https://forum.freecadweb.org/viewtopic.php?f=3&t=7827&p=174209#p174209
#import Draft
#sels=Gui.Selection.getSelection()
#for sel in sels:
# for w in sel.Shape.Wires:
# pts=[v.Point for v in w.Vertexes]
# r=Draft.makeWire(pts)
# r.Label="DW for " +sel.Label
# r=Draft.makeBSpline(pts)
# r.Label="Spline for " +sel.Label
# pts=r.Shape.Edge1.Curve.discretize(500)
# r2=Draft.makeBSpline(pts)
# r2.Label="Spline 500 for " +sel.Label
print( pp)
pts =pp
lineCreate=Draft.makeBSpline(pts)
# lineCreate = Draft.makeBSpline(pp) # Ok avec courbes makeBSpline
text = "_makeBSpline"
colored(text)
self.RB_02_02_BSpline.setChecked(True)
# except Exception:
# App.Console.PrintWarning("Type line makeBSpline abandoned try with BSplineCurve" + "\n")
# typeLine = 2
if typeLine == 2:
try:
###https://forum.freecadweb.org/viewtopic.php?f=3&t=22653&p=175919#p175919
###obj = FreeCAD.ActiveDocument.getObject("DWire")
###pts = [v.Point for v in obj.Shape.Vertexes]
###import Part
###bs = Part.BSplineCurve()
###bs.interpolate(pts)
###Part.show(bs.toShape())
#lineCreate = Part.BSplineCurve() # OK avec courbes BSplineCurve 1
#lineCreate.interpolate(pp)#,False) # OK avec courbes BSplineCurve 1
#lineCreate = Part.Edge(lineCreate) # OK avec courbes BSplineCurve 1
#Part.show(lineCreate) # OK avec courbes BSplineCurve 1
#self.RB_02_03_BSplineCurve.setChecked(True) # OK avec courbes BSplineCurve 1
#text = "_BSplineCurve 1" # OK avec courbes BSplineCurve 1
#App.Console.PrintMessage("_BSplineCurve 1" + "\n") # OK avec courbes BSplineCurve 1
lineCreate = Part.BSplineCurve() # OK avec courbes BSplineCurve 2
lineCreate.buildFromPoles(pp) # OK avec courbes BSplineCurve 2
Part.show(lineCreate.toShape()) # OK avec courbes BSplineCurve 2
lineCreate = App.ActiveDocument.ActiveObject # OK avec courbes BSplineCurve 2
self.RB_02_03_BSplineCurve.setChecked(True) # OK avec courbes BSplineCurve 2
text = "_BSplineCurve 2" # OK avec courbes BSplineCurve 2
App.Console.PrintMessage("_BSplineCurve 2" + "\n") # OK avec courbes BSplineCurve 2
colored(text)
if typeArc == 1: # OK with BSplineCurve toBiArcs version 0.16 !!!
try:
arcs=lineCreate.toBiArcs(0.01)
arcs
lineCreate = App.ActiveDocument.ActiveObject
text = "_BSplineCurvetoBiArcs"
App.Console.PrintMessage("_BSplineCurvetoBiArcs" + "\n")
colored(text)
except Exception:
App.Console.PrintError("Error toBiArcs" + "\n")
except Exception:
App.Console.PrintMessage("type line BSplineCurve abandoned try with makePolygon" + "\n")
typeLine = 3
if typeLine == 3:
try:
lineCreate = Part.makePolygon(pp) # makePolygon
Part.show(lineCreate)
lineCreate = App.ActiveDocument.ActiveObject
self.RB_02_04_MakePolygon.setChecked(True)
text = "_makePolygon"
App.Console.PrintMessage("_makePolygon" + "\n")
colored(text)
except Exception:
App.Console.PrintWarning("Type line _makePolygon abandoned try with makeBezCurve" + "\n")
typeLine = 4
if typeLine == 4:
try:
lineCreate = Draft.makeBezCurve(pp,closed=False,support=None) # makeBezCurve
text = "_makeBezCurve"
App.Console.PrintMessage("_makeBezCurve" + "\n")
colored(text)
except Exception:
App.Console.PrintWarning("Type line _makeBezCurve abandoned try with makeWire" + "\n")
typeLine = 0
if typeLine == 0:
lineCreate = Draft.makeWire(pp,closed=False,face=False,support=None) # makeWire
self.RB_02_01_MakeWire.setChecked(True)
text = "_makeWire"
App.Console.PrintMessage("_makeWire" + "\n")
colored(text)
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: green")
self.PB_05_02_Reset_Data.setStyleSheet("background-color: green")
self.PB_05_03_Reuse.setStyleSheet("background-color: green")
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: green") # green
import FreeCAD, FreeCADGui
doc=App.ActiveDocument.Name
try: # Wire close or open
if wireClose == 0:
FreeCAD.getDocument(doc).getObject(lineCreate.Name).Closed = False
else:
FreeCAD.getDocument(doc).getObject(lineCreate.Name).Closed = True
except Exception:
None
try: # face or not face
if wireFace == 0:
lineCreate.MakeFace = False
else:
lineCreate.MakeFace = True
except Exception:
try: # face Shape
faceShape = Part.Wire(lineCreate.Shape)
faceShape1 = Part.Face(faceShape)
Part.show(faceShape1)
FreeCADGui.activeDocument().activeObject().ShapeColor = (1.00,0.00,0.0)
App.ActiveDocument.ActiveObject.Label = objectLabel + "_Face_" + text
#print( "Create face shape ")
except Exception:
#print( "Not face created ")
None
self.PBar_05_01_ProgressBar.setValue(0) # ProgressBar
# self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
# self.PBar_05_01_ProgressBar.setMaximum(0) # ProgressBar
FreeCAD.ActiveDocument.recompute()
else:
App.Console.PrintError("Select object" + "\n")
except Exception:
self.Label_05_01_Data.setText("Standard_ConstructionError try a different type of line " + str(len(pp)))
self.Label_05_01_Data.setStyleSheet("color : #FF0000") # Color text
App.Console.PrintError("Standard_ConstructionError or not document open" + "\n")
def on_PB_05_01_Wire_For_Test_clicked(self):
global objectLabel
global revers
global pp
global pointsPerMm
global wireClose
sel = FreeCADGui.Selection.getSelection()
try:
objectLabel = sel[0].Label
App.Console.PrintMessage("Selection(s) : " + str(len(sel)) + " " + objectLabel + " ("+ str(pointsPerMm) + ")" + "\n")
self.Label_05_01_Data.setText("Data object : Wait")
self.Label_05_01_Data.setStyleSheet("color : #FF0000") # Color text
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_03_Reuse.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_06_Del_Line.setStyleSheet("background-color: green") # green
Gui.updateGui() # rafraichi l'ecran
c = -1
r = 1
p = []
if self.CB_03_01a_To_Mouse.isChecked():
print( pp)
None
else:
pp = []
del pp[:]
# ori try:
self.PBar_05_01_ProgressBar.setMaximum(len(sel)) # ProgressBar
for w in sel:
c += 1
w =sel[c].Shape
w2=Part.Wire(OpenSCAD2Dgeom.findConnectedEdges(w.Edges)[0])
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: green") # green
self.PB_05_02_Reset_Data.setStyleSheet("background-color: green") # green
self.PB_05_03_Reuse.setStyleSheet("background-color: green") # green
comp0 = 0
for e in w2.Edges:
self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
self.PBar_05_01_ProgressBar.setMaximum(0) # ProgressBar
comp0 += 1
try:
points=e.discretize(Distance=pointsPerMm)
# print("1 ",points)
except Exception:
points = [e.Vertexes[0].Point, e.Vertexes[1].Point]
# print(pointsPerMm," ",e.Vertexes[0].Point)
# print("2 ",points)
# if pointsPerMm "ici je ne sais plus pourquoi .. peut etre 0 a travailler "
if revers == 0:
if (str(e.Curve)[1:5] == "Line") and (e.Orientation=="Reversed"):
points.reverse()
elif (str(e.Curve)[0:6] == "Circle") and (e.Orientation=="Reversed"):
points.reverse()
elif (str(e.Curve)[1:8] == "Ellipse") and (e.Orientation=="Reversed"):
points.reverse()
elif (str(e.Curve)[1:13] == "BSplineCurve") and (e.Orientation=="Reversed"):
points.reverse()
elif (str(e.Curve)[1:13] == "BezierCurve") and (e.Orientation=="Reversed"):
points.reverse()
elif revers == 1:
if (str(e.Curve)[1:5] == "Line") and (e.Orientation=="Forward"):
points.reverse()
elif (str(e.Curve)[0:6] == "Circle") and (e.Orientation=="Forward"):
points.reverse()
elif (str(e.Curve)[1:8] == "Ellipse") and (e.Orientation=="Forward"):
points.reverse()
elif (str(e.Curve)[1:13] == "BSplineCurve") and (e.Orientation=="Forward"):
points.reverse()
elif (str(e.Curve)[1:13] == "BezierCurve") and (e.Orientation=="Forward"):
points.reverse()
elif revers == 2:
None
elif revers == 3:
points.reverse()
self.Label_05_01_Data.setText("Number coordinates : " + str(len(pp)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
self.PBar_05_01_ProgressBar.setValue(c) # affect the value "val_X" in PBar_05_01_ProgressBar
p = points
pp += p
del p[:]
if revers == 0:
pp.reverse()
if wireClose == 2:
# pp.append(pp[0])
pp += pp[0]
ff = ui
ff.createWire()
# except Exception:
# App.Console.PrintError("Decoding error or inappropriate object" + "\n")
except Exception:
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(255, 0, 0);") # white and red
App.Console.PrintError("Select one object or error object" + "\n")
self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
self.PBar_05_01_ProgressBar.setMaximum(100) # ProgressBar
self.PBar_05_01_ProgressBar.setValue(0) # ProgressBar
# self.PB_05_06_Del_Line.setStyleSheet("background-color: QPalette.Base") # origin system
# print( "on_PB_05_01_Wire_For_Test_clicked" )
def on_PB_05_02_Reset_Data_clicked(self):
global pp
del pp[:]
self.PBar_05_01_ProgressBar.setValue(0)
self.Label_05_01_Data.setText("Number coordinates : 0")
self.Label_05_01_Data.setStyleSheet("color : #FF0000") # Color text
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_03_Reuse.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_06_Del_Line.setStyleSheet("background-color: QPalette.Base") # origin system
# print( "on_PB_05_02_Reset_Data_clicked")
def on_PB_05_03_Reuse_clicked(self):
global pp
global text
if len(pp) != 0:
text = ""
Gui.updateGui() # rafraichi l'ecran
self.Label_05_01_Data.setText("Number coordinates : " + str(len(pp)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
ff = ui
ff.createWire()
else:
self.Label_05_01_Data.setText("Number coordinates : Not data")
self.Label_05_01_Data.setStyleSheet("color : #FF0000") # Color text
App.Console.PrintError("Not data" + "\n")
self.PB_05_03_Reuse.setStyleSheet("background-color: red") #red
self.PBar_05_01_ProgressBar.setMinimum(0) # ProgressBar
self.PBar_05_01_ProgressBar.setMaximum(100) # ProgressBar
self.PBar_05_01_ProgressBar.setValue(0) # ProgressBar
# print( "on_PB_05_03_Reuse_clicked")
def on_PB_05_04_ClearTE_clicked(self):
self.TE_05_01_textEdit.clear()
self.TE_05_01_textEdit.setText("List Data object history")
# print( "on_PB_05_04_ClearTE_clicked")
def on_PB_05_04b_Zoom_clicked(self):
global Switch_TE_Zoom
if Switch_TE_Zoom == 0:
self.TE_05_01_textEdit.setGeometry(QtCore.QRect(10, 20, 271, 182))
self.CB_05_01_Solid.setVisible(False)
self.CB_05_02_Frenet.setVisible(False)
self.PBar_05_01_ProgressBar.setVisible(False)
self.SP_05_01_Dia_Circle.setVisible(False)
Switch_TE_Zoom = 1
else:
self.TE_05_01_textEdit.setGeometry(QtCore.QRect(10, 20, 271, 81))
self.CB_05_01_Solid.setVisible(True)
self.CB_05_02_Frenet.setVisible(True)
self.PBar_05_01_ProgressBar.setVisible(True)
self.SP_05_01_Dia_Circle.setVisible(True)
Switch_TE_Zoom = 0
# print( "on_PB_05_04b_Zoom_clicked")
def on_PB_05_05_ClearRView_clicked(self): # on_PB_05_05_ClearRView_clicked
try:
mw=Gui.getMainWindow()
r=mw.findChild(QtGui.QTextEdit, "Report view")
r.clear()
except Exception:
None
# print( "on_PB_05_05_ClearRView_clicked")
def on_PB_05_06_Del_Line_clicked(self): # on_PB_05_06_Del_Line_clicked
global lineCreate
global myCircle
global mySweep
global txtBegin
global txtEnd
global text
try:
FreeCAD.ActiveDocument.removeObject(lineCreate.Name)
self.TE_05_01_textEdit.append( str(comptDataSaved) + " : " + objectLabel + " " + text + "_Prec(" + str(pointsPerMm) + ") deleted") # give Label in TE_05_01_textEdit
try:
FreeCAD.ActiveDocument.removeObject(txtBegin.Name)
FreeCAD.ActiveDocument.removeObject(txtEnd.Name)
except Exception:
None
try:
FreeCAD.ActiveDocument.removeObject(myCircle.Name)
FreeCAD.ActiveDocument.removeObject(mySweep.Name)
except Exception:
None
self.PB_05_06_Del_Line.setStyleSheet("background-color: QPalette.Base") # origin system
except Exception:
self.PB_05_06_Del_Line.setStyleSheet("background-color: red") # red
App.Console.PrintError("Error delete object" + "\n")
# print( "on_PB_05_06_Del_Line_clicked")
def on_SP_05_01_Dia_Circle_valueChanged(self,value):
global diamCircle
diamCircle = value
# print( "on_SP_05_01_Dia_Circle_valueChanged")
def on_PB_05_07_Test_Sweep_clicked(self):
global pp
global lineCreate
global objectLabel
global myCircle
global mySweep
global mySweepSolid
global mySweepFrenet
global diamCircle
try:
Chrono(0)
myCircle = Draft.makeCircle(diamCircle)
myCircle.MakeFace = True
myCircle.Label = objectLabel + "_Circle"
pointsDirection = []
pointsDirection = lineCreate.Shape.discretize(Number=500)
#discretize(Number=n) => gives a list of 'n' equidistant points
#discretize(QuasiNumber=n) => gives a list of 'n' quasi equidistant points (is faster than the method above)
#discretize(Distance=d) => gives a list of equidistant points with distance 'd'
#discretize(Deflection=d) => gives a list of points with a maximum deflection 'd' to the edge
#discretize(QuasiDeflection=d) => gives a list of points with a maximum deflection 'd' to the edge (faster)
#discretize(Angular=a,Curvature=c,[Minimum=m]) => gives a list of points with an angular deflection of 'a'
directionOriginalObject = pointsDirection[0].sub(pointsDirection[1]) # avec vecteurs 1 et 2 (direction debut ligne)
v=pointsDirection[0].sub(pointsDirection[1]) # avec vecteurs 1 et 2 (direction debut ligne)
#directionOriginalObject = pointsDirection[0].sub(pointsDirection[-1]) #avec vecteurs extremites (direction objet)
#v=pointsDirection[0].sub(pointsDirection[-1]) #avec vecteurs extremites (direction objet)
r=App.Rotation(App.Vector(0,0,1),v) # original
v=directionOriginalObject
pl=FreeCAD.Placement()
pl.Rotation.Q = r.Q
pl.Base = pp[0]
myCircle.Placement = pl
del pointsDirection[:]
text = ""
except Exception:
App.Console.PrintError("Error create circle" + "\n")
try:
mySweep = App.activeDocument().addObject('Part::Sweep','mySweepTest')
mySweep.Sections = [myCircle]
mySweep.Spine = lineCreate
if mySweepSolid == 1:
mySweep.Solid = True
text = "True"
else:
mySweep.Solid = False
text = "False"
if mySweepFrenet == 1:
mySweep.Frenet = True
text += " - True"
else:
mySweep.Frenet = False
text += " - False"
#mySweep.Transition = 1 #1=angle droit 2=courbe
mySweep.Label = objectLabel + "_mySweepTest"
FreeCAD.ActiveDocument.recompute()
self.TE_05_01_textEdit.append( objectLabel + " " + text + "_Prec(" + str(pointsPerMm) + ") Sweep") # give Label in TE_05_01_textEdit
except Exception:
try:
FreeCADGui.ActiveDocument.removeObject(myCircle.Name)
except Exception:
None
try:
FreeCADGui.ActiveDocument.removeObject(mySweep.Name)
except Exception:
None
App.Console.PrintError("Error create sweep" + "\n")
Chrono(1)
# print( "on_PB_05_07_Test_Sweep_clicked")
def on_CB_05_01_Solid_clicked(self): # on_CB_05_01_Solid_clicked
global mySweepSolid
if self.CB_05_01_Solid.isChecked():
mySweepSolid = 1
else:
mySweepSolid = 0
print( "on_CB_05_01_Solid_clicked ", str(mySweepSolid))
def on_CB_05_02_Frenet_clicked(self): # on_CB_05_02_Frenet_clicked
global mySweepFrenet
if self.CB_05_02_Frenet.isChecked():
mySweepFrenet = 1
else:
mySweepFrenet = 0
print( "on_CB_05_01_Solid_clicked ", str(mySweepFrenet))
def on_PB_05_08_Recompute_clicked(self):
import FreeCAD
FreeCAD.ActiveDocument.recompute()
# print( "on_PB_05_08_Recompute_clicked ")
def on_PB_06_01_Save_Data_File_clicked(self): #on_PB_06_01_Save_Data_File_clicked save data Tmp
global pp
global path
global nomFichier
global objectLabel
global pointsPerMm
global text
global comptDataSaved
global savedata
global createZero
if len(pp) != 0:
comptDataSaved += 1
nomFichier2 = nomFichier.split(".")
nomFichier2 = nomFichier2[-2][:-3]
# nomFichier2 = nomFichier2[:-3]
if savedata == 0: # XYZ
nomFichier2 = nomFichier
elif savedata == 1: # XY
if createZero == 1:
nomFichier2 += "XY0.asc"
else:
nomFichier2 += "XY-.asc"
elif savedata == 2: # YZ
if createZero == 1:
nomFichier2 += "0YZ.asc"
else:
nomFichier2 += "-YZ.asc"
elif savedata == 3: # XZ
if createZero == 1:
nomFichier2 += "X0Z.asc"
else:
nomFichier2 += "X-Z.asc"
if self.CB_06_01_Contigu_Data.isChecked:
del pp[0]
file = open(path + nomFichier2, "a") # open the file r=read w=write a=append
App.Console.PrintMessage(nomFichier2 + " ( " + str(len(pp)) + " )" + "\n")
# print( pp)
for i in pp: # save coordinates in file
if savedata == 0: # XYZ
file.write(str(i.x)+" "+str(i.y)+" "+str(i.z)+"\n")
elif savedata == 1: # XY
if createZero == 1:
file.write(str(i.x)+" "+str(i.y)+" 0.0"+"\n")
else:
file.write(str(i.x)+" "+str(i.y)+""+"\n")
elif savedata == 2: # YZ
if createZero == 1:
file.write("0.0 "+str(i.y)+" "+str(i.z)+"\n")
else:
file.write(""+str(i.y)+" "+str(i.z)+"\n")
elif savedata == 3: # XZ
if createZero == 1:
file.write(str(i.x)+" 0.0 "+str(i.z)+"\n")
else:
file.write(str(i.x)+" "+str(i.z)+"\n")
file.close()
del pp[:] #a verifier !!!
self.Label_05_01_Data.setText("Number coordinates : " + str(len(pp)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_03_Reuse.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: green") #green
self.PB_06_02_Read_Data_File.setStyleSheet("background-color: green") #green
self.PB_06_03_Reset_Data_File.setStyleSheet("background-color: green") #green
self.PB_01_Save.setStyleSheet("background-color: green") #green
self.TE_05_01_textEdit.append( str(comptDataSaved) + " : " + objectLabel + " " + text + "_Prec(" + str(pointsPerMm) + ") saved_" + nomFichier2[11:-4]) # give Label in TE_05_01_textEdit
else:
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: red") #red
App.Console.PrintError("Not data to save" + "\n")
# print( "on_PB_06_01_Save_Data_File_clicked")
def decodeData(self,p):
global pp
global createCloud
global createShell
global createPoint
global nomFichier
global comptData
global sautData
global rgbPoints
global suppressBegin
global suppressEnd
X = Y = Z = 0.0
comptData = 0
self.PBar_05_01_ProgressBar.setMinimum(0)
self.PBar_05_01_ProgressBar.setMaximum(len(p))
###### variables for PCD begin
passage = 1 # open the passage PCD datas
VERSION = FIELDS = SIZE = TYPE = COUNT = WIDTH = HEIGHT = VIEWPOINT = POINTS = DATA = ""
rgb = WIDTH_X = HEIGHT_Y = 0.0
del rgbPoints[:]
###### variables for PCD end
longueurExecute = err = 0
longueurFichier = len(p)
print("len file ",len(p))
for ligne in p:
longueurExecute += 1
print( longueurExecute,"/",longueurFichier)
if (p[0].find("PCD") != -1) and (passage == 1) : # The PCD configuration datas are not used in the macro
# http://pointclouds.org/documentation/tutorials/pcd_file_format.php
li2 = ligne.split()
try:
if li2[0] == "VERSION" : VERSION = li2[1] ; print( "VERSION ",VERSION ) # VERSION # .5 # .5 # 0.7 # .7 # .7 #
if li2[0] == "FIELDS" : FIELDS = li2[1] ; print( "FIELDS ",FIELDS ) # FIELDS # x y z # x y z intensity # rgba # x y z # x y z rgb #
if li2[0] == "SIZE" : SIZE = li2[1] ; print( "SIZE ",SIZE ) # SIZE # 4 4 4 # 4 4 4 4 # 4 # 4 4 4 # 4 4 4 4 #
if li2[0] == "TYPE" : TYPE = li2[1] ; print( "TYPE ",TYPE ) # TYPE # F F F # F F F F # U # F F F # F F F F #
if li2[0] == "COUNT" : COUNT = li2[1] ; print( "COUNT ",COUNT ) # COUNT # 1 1 1 # 1 1 1 1 # 1 # 1 1 1 # 1 1 1 1 #
if li2[0] == "WIDTH" : WIDTH = li2[1] ; print( "WIDTH ",WIDTH ) # WIDTH # 397 # 167198 # 640 # 10031 # 213 #
if li2[0] == "HEIGHT" : HEIGHT = li2[1] ; print( "HEIGHT ",HEIGHT ) # HEIGHT # 1 # 1 # 480 # 1 # 1 #
if li2[0] == "VIEWPOINT" : VIEWPOINT = li2[1] ; print( "VIEWPOINT ",VIEWPOINT ) # VIEWPOINT # neant # neant # 0 0 0 1 0 0 0 # 0 0 0 1 0 0 0 # 0 0 0 1 0 0 0 #
if li2[0] == "POINTS" : POINTS = li2[1] ; print( "POINTS ",POINTS ) # POINTS # 397 # 167198 # 307200 # 10031 # 213 #
if li2[0] == "DATA" : # DATA # ascii # ascii # ascii # ascii # ascii #
DATA = li2[1] ; print( "DATA ",DATA ) # DATA # ascii
passage = 0 # Cutting the passage PCD datas
except Exception:
App.Console.PrintError("Error read header PCD" + "\n")
else:
coordinates = ligne.split()
# print( coordinates))
comptData += 1
if (comptData % sautData == 0) and (len(coordinates) != 0):
self.PBar_05_01_ProgressBar.setValue(comptData)
##
## ici pts = X Y Z Intensity R G B.
##100140 = longueur
##0.4042519999999996 -3.476741 -1.634333 53 9 11 6
##
##from FreeCAD import Base
##fichier = str("C:/Provisoire400/DXF_ASC/Autres Points/internet_00.pts")
##print( fichier
##file = open(fichier, "r") # open the file read
##import Points
##pnt=Points.Points()
##pp = []
##long = file.readline()
##print( long
##for ligne in file:
## X,Y,Z,a,b,c,d = ligne.split() # separate the coordinates pour pct
## a = FreeCAD.Vector(float(X), float(Y), float(Z))
## pnt.addPoints([a])
##Points.show(pnt)
##
try: # The PCD configuration ver .7
X, Y, Z, rgb = coordinates # rgb float('4.2108e+06') = 4210800.0 # separate the coordinates 4 fields
try:
a = bin(int(float(rgb)))
b = a[a.find("b")+1:]
rP = float((int(b[len(b)-8:],2)) * (1.0/255.0)) # decode Red color for FreeCAD
gP = float((int(b[len(b)-16:-8],2)) * (1.0/255.0)) # decode Ground color for FreeCAD
bP = float((int(b[:-16],2)) * (1.0/255.0)) # decode Blue color for FreeCAD
rgbPoints.append([rP, gP, bP])
except Exception:
rgbPoints.append([0.0, 1.0, 0.0])
except Exception:
try:
X, Y, Z = coordinates # separate the coordinates 3 fields
except Exception:
try:
X, Y = coordinates # separate the coordinates 2 fields
Z = 0.0
except Exception:
X = WIDTH_X # points as one photo
Y = HEIGHT_Y
Z = 0.0
App.Console.PrintMessage(str(WIDTH_X) +" "+ str(HEIGHT_Y) +" "+ str(WIDTH) + "\n")
if WIDTH_X == (float(WIDTH) - 1):
HEIGHT_Y += 1
WIDTH_X = -1.0
WIDTH_X += 1
a = bin(int(float(ligne)))
b = a[a.find("b")+1:]
try:
rP = float((int(b[len(b)-8:],2)) * (1.0/255.0)) # decode Red color for FreeCAD
except Exception:
rp = 0.0
try:
gP = float((int(b[len(b)-16:-8],2)) * (1.0/255.0)) # decode Ground color for FreeCAD
except Exception:
rp = 0.0
try:
bP = float((int(b[:-16],2)) * (1.0/255.0)) # decode Blue color for FreeCAD
except Exception:
rp = 0.0
rgbPoints.append([rP, gP, bP])
if suppressEnd == 0:
X = X[suppressBegin:]
Y = Y[suppressBegin:]
Z = Z[suppressBegin:]
else:
X = X[suppressBegin:-suppressEnd]
Y = Y[suppressBegin:-suppressEnd]
Z = Z[suppressBegin:-suppressEnd]
try:
pp.append(FreeCAD.Vector(float(X),float(Y),float(Z))) # append the coordinates XYZ
except Exception:
print("Error coordinates type ", coordinates)
# print( "ouille")
# print( X," ",Y," ",Z," ",rP," ",gP," ",bP)
Gui.updateGui() # rafraichi l'ecran
self.PBar_05_01_ProgressBar.setValue(0)
self.TE_05_01_textEdit.append("File : " + nomFichier + "\nNumber coordinates :" + str(comptData))
self.Label_05_01_Data.setText("Number coordinates : " + str(comptData))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
# print( "decodeData")
def on_SP_06_01_Step_valueChanged(self,value): # on_SP_06_01_Step_valueChanged
global sautData
sautData = value
# print( "on_SP_06_01_Step_valueChanged ",str(sautData))
def on_PB_06_02_Read_Data_File_clicked(self): # on_PB_06_02_Read_Data_File_clicked
global path
global nomFichier
global pp
try: # ajouter lire les asc avec entete
file = open(path+nomFichier, "r") # open the file read imposed
del pp[:]
p = []
del p[:]
p = file.readlines()
file.close()
App.Console.PrintMessage("Read : "+ nomFichier + "\n")
self.TE_05_01_textEdit.append("File : " + nomFichier + "\nFile length :" + str(len(p)))
self.Label_05_01_Data.setText("Data object : " + str(len(p)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
ff = ui
ff.decodeData(p)
del p[:]
ff = ui
ff.createWire()
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_03_Reuse.setStyleSheet("background-color: QPalette.Base") # origin system
except Exception:
self.PB_06_02_Read_Data_File.setStyleSheet("background-color: red") #red
App.Console.PrintError("Not file " + path + nomFichier + " existant" + "\n")
# print( "on_PB_06_02_Read_Data_File_clicked")
def on_SP_01_suppressBegin_valueChanged(self,value): # connect on def "on_SP_01_suppressBegin_valueChanged"
global suppressBegin
suppressBegin = value
print("on_SP_01_suppressBegin_valueChanged ",str(suppressBegin))
def on_SP_02_suppressEnd_valueChanged(self,value): # connect on def "on_SP_02_suppressEnd_valueChanged"
global suppressEnd
suppressEnd = value
print("on_SP_02_suppressEnd_valueChanged ",str(suppressEnd))
def on_PB_06_03_Reset_Data_File_clicked(self): # on_PB_06_03_Reset_Data_File_clicked
global path
global nomFichier
global text
global comptData
global comptDataSaved
try:
os.remove(path + nomFichier) # delete the file
App.Console.PrintMessage("File : " + path + nomFichier + " Deleted" + "\n")
text = ""
comptData = 0
comptDataSaved = 0
self.CB_04_02_Coma.setChecked(False)
self.Label_05_01_Data.setText("Number coordinates : " + str(comptData))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_02_Read_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_03_Reset_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_01_Save.setStyleSheet("background-color: QPalette.Base") # origin system
except Exception:
self.PB_06_03_Reset_Data_File.setStyleSheet("background-color: red") #red
App.Console.PrintError("The temporary file " + nomFichier + " not present" + "\n")
# print( "on_PB_06_03_Reset_Data_File_clicked")
def on_PB_01_Save_clicked(self): # on_PB_01_Save_clicked
global path
global nomFichier
# global s
try:
file = open(path + nomFichier, "r") # open the file r=read w=write a=append
##########
if self.CB_04_02_Coma.isChecked(): # create coma instead space
p = []
p = file.readlines()
for i in range(len(p)):
p[i] = p[i].replace(" ",",")
##########
file.close()
self.window.hide() # hide the window open color
pathSave = path
SaveName, Filter = PySide.QtGui.QFileDialog.getSaveFileName(None, "Save a file asc", pathSave, "*.asc") # PySide
if SaveName == "":
App.Console.PrintMessage("Process aborted" + "\n")
else:
nomFichierSave = SaveName
try:
if self.CB_04_02_Coma.isChecked():
f = open(nomFichierSave, 'w')
for i in p:
f.write(i)
f.close()
del p[:]
else:
import shutil
shutil.copy(path + nomFichier, nomFichierSave)
App.Console.PrintMessage("File saved to " + SaveName + "\n")
except Exception:
App.Console.PrintError("Not data for save or error I/O file" + "\n")
self.window.show() # show the window and close color
except Exception:
App.Console.PrintError("Not file " + nomFichier + " for copy" + "\n") # detect error ... display the text in red (PrintError)
## App.Console.PrintMessage("on_PB_01_Save_clicked" + "\n")
def on_PB_02_Read_clicked(self): # on_PB_02_Read_clicked
global pp
global path
global objectLabel
global text
# global comptData
global OpenName
OpenName = ""
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Read a file FCDataTest", path, "*.asc *.pcd *.txt *.pts *.qvd *.dat")#PySide
# retablir try:
if OpenName != "":
# retablir try:
######################################
# print( OpenName)
## if OpenName[-4:].upper() == ".PCD":
# import Points
# print( OpenName)
# Points.open(OpenName)
# print( OpenName[-4:].upper())
######################################
text = ""
del pp[:]
p = []
del p[:]
file = open(OpenName, "r") # open the file r=read w=write a=append
p = file.readlines()
if "," in p[0] != 0: # detect coma in file
self.CB_04_02_Coma.setChecked(True)
self.CB_04_02_Coma.setStyleSheet("background-color: green") # origin system
for i in range(len(p)):
p[i] = p[i].replace(","," ") # replace the coma with space conversion for macro data
file.close()
self.Label_05_01_Data.setText("Data object : " + OpenName + " " + str(len(p)))
self.Label_05_01_Data.setStyleSheet("color : #008500") # Color text
self.TE_05_01_textEdit.append("File : " + OpenName + "\nFile length :" + str(len(p)))
objectLabel = OpenName.split("/")
objectLabel = objectLabel[-1]
ff = ui
ff.decodeData(p)
del p[:]
ff = ui
ff.createWire()
# except Exception:
# App.Console.PrintError("Error read file" + "\n")
self.PBar_05_01_ProgressBar.setValue(0)
# except Exception:
# None
else:
App.Console.PrintMessage("Proces aborded" + "\n")
# print( "on_PB_02_Read_clicked")
def on_PB_03_Reset_clicked(self):
global revers
global createLine
global typeLine
global typeArc
global wireClose
global wireFace
global pointsPerMm
global createCloud
global createShell
global createPoint
global savedata
global pp
global comptData
global comptDataSaved
global sautData
global createZero
global mySweepSolid
global mySweepFrenet
global verbose
global check_To_Mouse
global vecteurSou_Comp
global path
global nomFichier
self.red = 1.0
self.green = 0.0
self.blue = 0.0
self.GBox_00_Configuration.setEnabled(True)
self.GBox_05_Data_Wire_Gui.setEnabled(True)
self.GBox_06_Data_File.setEnabled(True)
check_To_Mouse = 0
vecteurSou_Comp = 0
self.CB_03_01a_To_Mouse.setChecked(False)
self.CB_03_01a_To_Mouse.setVisible(False)
self.PB_00_Mouse_Mode.setVisible(False)
self.CB_01_01_Reverse.setEnabled(False)
self.CB_01_01_Reverse.setChecked(False)
self.TE_05_01_textEdit.clear()
self.TE_05_01_textEdit.setText("List Data object saved in file")
self.Label_05_01_Data.setText("Reset")
self.Label_05_01_Data.setStyleSheet("color : #000000") # Color text
revers = 0
self.RB_01_01_Reversed.setChecked(True)
self.CB_01_01_Reverse.setChecked(False)
self.CB_01_01_Reverse.setEnabled(False)
self.GBox_02_Type_Line.setChecked(True)
createLine = 1
self.RB_02_01_MakeWire.setChecked(True)
typeLine = 0
self.PB_05_01_Wire_For_Test.setText("Ok MakeWire")
self.CB_02_01_Arc.setChecked(False)
typeArc = 0
self.CB_03_01_Close.setChecked(False)
self.CB_03_01_Close.setVisible(True)
self.CB_03_01b_CloseFo.setChecked(False)
self.CB_03_01b_CloseFo.setVisible(True)
wireClose = 0
self.CB_03_02_Create_Face.setChecked(False)
self.CB_03_02_Create_Face.setVisible(True)
wireFace = 0
createCloud = 0
self.CB_03_03_Create_Points.setChecked(False)
self.CB_03_02b_Create_Cloud.setVisible(False)
createPoint = 0
self.CB_03_02bb_Create_Shell.setVisible(False)
createShell = 0
self.DSB_00_01_Precision.setValue(1)
pointsPerMm = 1.0
self.RB_04_01_XYZ.setChecked(True)
savedata = 0
self.CB_04_01_Zero.setChecked(False)
createZero = 0
self.CB_04_02_Coma.setChecked(False)
self.CB_04_02_Coma.setStyleSheet("background-color: QPalette.Base") # origin system
self.RB_04_02_XY.setText("X Y")
self.RB_04_03_YZ.setText("Y Z")
self.RB_04_04_XZ.setText("X Z")
del pp[:]
try:
os.remove(path + nomFichier) # efface FCDataTest_XYZ.asc
except Exception:
None
mySweepSolid = 1
self.CB_05_01_Solid.setChecked(True)
mySweepFrenet = 1
self.CB_05_02_Frenet.setChecked(True)
comptData = 0
comptDataSaved = 0
self.SP_06_01_Step.setValue(1)
sautData = 1
self.CB_00_Verbose.setChecked(True)
verbose = 1
self.CB_06_01_Contigu_Data.setChecked(False)
self.PBar_05_01_ProgressBar.setValue(0)
self.PB_04_Color.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_01_Wire_For_Test.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_02_Reset_Data.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_03_Reuse.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_05_06_Del_Line.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_01_Save_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_02_Read_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_06_03_Reset_Data_File.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_01_Save.setStyleSheet("background-color: QPalette.Base") # origin system
# App.Console.PrintMessage("on_PB_03_Reset_clicked" + "\n")
def on_PB_04_Color_clicked(self):
self.PB_04_Color.setStyleSheet("background-color: QPalette.Base") # origin system
self.window.hide() # hide the window open color
couleur = QtGui.QColorDialog.getColor()
if couleur.isValid():
self.red = couleur.redF()
self.green = couleur.greenF()
self.blue = couleur.blueF()
self.PB_04_Color.setStyleSheet("background-color: rgb("+str(self.red*255)+","+str(self.green*255)+","+str(self.blue*255)+"); color: cmj("+str(255)+","+str(255)+","+str(255)+")")
self.window.show() # show the window and close color
# App.Console.PrintMessage("on_PB_04_Color_clicked" + "\n")
def on_PB_05_Dowgrade_clicked(self): # on_PB_05_Dowgrade_clicked
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True) #False
# App.Console.PrintMessage("on_PB_05_Dowgrade_clicked" + "\n")
def on_PB_07_Duplicate_clicked(self): # on_PB_07_Duplicate_clicked
try:
sel = Gui.Selection.getSelection()
s = Gui.Selection.getSelectionEx()
i2 = ii2 = -1
for i in s:
i2 += 1
ii2 = -1
FreeCADGui.Selection.getSelectionEx()[i2].SubObjects[ii2]
for ii in i.SubElementNames:
placementOrigine = objectRealPlacement3D(FreeCAD.ActiveDocument.getObject(i.ObjectName))# search the original Placement
ii2 += 1
Part.show(FreeCADGui.Selection.getSelectionEx()[i2].SubObjects[ii2].copy()) # create repro shape subObject
#print( i2+1 ,"/", ii2+1 ,"/", len(s) ," ", i.ObjectName ," ", ii) # display the info SubObject
a = App.ActiveDocument.ActiveObject
a.Placement.Base = placementOrigine
a.Placement.Rotation = App.Rotation(objectPlacementAngle[0], objectPlacementAngle[1], objectPlacementAngle[2])
# object Name / original object Name / SubObject Name
a.Label = a.Name + " " + i.ObjectName + " " + ii # Label for the repro shape
try:
FreeCADGui.activeDocument().activeObject().LineColor = (1.0,0.0,0.0) # give LineColor
FreeCADGui.activeDocument().activeObject().PointColor = (1.0,0.0,0.0) # give PointColor
FreeCADGui.activeDocument().activeObject().ShapeColor = (1.0,0.0,0.0) # give ShapeColor
except Exception:
None
except Exception:
#print( "Not SubObject")
None
FreeCAD.ActiveDocument.recompute()
def on_PB_06_Quit_clicked(self): # on_PB_06_Quit_clicked
global path
global nomFichier
global s
FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente
try:
MainWindow.setWindowState(Qt.WindowMinimized) # PySide cette WindowMinimized la fenetre avant de quitter
except Exception:
None
try:
file = open(path + nomFichier, "r") # open the file r=read w=write a=append here for test
file.close()
reply = QtGui.QMessageBox.question(None, "", "Give name for preserve the coordinates file\n or click Cancel to quit",
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
ff = ui
ff.on_PB_01_Save_clicked()
except Exception:
None
if os.path.isfile(path + nomFichier):
try:
os.remove(path + nomFichier) # efface FCDataTest_XYZ.asc
App.Console.PrintMessage(nomFichier + " deleted" + "\n")
except Exception:
App.Console.PrintError("Error delete file" + "\n")
App.Console.PrintMessage("End FCDXF_to_Shape" + "\n")
self.window.hide() # hide the window and close the macro
# App.Console.PrintMessage("on_PB_06_Quit_clicked" + "\n")
def on_CB_00_Verbose_clicked(self):
global verbose
verbose = 0
if self.CB_00_Verbose.isChecked():
verbose = 1
# FreeCAD.Console.PrintMessage("on_CB_00_Verbose_clicked" + "\n")
# def on_textEdit_Changed(self): # on_textEdit_Changed
# texte = unicode(self.TE_05_01_textEdit.toPlainText())
# print( "on_textEdit_Changed ",texte)
##################################################################################################
class SelObserver:
def addSelection(self, document, object, element, position): # Selection
global ui
global check_To_Mouse
global vecteurSou
global pointsName
if check_To_Mouse == 1: # mouse mode
pointsName.append(object)
vecteurSou = FreeCAD.Vector(position)
ff = ui
ff.mouse_Mode()
try:
Object = Gui.Selection.getSelectionEx()[0].SubObjects[0]
# try:
# print( "Curve : ",Object.Curve)
# except Exception:
# print( "No attribute 'Curve'")
print( vecteurSou)
except Exception:
None
ff = ui
ff.on_Label_04_01()
##################################################################################################
doc = FreeCAD.ActiveDocument
if doc == None:
doc = FreeCAD.newDocument()
s=SelObserver()
FreeCADGui.Selection.addObserver(s) # installe the function in resident mode
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
@mario52a
Copy link
Author

This macro utility is intended for the use of the program FreeCAD http://www.freecadweb.org/
The icon for your toolbar, it is to place in your macros directory (in the same location of the macro)
macro_dxf_to_shape rename the image in Macro_Dxf_To_Shape.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment