diff --git a/src/Mod/Assembly/App/CMakeLists.txt b/src/Mod/Assembly/App/CMakeLists.txt index 6eaebbfdc..ca11c4ec1 100644 --- a/src/Mod/Assembly/App/CMakeLists.txt +++ b/src/Mod/Assembly/App/CMakeLists.txt @@ -103,7 +103,8 @@ target_link_libraries(Assembly ${Assembly_LIBS}) fc_target_copy_resource(Assembly ${CMAKE_SOURCE_DIR}/src/Mod/Assembly ${CMAKE_BINARY_DIR}/Mod/Assembly - Init.py) + Init.py + AssemblyLib.py) SET_BIN_DIR(Assembly Assembly /Mod/Assembly) SET_PYTHON_PREFIX_SUFFIX(Assembly) diff --git a/src/Mod/Assembly/AssemblyLib.py b/src/Mod/Assembly/AssemblyLib.py new file mode 100644 index 000000000..b08eeb257 --- /dev/null +++ b/src/Mod/Assembly/AssemblyLib.py @@ -0,0 +1,77 @@ +#! python +# -*- coding: utf-8 -*- +#*************************************************************************** +#* * +#* Copyright (c) 2012 * +#* Juergen Riegel * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This 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 Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + + + +__title__="FreeCAD Assembly Lib" +__author__ = "Juergen Riegel " +__url__ = "http://free-cad.sourceforge.net" + +''' +General description: + + This set of classes is aimed for general methods used in the FreeCAD Assembly module + +User manual: + + TODO + +How it works / how to extend: + TODO +''' + +# import FreeCAD modules +import FreeCAD, Part, Assembly +from FreeCAD import Vector + +if FreeCAD.GuiUp: + import FreeCADGui, AssemblyGui + gui = True +else: + gui = False + +#--------------------------------------------------------------------------- +# General functions +#--------------------------------------------------------------------------- + + + + +#--------------------------------------------------------------------------- +# Import methods +#--------------------------------------------------------------------------- + + +def importAssembly(FileName,DestItem): + for i in Part.read(FileName).Solids: + po = FreeCAD.activeDocument().addObject('Assembly::ItemPart','STP-Part_1') + DestItem.Items = DestItem.Items + [po] + bo = FreeCAD.activeDocument().addObject('PartDesign::Body','STP-Body_1') + po.Model = bo + so = FreeCAD.activeDocument().addObject('PartDesign::Solid','STP-Solid_1') + bo.Model = so + bo.Tip = so + so.Shape = i + diff --git a/src/Mod/Assembly/FCDocTool.py b/src/Mod/Assembly/FCDocTool.py index 92c10eed4..d1bc824f3 100644 --- a/src/Mod/Assembly/FCDocTool.py +++ b/src/Mod/Assembly/FCDocTool.py @@ -1,7 +1,44 @@ #! python # -*- coding: utf-8 -*- -# (c) 2007 Juergen Riegel LGPL +#*************************************************************************** +#* * +#* Copyright (c) 2012 * +#* Juergen Riegel * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This 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 Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** +__title__="FreeCAD document tool" +__author__ = "Juergen Riegel " +__url__ = "http://free-cad.sourceforge.net" + +''' +General description: + + Command line tool and lib for exploring FreeCAD documents + +User manual: + + TODO + +How it works / how to extend: + TODO +''' import zipfile from xml.dom.minidom import parse, parseString diff --git a/src/Mod/Assembly/Gui/Command.cpp b/src/Mod/Assembly/Gui/Command.cpp index bfb3d65db..4af10a38c 100644 --- a/src/Mod/Assembly/Gui/Command.cpp +++ b/src/Mod/Assembly/Gui/Command.cpp @@ -192,26 +192,12 @@ void CmdAssemblyAddExistingComponent::activated(int iMsg) addModule(Doc,"Part"); addModule(Doc,"PartDesign"); addModule(Gui,"PartDesignGui"); + addModule(Gui,"AssemblyGui"); + addModule(Gui,"AssemblyLib"); std::string fName( (const char*)fn.toUtf8()); - doCommand(Gui, - -"father = AssemblyGui.getActiveAssembly()\n" -"\n" -"for i in Part.read('%s').Solids:\n" -" po = App.activeDocument().addObject('Assembly::ItemPart','STP-Part_1')\n" -" father.Items = father.Items + [po]\n" -" bo = App.activeDocument().addObject('PartDesign::Body','STP-Body_1')\n" -" po.Model = bo\n" -" so = App.activeDocument().addObject('PartDesign::Solid','STP-Solid_1')\n" -" bo.Model = so\n" -" bo.Tip = so\n" -" so.Shape = i\n" -"\n" -"del so,bo,father,po\n" - - ,fName.c_str()); + doCommand(Gui,"AssemblyLib.importAssembly('%s',AssemblyGui.getActiveAssembly())",fName.c_str()); this->updateActive(); }