Start AssemblyLib.py
This commit is contained in:
parent
b81bc0c27f
commit
638cfcc2cf
|
@ -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)
|
||||
|
|
77
src/Mod/Assembly/AssemblyLib.py
Normal file
77
src/Mod/Assembly/AssemblyLib.py
Normal file
|
@ -0,0 +1,77 @@
|
|||
#! python
|
||||
# -*- coding: utf-8 -*-
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2012 *
|
||||
#* Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
#* *
|
||||
#* 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 <FreeCAD@juergen-riegel.net>"
|
||||
__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
|
||||
|
|
@ -1,7 +1,44 @@
|
|||
#! python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2007 Juergen Riegel LGPL
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2012 *
|
||||
#* Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
#* *
|
||||
#* 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 <FreeCAD@juergen-riegel.net>"
|
||||
__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
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user