From 29cad491f5e89d52bfdddad13ae0a6f8267632c8 Mon Sep 17 00:00:00 2001 From: Mark Voltov Date: Tue, 23 May 2023 15:48:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BF=D0=B5=D1=86=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cg/freecad/Frames/AuxObjCreation.py | 286 ++++++++++++++++++ cg/freecad/Frames/BoMList.py | 110 +++++++ cg/freecad/Frames/DatumCommand.py | 49 +++ cg/freecad/Frames/Frames.py | 47 +-- cg/freecad/Frames/InitGui.py | 5 +- cg/freecad/Frames/Sheet_addition_test.py | 60 ++++ cg/freecad/Frames/UI/icons/BoMList.svg | 72 +++++ cg/freecad/Frames/UI/icons/auxDatum.svg | 240 +++++++++++++++ cg/freecad/Frames/box.py | 0 cg/freecad/Frames/newLabel.py | 17 ++ cg/freecad/Frames/testSpread2.py | 77 +++++ .../Frames/usecases/asm4parser_usecase.py | 53 ++++ 12 files changed, 998 insertions(+), 18 deletions(-) create mode 100644 cg/freecad/Frames/AuxObjCreation.py create mode 100644 cg/freecad/Frames/BoMList.py create mode 100644 cg/freecad/Frames/DatumCommand.py create mode 100644 cg/freecad/Frames/Sheet_addition_test.py create mode 100644 cg/freecad/Frames/UI/icons/BoMList.svg create mode 100644 cg/freecad/Frames/UI/icons/auxDatum.svg create mode 100644 cg/freecad/Frames/box.py create mode 100644 cg/freecad/Frames/newLabel.py create mode 100644 cg/freecad/Frames/testSpread2.py create mode 100644 cg/freecad/Frames/usecases/asm4parser_usecase.py diff --git a/cg/freecad/Frames/AuxObjCreation.py b/cg/freecad/Frames/AuxObjCreation.py new file mode 100644 index 0000000..4db00e4 --- /dev/null +++ b/cg/freecad/Frames/AuxObjCreation.py @@ -0,0 +1,286 @@ + + + + " + #Создаем объект, к которому привязываем вспомогательную информацию: + 1. Выбираем элемент в модели: + 1.1. Поверхность - можем создать призматический объект. Соответствует точке захвата, рабочей зоне, опорной поверхности, поверхности базирования + 1.1.1 Выбираем тип объкта, который нам нужно построить. + 1.1.2 В зависимости от выбора, предлагается указать объект для ориентации осей. + 1.1.3 Указать размеры зоны построения. Для захвата соответствует габаритам пальца, для рабочей зоны - координатам. Полуавтоматическое (ручное???) создание эскиза? + 1.1.4 Для захвата выбираем вытягивание объекта на нужную длину до параллельной поверхности + 1.1.5 - Результат - построенный параллелограмм с размерами и привязкой к моделям. Его мы экспортируем в json через существующий функционал + + 1.2. Цилиндрическая поверхность - осесимметричный объект. Захват двухпальцевый, трехпальцевый, четырехпальцевый, цилиндрическая зона установки, отверстия сопряжения + 1.2.1 Выбираем тип объекта + 1.2.2. Выбираем ориентацию главной оси. //Потенциально, мы можем захватить цилиндрический объект в любой ориентации, нужно ли добавлять конкретное указание? + видимо, только если геометрия обязывает нас придерживаться ее (напр. не дает поставить 4 палец) + указание требуется, если есть фиксаторы, опорные площадки или что-то иное, что приводит к однозначному позиционированию + 1.2.3. Вытягиваем зону до привязки. Пальцы ставим как цилиндрический массив( нужно ли??) + 1.2.4 Результат - цилиндрическая зона с радиусом, ориентациями осей. + 2. К размеченным объектам необходимо привязать метаданные, содержащие связи с конкретными моделями. STEP-файл захвата, step-файл входной детали и/или выходной. + 2.1 Нужно ли привязывать захват? Да, но в некоем обобщенном виде. Позиция захвата - характеристика способа воздействия, а не объекта. + 2.2 Для станков входы и выходы необходимы. + 2.3 + " + + + #!/usr/bin/env python3 +# coding: utf-8 +# +# LGPL +# Copyright HUBERT Zoltán +# +# newDatumCmd.py + + +import os + +from PySide import QtGui, QtCore +import FreeCADGui as Gui +import FreeCAD as App +from FreeCAD import Console as FCC + +import Asm4_libs as Asm4 + + + + +""" + +-----------------------------------------------+ + | a class to create all Datum objects | + +-----------------------------------------------+ +""" +class newDatum: + "My tool object" + def __init__(self, datumName): + self.datumName = datumName + # recognised containers (not the same as Asm4.containerTypes !) + self.containers = [ 'App::Part', 'PartDesign::Body', 'App::DocumentObjectGroup'] + if self.datumName == 'Point': + self.datumType = 'PartDesign::Point' + self.menutext = "New Point" + self.tooltip = "Create a new Datum Point in a Part" + self.icon = os.path.join( Asm4.iconPath , 'Asm4_Point.svg') + self.datumColor = (0.00,0.00,0.00) + self.datumAlpha = [] + elif self.datumName == 'Axis': + self.datumType = 'PartDesign::Line' + self.menutext = "New Axis" + self.tooltip = "Create a new Datum Axis in a Part" + self.icon = os.path.join( Asm4.iconPath , 'Asm4_Axis.svg') + self.datumColor = (0.00,0.00,0.50) + self.datumAlpha = [] + elif self.datumName == 'Plane': + self.datumType = 'PartDesign::Plane' + self.menutext = "New Plane" + self.tooltip = "Create a new Datum Plane in a Part" + self.icon = os.path.join( Asm4.iconPath , 'Asm4_Plane.svg') + self.datumColor = (0.50,0.50,0.50) + self.datumAlpha = 80 + elif self.datumName == 'LCS': + self.datumType = 'PartDesign::CoordinateSystem' + self.menutext = "New Coordinate System" + self.tooltip = "Create a new Coordinate System in a Part" + self.icon = os.path.join( Asm4.iconPath , 'Asm4_CoordinateSystem.svg') + self.datumColor = [] + self.datumAlpha = [] + elif self.datumName == 'Sketch': + self.datumType = 'Sketcher::SketchObject' + self.menutext = "New Sketch" + self.tooltip = "Create a new Sketch in a Part" + self.icon = os.path.join( Asm4.iconPath , 'Asm4_Sketch.svg') + self.datumColor = [] + self.datumAlpha = [] + + + def GetResources(self): + return {"MenuText": self.menutext, + "ToolTip": self.tooltip, + "Pixmap" : self.icon } + + + def IsActive(self): + if App.ActiveDocument: + # is something correct selected ? + if self.checkSelection(): + return(True) + return(False) + + + def checkSelection(self): + # if something is selected ... + if Gui.Selection.getSelection(): + selectedObj = Gui.Selection.getSelection()[0] + # ... and it's an App::Part or an datum object + selType = selectedObj.TypeId + if selType in self.containers or selType in Asm4.datumTypes or selType=='Sketcher::SketchObject': + return(selectedObj) + # or of nothing is selected ... + elif Asm4.getAssembly(): + # ... but there is as assembly: + return Asm4.getAssembly() + # if we're here it's because we didn't find a good reason to not be here + return None + + + + """ + +-----------------------------------------------+ + | the real stuff | + +-----------------------------------------------+ + """ + def Activated(self): + # check that we have somewhere to put our stuff + selectedObj = self.checkSelection() + # default name increments the datum type's end numeral + proposedName = Asm4.nextInstance( self.datumName, startAtOne=True ) + + parentContainer = None + # check whether we have selected a container + if selectedObj.TypeId in self.containers: + parentContainer = selectedObj + # if a datum object is selected + elif selectedObj.TypeId in Asm4.datumTypes or selectedObj.TypeId=='Sketcher::SketchObject': + # see whether it's in a container + parent = selectedObj.getParentGeoFeatureGroup() + if parent.TypeId in self.containers: + parentContainer = parent + # if there is an assembly + elif Asm4.getAssembly(): + parentContainer = Asm4.getAssembly() + # something went wrong + else: + Asm4.warningBox("I can't create a "+self.datumType+" with the current selections") + + # check whether there is already a similar datum, and increment the instance number + # instanceNum = 1 + #while App.ActiveDocument.getObject( self.datumName+'_'+str(instanceNum) ): + # instanceNum += 1 + #datumName = self.datumName+'_'+str(instanceNum) + if parentContainer: + # input dialog to ask the user the name of the Sketch: + #proposedName = Asm4.nextInstance( self.datumName + '_' + selectedObj.Label, startAtOne=True ) + text,ok = QtGui.QInputDialog.getText(None,'Create new '+self.datumName, + 'Enter '+self.datumName+' name :'+' '*40, text = proposedName) + if ok and text: + # App.activeDocument().getObject('Model').newObject( 'Sketcher::SketchObject', text ) + createdDatum = App.ActiveDocument.addObject( self.datumType, text ) + parentContainer.addObject( createdDatum ) + createdDatum.Label = text + # automatic resizing of datum Plane sucks, so we set it to manual + if self.datumType=='PartDesign::Plane': + createdDatum.ResizeMode = 'Manual' + createdDatum.Length = 100 + createdDatum.Width = 100 + elif self.datumType=='PartDesign::Line': + createdDatum.ResizeMode = 'Manual' + createdDatum.Length = 200 + # if color or transparency is specified for this datum type + if self.datumColor: + Gui.ActiveDocument.getObject(createdDatum.Name).ShapeColor = self.datumColor + if self.datumAlpha: + Gui.ActiveDocument.getObject(createdDatum.Name).Transparency = self.datumAlpha + # highlight the created datum object + Gui.Selection.clearSelection() + Gui.Selection.addSelection( App.ActiveDocument.Name, parentContainer.Name, createdDatum.Name+'.' ) + Gui.runCommand('Part_EditAttachment') + + + +""" + +-----------------------------------------------+ + | a class to create an LCS on a hole | + +-----------------------------------------------+ +""" +class newHole: + def GetResources(self): + return {"MenuText": "New Hole Axis", + "ToolTip": "Create a Datum Axis attached to a hole", + "Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_Hole.svg') + } + + def IsActive(self): + selection = self.getSelectedEdges() + if selection is None: + return False + else: + return True + + + """ + +-----------------------------------------------+ + | the real stuff | + +-----------------------------------------------+ + """ + def getSelectedEdges(self): + # check that we have selected only circular edges + selection = None + parent = None + edges = [] + # 1 selection means a single parent + if App.ActiveDocument and len(Gui.Selection.getSelection()) == 1: + parent = Gui.Selection.getSelection()[0] + # parse all sub-elemets of the selection + for i in range(len(Gui.Selection.getSelectionEx()[0].SubObjects)): + edgeObj = Gui.Selection.getSelectionEx()[0].SubObjects[i] + edgeName = Gui.Selection.getSelectionEx()[0].SubElementNames[i] + # if the edge is circular + if Asm4.isCircle(edgeObj): + edges.append( [edgeObj,edgeName] ) + # if we found circular edges + if len(edges) > 0: + selection = ( parent, edges ) + return selection + + + def Activated(self): + ( selectedObj, edges ) = self.getSelectedEdges() + for i in range(len(edges)): + edgeObj = edges[i][0] + edgeName = edges[i][1] + parentPart = selectedObj.getParentGeoFeatureGroup() + # we can create a datum only in a container + if parentPart: + parentDoc = parentPart.Document + # if the solid having the edge is indeed in an App::Part + if parentPart and (parentPart.TypeId=='App::Part' or parentPart.TypeId=='PartDesign::Body'): + # check whether there is already a similar datum, and increment the instance number + instanceNum = 1 + while parentDoc.getObject( 'HoleAxis_'+str(instanceNum) ): + instanceNum += 1 + axis = parentPart.newObject('PartDesign::Line','HoleAxis_'+str(instanceNum)) + axis.Support = [( selectedObj, (edgeName,) )] + axis.MapMode = 'AxisOfCurvature' + axis.MapReversed = False + axis.ResizeMode = 'Manual' + axis.Length = edgeObj.BoundBox.DiagonalLength + axis.ViewObject.ShapeColor = (0.0,0.0,1.0) + axis.ViewObject.Transparency = 50 + axis.recompute() + parentPart.recompute() + # + else: + FCC.PrintMessage('Datum objects can only be created inside Part or Body containers') + + + +""" + +-----------------------------------------------+ + | add the commands to the workbench | + +-----------------------------------------------+ +""" +Gui.addCommand( 'Asm4_newPoint', newDatum('Point') ) +Gui.addCommand( 'Asm4_newAxis', newDatum('Axis') ) +Gui.addCommand( 'Asm4_newPlane', newDatum('Plane') ) +Gui.addCommand( 'Asm4_newLCS', newDatum('LCS') ) +Gui.addCommand( 'Asm4_newSketch',newDatum('Sketch')) +Gui.addCommand( 'Asm4_newHole', newHole() ) + +# defines the drop-down button for Datum objects +createDatumList = [ 'Asm4_newLCS', + 'Asm4_newPlane', + 'Asm4_newAxis', + 'Asm4_newPoint', + 'Asm4_newHole' ] +Gui.addCommand( 'Asm4_createDatum', Asm4.dropDownCmd( createDatumList, 'Create Datum Object')) diff --git a/cg/freecad/Frames/BoMList.py b/cg/freecad/Frames/BoMList.py new file mode 100644 index 0000000..fef31eb --- /dev/null +++ b/cg/freecad/Frames/BoMList.py @@ -0,0 +1,110 @@ +from helper.is_solid import is_object_solid +import FreeCAD as App +import Spreadsheet + + +def createSpreadsheet(): + + if App.ActiveDocument.getObject("BoM_List") == None: + + sheet = App.activeDocument().addObject('Spreadsheet::Sheet', 'BoM_List') + sheet.set('A1', 'п.п.') + sheet.set('B1', 'Наименование детали') + sheet.set('C1', 'Количество') + else: + + sheet = App.ActiveDocument.getObject("BoM_List") + App.ActiveDocument.BoM_List.clear('A1:ZZ16384') + sheet.set('A1', 'п.п.') + sheet.set('B1', 'Наименование детали') + sheet.set('C1', 'Количество') + + return (sheet) + + +class SolidBodiesParcer: + _asmThere = [] + + def __init__(self) -> None: + if (self._asmThere.__len__() == 0): + + self.initParse() + pass + + def initParse(self): + for el in App.ActiveDocument.RootObjects: + if (is_object_solid(el) and hasattr(el, 'Group')): + self.getSubPartsLink(el.Group, el.Label) + + def getSubPartsLink(self, group, label): + groupLink = {label: []} + for el in group: + if (is_object_solid(el)): + groupLink[label].append( + {'label': el.Label, 'isGroup': hasattr(el, 'Group'), 'solid': el}) + + for el in groupLink[label]: + if ('isGroup' in el): + if (el['isGroup'] == False): + self._asmThere.append(el['solid'].Label) + if (el['isGroup']): + self.getSubPartsLink(el['solid'].Group, el['label']), + + return groupLink + + +def uniquePartsSort(labelParts): + + uniquePartsLabels = {} + + for el in labelParts: + for k in labelParts: + if (App.ActiveDocument.getObjectsByLabel(str(el))[0].Shape.isPartner(App.ActiveDocument.getObjectsByLabel(str(k))[0].Shape)): + + if uniquePartsLabels.get(el) == None: + uniquePartsLabels[el] = k + + sortedParts = {} + + for k, v in uniquePartsLabels.items(): + + if sortedParts.get(v) == None: + sortedParts[v] = [k] + else: + sortedParts[v].append(k) + + return sortedParts + + +def countForUniques(sortedParts): + countedParts = {} + for k in sortedParts: + countedParts[k] = len(sortedParts[k]) + return countedParts + + +def fillInBoMList(sheet, countedParts): + + a = 1 + + for label, count in countedParts.items(): + a += 1 + b = label + c = count + sheet.set('A' + str(a), str(a-1)) + sheet.set('B' + str(a), str(b)) + sheet.set('C' + str(a), str(c)) + + total_count = sum(countedParts.values()) + sheet.set('B'+str(a+1), 'Итого') + + sheet.set('C' + str(a+1), str(total_count)) + + +def run_BoM_list(): + createSpreadsheet() + sheet = App.ActiveDocument.getObject("BoM_List") + labelParts = SolidBodiesParcer()._asmThere + sortedParts = uniquePartsSort(labelParts) + countedParts = countForUniques(sortedParts) + fillInBoMList(sheet, countedParts) diff --git a/cg/freecad/Frames/DatumCommand.py b/cg/freecad/Frames/DatumCommand.py new file mode 100644 index 0000000..a7db4fd --- /dev/null +++ b/cg/freecad/Frames/DatumCommand.py @@ -0,0 +1,49 @@ +import FreeCAD +import FreeCADGui +from PySide import QtGui, QtCore + +class DatumTool: + """ + A tool for creating datums in existing models + """ + def __init__(self): + self.active = False + + def activate(self): + self.active = True + FreeCAD.Console.PrintMessage("Datum tool activatedn") + + def deactivate(self): + self.active = False + FreeCAD.Console.PrintMessage("Datum tool deactivatedn") + + def mousePressEvent(self, event): + if self.active: + # Create a datum at the position of the mouse click + pos = FreeCADGui.ActiveDocument.ActiveView.getCursorPos() + point = FreeCADGui.ActiveDocument.ActiveView.getPoint(pos) + datum = FreeCAD.ActiveDocument.addObject("Part::Datum", "Datum") + datum.Placement.Base = point + datum.ViewObject.ShapeColor = (0.0, 1.0, 0.0) # Set the color of the datum to green + FreeCAD.ActiveDocument.recompute() + +class DatumCommand: + """ + A command for activating and deactivating the datum tool + """ + def __init__(self): + self.tool = DatumTool() + + def Activated(self): + self.tool.activate() + FreeCADGui.ActiveDocument.ActiveView.addEventCallback("SoMouseButtonEvent", self.tool.mousePressEvent) + + def Deactivated(self): + self.tool.deactivate() + FreeCADGui.ActiveDocument.ActiveView.removeEventCallback("SoMouseButtonEvent", self.tool.mousePressEvent) + + def GetResources(self): + return {'Pixmap': 'path/to/icon.png', 'MenuText': 'Datum Tool', 'ToolTip': 'Creates datum elements in existing models'} + +# Add the command to the Draft Workbench +FreeCADGui.addCommand('DatumCommand', DatumCommand()) \ No newline at end of file diff --git a/cg/freecad/Frames/Frames.py b/cg/freecad/Frames/Frames.py index ea46662..1bc5544 100644 --- a/cg/freecad/Frames/Frames.py +++ b/cg/freecad/Frames/Frames.py @@ -11,9 +11,11 @@ # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . +from BoMList import run_BoM_list import FreeCAD import Tools -from scenarios.robossembler_freecad_export_scenario import RobossemblerFreeCadExportScenario +from usecases.asm4parser_usecase import Asm4StructureParseUseCase + if FreeCAD.GuiUp: import FreeCADGui @@ -297,6 +299,13 @@ def makeAllPartFrames(): def spawnFeatureFrameCreator(): ffpanel = FeatureFramePanel() FreeCADGui.Control.showDialog(ffpanel) + +def BoMGeneration(part): + + + obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython", + "FeatureFrame") + print(obj) ################################################################### @@ -306,22 +315,26 @@ uidir = os.path.join(FreeCAD.getUserAppDataDir(), "Mod", __workbenchname__, "UI") icondir = os.path.join(uidir, "icons") -Tools.spawnClassCommand("FrameCommand", - makeFrame, - {"Pixmap": str(os.path.join(icondir, "frame.svg")), - "MenuText": "Make a free frame", - "ToolTip": "Make a freestanding reference frame."}) - -Tools.spawnClassCommand("ASM4StructureParsing", - RobossemblerFreeCadExportScenario().call, - {"Pixmap": str(os.path.join(icondir, "assembly4.svg")), - "MenuText": "Make a ASM4 parsing", - "ToolTip": "Make a ASM4 1"}) -Tools.spawnClassCommand("SelectedPartFrameCommand", - makeSelectedPartFrames, - {"Pixmap": str(os.path.join(icondir, "partframe.svg")), - "MenuText": "selected parts frames", - "ToolTip": "Make selected parts frames."}) +# Tools.spawnClassCommand("FrameCommand", +# makeFrame, +# {"Pixmap": str(os.path.join(icondir, "frame.svg")), +# "MenuText": "Make a free frame", +# "ToolTip": "Make a freestanding reference frame."}) +Tools.spawnClassCommand("BoMGeneration", + run_BoM_list, + {"Pixmap": str(os.path.join(icondir, "BoMList.svg")), + "MenuText": "Generate Bill of Materials", + "ToolTip": "Press the button to create big BoM"}) +# Tools.spawnClassCommand("ASM4StructureParsing", +# Asm4StructureParseUseCase().initParse, +# {"Pixmap": str(os.path.join(icondir, "assembly4.svg")), +# "MenuText": "Make a ASM4 parsing", +# "ToolTip": "Make a ASM4 1"}) +# Tools.spawnClassCommand("SelectedPartFrameCommand", +# makeSelectedPartFrames, +# {"Pixmap": str(os.path.join(icondir, "partframe.svg")), +# "MenuText": "selected parts frames", +# "ToolTip": "Make selected parts frames."}) Tools.spawnClassCommand("AllPartFramesCommand", makeAllPartFrames, diff --git a/cg/freecad/Frames/InitGui.py b/cg/freecad/Frames/InitGui.py index 536ec0a..4ed400b 100644 --- a/cg/freecad/Frames/InitGui.py +++ b/cg/freecad/Frames/InitGui.py @@ -36,10 +36,13 @@ class Frames(Workbench): """This function is executed when FreeCAD starts""" import Frames self.framecommands = [ + "BoMGeneration", "FrameCommand", + "SelectedPartFrameCommand", "AllPartFramesCommand", - "FeatureFrameCommand" + "FeatureFrameCommand", + ] self.toolcommands = [ "ExportPlacementAndPropertiesCommand", diff --git a/cg/freecad/Frames/Sheet_addition_test.py b/cg/freecad/Frames/Sheet_addition_test.py new file mode 100644 index 0000000..9b645b0 --- /dev/null +++ b/cg/freecad/Frames/Sheet_addition_test.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Sheet_addition_test.py +# +# Copyright 2015 Ulrich Brammer +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# + +theDoc = App.newDocument("SheetTest") +App.setActiveDocument("SheetTest") +#App.activeDocument("SheetTest") + + +p=App.ParamGet("User parameter:BaseApp/Preferences/General") +thePath = p.GetString('FileOpenSavePath') + + +mySheet = theDoc.addObject('Spreadsheet::Sheet','Spreadsheet') + +mySheet.set('A1', '1') +mySheet.set('A2', '2') +theDoc.recompute() +mySheet.set('A3', '=A1+A2') +mySheet.setPosition('A4') +#theDoc.saveAs("/home/ulrich/FreeCAD/Spreadsheet/Sheet_4.fcstd") +theDoc.saveAs(thePath + '/Sheet_5.fcstd') +mySheet.set('A4', '=A3') +theDoc.recompute() + +if mySheet.State == ['Invalid']: + print "Invalid Spreadsheet" +else: + print "No error found" + + + + +def main(): + + return 0 + +if __name__ == '__main__': + main() + diff --git a/cg/freecad/Frames/UI/icons/BoMList.svg b/cg/freecad/Frames/UI/icons/BoMList.svg new file mode 100644 index 0000000..caf5d4f --- /dev/null +++ b/cg/freecad/Frames/UI/icons/BoMList.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + ... + + + + + + Parts + + + + List + + + \ No newline at end of file diff --git a/cg/freecad/Frames/UI/icons/auxDatum.svg b/cg/freecad/Frames/UI/icons/auxDatum.svg new file mode 100644 index 0000000..c1ca8d8 --- /dev/null +++ b/cg/freecad/Frames/UI/icons/auxDatum.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [wmayer] + + + Sketcher_Sketch + 2011-10-10 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_Sketch.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cg/freecad/Frames/box.py b/cg/freecad/Frames/box.py new file mode 100644 index 0000000..e69de29 diff --git a/cg/freecad/Frames/newLabel.py b/cg/freecad/Frames/newLabel.py new file mode 100644 index 0000000..761ed81 --- /dev/null +++ b/cg/freecad/Frames/newLabel.py @@ -0,0 +1,17 @@ +import FreeCAD as App + + +def is_object_solid(obj): + """If obj is solid return True""" + if not isinstance(obj, FreeCAD.DocumentObject): + return False + + if not hasattr(obj, 'Shape'): + return False + + return obj.Shape.isClosed() + +def addProperty(): + for obj in App.ActiveDocument().Objects: + if is_object_solid(obj): + \ No newline at end of file diff --git a/cg/freecad/Frames/testSpread2.py b/cg/freecad/Frames/testSpread2.py new file mode 100644 index 0000000..a2953f0 --- /dev/null +++ b/cg/freecad/Frames/testSpread2.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# faculSpread.py +# +# Copyright 2015 ulrich1a +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# + + + +p=App.ParamGet("User parameter:BaseApp/Preferences/General") +thePath = p.GetString('FileOpenSavePath') + + +theDoc = App.newDocument("SheetTest2") +App.setActiveDocument("SheetTest2") + +mySheet = theDoc.addObject('Spreadsheet::Sheet','Spreadsheet') + + +col = 'A' +mySheet.setColumnWidth(col, 125) +theDoc.recompute() + +startRow = 3 + +for i in range(20): + print "i: ", i + if i == 0: + print "setting start" + mySheet.set(col+str(startRow+i), '1') + #App.activeDocument().recompute() + else: + mySheet.set(col + str(startRow+i), '='+col+str(startRow+i-1)+'*'+str(i)) + #App.activeDocument().recompute() + +#mySheet.show() +#App.activeDocument().recompute() + +mySheet.set('A1', 'This is the very long Titel, which needs more space!') +mySheet.set('A2', '=A1') + +# mySheet.setDisplayUnit('A10:A11', 'mm') + +theDoc.recompute() +mySheet.setAlias('A1', 'Title') +mySheet.set('D1', '=Title') + +theDoc.recompute() + +theDoc.saveAs(thePath + '/Sheet_6.fcstd') +mySheet.set('B4','=A4') +mySheet.set('E1', '=D1') +theDoc.recompute() +mySheet.setAlias('A2', 'huhu') +theDoc.recompute() + +if mySheet.State == ['Invalid']: + print "Invalid Spreadsheet" +else: + print "No error found" diff --git a/cg/freecad/Frames/usecases/asm4parser_usecase.py b/cg/freecad/Frames/usecases/asm4parser_usecase.py new file mode 100644 index 0000000..f732d1b --- /dev/null +++ b/cg/freecad/Frames/usecases/asm4parser_usecase.py @@ -0,0 +1,53 @@ +import FreeCAD as App + +class Asm4StructureParseUseCase: + _parts = [] + _label = [] + + def getSubPartsLabel(self, group): + groupLabel = [] + for el in group: + if str(el) == '': + groupLabel.append(el.Label) + return groupLabel + + def parseLabel(self, nextGroup, label, level=2, nextGroupParse=0): + if nextGroup.__len__() == nextGroupParse: + return + else: + groupParts = [] + + for el in nextGroup: + if str(el) == '': + groupParts.append(el) + + for el in groupParts: + if str(el) == '': + label.append({ + "level": level, + "attachedTo": el.AttachedTo.split('#'), + "label": el.Label, + "axis": self.getSubPartsLabel(el.Group) + }) + + def initParse(self): + + model = App.ActiveDocument.RootObjects[1] + self._label.append({ + "level": 1, + "attachedTo": "Parent Assembly", + "label": model.Label, + "axis": self.getSubPartsLabel(model.Group) + }) + for parent in model.Group: + if str(parent) == '': + self._label.append({ + "level": 1, + "attachedTo": parent.AttachedTo.split('#'), + "label": parent.Label, + "axis": self.getSubPartsLabel(parent.Group) + }) + print(self._label) + + + \ No newline at end of file