461 lines
32 KiB
HTML
461 lines
32 KiB
HTML
<html><head><title>Extra python modules/sv</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Extra python modules/sv</h1></div>
|
|
|
|
<div id="mw-content-text" lang="sv" dir="ltr" class="mw-content-ltr"><hr/>
|
|
<div class="mw-parser-output"><p>This page lists several additional python modules or other pieces of software that can be downloaded freely from the internet, and add functionality to your FreeCAD installation.
|
|
</p>
|
|
<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1 tocsection-1"><a href="#PySide_.28previously_PyQt4.29"><span class="tocnumber">1</span> <span class="toctext">PySide (previously PyQt4)</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-2"><a href="#Installation"><span class="tocnumber">1.1</span> <span class="toctext">Installation</span></a>
|
|
<ul>
|
|
<li class="toclevel-3 tocsection-3"><a href="#Linux"><span class="tocnumber">1.1.1</span> <span class="toctext">Linux</span></a></li>
|
|
<li class="toclevel-3 tocsection-4"><a href="#Windows"><span class="tocnumber">1.1.2</span> <span class="toctext">Windows</span></a></li>
|
|
<li class="toclevel-3 tocsection-5"><a href="#MacOSX"><span class="tocnumber">1.1.3</span> <span class="toctext">MacOSX</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-2 tocsection-6"><a href="#Usage"><span class="tocnumber">1.2</span> <span class="toctext">Usage</span></a></li>
|
|
<li class="toclevel-2 tocsection-7"><a href="#Example_of_transition_from_PyQt4_and_PySide"><span class="tocnumber">1.3</span> <span class="toctext">Example of transition from PyQt4 and PySide</span></a></li>
|
|
<li class="toclevel-2 tocsection-8"><a href="#Additional_documentation"><span class="tocnumber">1.4</span> <span class="toctext">Additional documentation</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-9"><a href="#Pivy"><span class="tocnumber">2</span> <span class="toctext">Pivy</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-10"><a href="#Installation_2"><span class="tocnumber">2.1</span> <span class="toctext">Installation</span></a>
|
|
<ul>
|
|
<li class="toclevel-3 tocsection-11"><a href="#Prerequisites"><span class="tocnumber">2.1.1</span> <span class="toctext">Prerequisites</span></a></li>
|
|
<li class="toclevel-3 tocsection-12"><a href="#Debian_.26_Ubuntu"><span class="tocnumber">2.1.2</span> <span class="toctext">Debian & Ubuntu</span></a></li>
|
|
<li class="toclevel-3 tocsection-13"><a href="#Other_linux_distributions"><span class="tocnumber">2.1.3</span> <span class="toctext">Other linux distributions</span></a></li>
|
|
<li class="toclevel-3 tocsection-14"><a href="#Mac_OS"><span class="tocnumber">2.1.4</span> <span class="toctext">Mac OS</span></a></li>
|
|
<li class="toclevel-3 tocsection-15"><a href="#Windows_2"><span class="tocnumber">2.1.5</span> <span class="toctext">Windows</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-2 tocsection-16"><a href="#Usage_2"><span class="tocnumber">2.2</span> <span class="toctext">Usage</span></a></li>
|
|
<li class="toclevel-2 tocsection-17"><a href="#Dokumentation"><span class="tocnumber">2.3</span> <span class="toctext">Dokumentation</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-18"><a href="#pyCollada"><span class="tocnumber">3</span> <span class="toctext">pyCollada</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-19"><a href="#Installation_3"><span class="tocnumber">3.1</span> <span class="toctext">Installation</span></a>
|
|
<ul>
|
|
<li class="toclevel-3 tocsection-20"><a href="#Linux_2"><span class="tocnumber">3.1.1</span> <span class="toctext">Linux</span></a>
|
|
<ul>
|
|
<li class="toclevel-4 tocsection-21"><a href="#From_the_git_repository"><span class="tocnumber">3.1.1.1</span> <span class="toctext">From the git repository</span></a></li>
|
|
<li class="toclevel-4 tocsection-22"><a href="#With_easy_install"><span class="tocnumber">3.1.1.2</span> <span class="toctext">With easy_install</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-3 tocsection-23"><a href="#Windows_3"><span class="tocnumber">3.1.2</span> <span class="toctext">Windows</span></a></li>
|
|
<li class="toclevel-3 tocsection-24"><a href="#Mac_OS_2"><span class="tocnumber">3.1.3</span> <span class="toctext">Mac OS</span></a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-25"><a href="#IfcOpenShell"><span class="tocnumber">4</span> <span class="toctext">IfcOpenShell</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-26"><a href="#Installation_4"><span class="tocnumber">4.1</span> <span class="toctext">Installation</span></a>
|
|
<ul>
|
|
<li class="toclevel-3 tocsection-27"><a href="#Linux_3"><span class="tocnumber">4.1.1</span> <span class="toctext">Linux</span></a></li>
|
|
<li class="toclevel-3 tocsection-28"><a href="#Windows_4"><span class="tocnumber">4.1.2</span> <span class="toctext">Windows</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-2 tocsection-29"><a href="#Links"><span class="tocnumber">4.2</span> <span class="toctext">Links</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-30"><a href="#Teigha_Converter"><span class="tocnumber">5</span> <span class="toctext">Teigha Converter</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-31"><a href="#Installation_5"><span class="tocnumber">5.1</span> <span class="toctext">Installation</span></a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<h2><span class="mw-headline" id="PySide_.28previously_PyQt4.29">PySide (previously PyQt4)</span></h2>
|
|
<ul><li> homepage (PySide): <a rel="nofollow" class="external free" href="http://qt-project.org/wiki/PySide">http://qt-project.org/wiki/PySide</a></li>
|
|
<li> license: LGPL </li>
|
|
<li> optional, but needed by several modules: Draft, Arch, Ship, Plot, OpenSCAD, Spreadsheet</li></ul>
|
|
<p>PySide (previously PyQt) is required by several modules of FreeCAD to access FreeCAD's Qt interface. It is already bundled in the windows verison of FreeCAD, and is usually installed automatically by FreeCAD on Linux, when installing from official repositories. If those modules (Draft, Arch, etc) are enabled after FreeCAD is installed, it means PySide (previously PyQt) is already there, and you don't need to do anything more.
|
|
</p><p><b>Notera</b>: av följande moduler, så är Pivy nu helt integrerad i alla FreeCAD installationspaket, och PyQt4 är också integrerat i Windows installationspaket.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Installation">Installation</span></h3>
|
|
<h4><span class="mw-headline" id="Linux">Linux</span></h4>
|
|
<p>The simplest way to install PySide is through your distribution's package manager. On Debian/Ubuntu systems, the package name is generally <i>python-PySide</i>, while on RPM-based systems it is named <i>pyside</i>. The necessary dependencies (Qt and SIP) will be taken care of automatically.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Windows">Windows</span></h4>
|
|
<p>The program can be downloaded from <a rel="nofollow" class="external free" href="http://qt-project.org/wiki/Category:LanguageBindings::PySide::Downloads">http://qt-project.org/wiki/Category:LanguageBindings::PySide::Downloads</a> . You'll need to install the Qt and SIP libraries before installing PySide (to be documented).
|
|
</p>
|
|
<h4><span class="mw-headline" id="MacOSX">MacOSX</span></h4>
|
|
<p>PyQt on Mac can be installed via homebrew or port. See <a href="/wiki/CompileOnMac#Install_Dependencies" title="CompileOnMac">CompileOnMac#Install_Dependencies</a> for more information.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Usage">Usage</span></h3>
|
|
<p>Once it is installed, you can check that everything is working by typing in FreeCAD python console:
|
|
</p>
|
|
<pre>import PySide </pre>
|
|
<p>To access the FreeCAD interface, type :
|
|
</p>
|
|
<pre>from PySide import QtCore,QtGui
|
|
FreeCADWindow = FreeCADGui.getMainWindow() </pre>
|
|
<p>Now you can start to explore the interface with the dir() command. You can add new elements, like a custom widget, with commands like :
|
|
</p>
|
|
<pre>FreeCADWindow.addDockWidget(QtCore.Qt.RghtDockWidgetArea,my_custom_widget) </pre>
|
|
<p>Working with Unicode :
|
|
</p>
|
|
<pre>text = text.encode('utf-8') </pre>
|
|
<p>Working with QFileDialog and OpenFileName :
|
|
</p>
|
|
<pre>path = FreeCAD.ConfigGet("AppHomePath")
|
|
#path = FreeCAD.ConfigGet("UserAppData")
|
|
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Read a txt file", path, "*.txt") </pre>
|
|
<p>Working with QFileDialog and SaveFileName :
|
|
</p>
|
|
<pre>path = FreeCAD.ConfigGet("AppHomePath")
|
|
#path = FreeCAD.ConfigGet("UserAppData")
|
|
SaveName, Filter = PySide.QtGui.QFileDialog.getSaveFileName(None, "Save a file txt", path, "*.txt") </pre>
|
|
<h3><span class="mw-headline" id="Example_of_transition_from_PyQt4_and_PySide">Example of transition from PyQt4 and PySide</span></h3>
|
|
<p>PS: these examples of errors were found in the transition PyQt4 to PySide and these corrections were made, other solutions are certainly available with the examples above
|
|
</p>
|
|
<pre>try:
|
|
import PyQt4 # PyQt4
|
|
from PyQt4 import QtGui ,QtCore # PyQt4
|
|
from PyQt4.QtGui import QComboBox # PyQt4
|
|
from PyQt4.QtGui import QMessageBox # PyQt4
|
|
from PyQt4.QtGui import QTableWidget, QApplication # PyQt4
|
|
from PyQt4.QtGui import * # PyQt4
|
|
from PyQt4.QtCore import * # PyQt4
|
|
except Exception:
|
|
import PySide # PySide
|
|
from PySide import QtGui ,QtCore # PySide
|
|
from PySide.QtGui import QComboBox # PySide
|
|
from PySide.QtGui import QMessageBox # PySide
|
|
from PySide.QtGui import QTableWidget, QApplication # PySide
|
|
from PySide.QtGui import * # PySide
|
|
from PySide.QtCore import * # PySide </pre>
|
|
<p>To access the FreeCAD interface, type :
|
|
You can add new elements, like a custom widget, with commands like :
|
|
</p>
|
|
<pre>myNewFreeCADWidget = QtGui.QDockWidget() # create a new dockwidget
|
|
myNewFreeCADWidget.ui = Ui_MainWindow() # myWidget_Ui() # load the Ui script
|
|
myNewFreeCADWidget.ui.setupUi(myNewFreeCADWidget) # setup the ui
|
|
try:
|
|
app = QtGui.qApp # PyQt4 # the active qt window, = the freecad window since we are inside it
|
|
FCmw = app.activeWindow() # PyQt4 # the active qt window, = the freecad window since we are inside it
|
|
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window
|
|
except Exception:
|
|
FCmw = FreeCADGui.getMainWindow() # PySide # the active qt window, = the freecad window since we are inside it
|
|
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window </pre>
|
|
<p>Working with Unicode :
|
|
</p>
|
|
<pre>try:
|
|
text = unicode(text, 'ISO-8859-1').encode('UTF-8') # PyQt4
|
|
except Exception:
|
|
text = text.encode('utf-8') # PySide </pre>
|
|
<p>Working with QFileDialog and OpenFileName :
|
|
</p>
|
|
<pre>OpenName = ""
|
|
try:
|
|
OpenName = QFileDialog.getOpenFileName(None,QString.fromLocal8Bit("Lire un fichier FCInfo ou txt"),path,"*.FCInfo *.txt") # PyQt4
|
|
except Exception:
|
|
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Lire un fichier FCInfo ou txt", path, "*.FCInfo *.txt")#PySide </pre>
|
|
<p>Working with QFileDialog and SaveFileName :
|
|
</p>
|
|
<pre>SaveName = ""
|
|
try:
|
|
SaveName = QFileDialog.getSaveFileName(None,QString.fromLocal8Bit("Sauver un fichier FCInfo"),path,"*.FCInfo") # PyQt4
|
|
except Exception:
|
|
SaveName, Filter = PySide.QtGui.QFileDialog.getSaveFileName(None, "Sauver un fichier FCInfo", path, "*.FCInfo")# PySide </pre>
|
|
<p>The MessageBox:
|
|
</p>
|
|
<pre>def errorDialog(msg):
|
|
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg )
|
|
try:
|
|
diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 # this function sets the window before
|
|
except Exception:
|
|
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)# PySide # this function sets the window before
|
|
# diag.setWindowModality(QtCore.Qt.ApplicationModal) # function has been disabled to promote "WindowStaysOnTopHint"
|
|
diag.exec_() </pre>
|
|
<p>Working with setProperty (PyQt4) and setValue (PySide)
|
|
</p>
|
|
<pre>self.doubleSpinBox.setProperty("value", 10.0) # PyQt4 </pre>
|
|
<p>replace to :
|
|
</p>
|
|
<pre>self.doubleSpinBox.setValue(10.0) # PySide </pre>
|
|
<p>Working with setToolTip
|
|
</p>
|
|
<pre>self.doubleSpinBox.setToolTip(_translate("MainWindow", "Coordinate placement Axis Y", None)) # PyQt4 </pre>
|
|
<p>replace to :
|
|
</p>
|
|
<pre>self.doubleSpinBox.setToolTip(_fromUtf8("Coordinate placement Axis Y")) # PySide </pre>
|
|
<p>or :
|
|
</p>
|
|
<pre>self.doubleSpinBox.setToolTip(u"Coordinate placement Axis Y.")# PySide </pre>
|
|
<h3><span class="mw-headline" id="Additional_documentation">Additional documentation</span></h3>
|
|
<p>Some pyQt4 tutorials (including how to build interfaces with Qt Designer to use with python):
|
|
</p>
|
|
<ul><li> <a rel="nofollow" class="external free" href="http://pyqt.sourceforge.net/Docs/PyQt4/classes.html">http://pyqt.sourceforge.net/Docs/PyQt4/classes.html</a> - the PyQt4 API Reference on sourceforge</li>
|
|
<li> <a rel="nofollow" class="external free" href="http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/">http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/</a> - a simple introduction</li>
|
|
<li> <a rel="nofollow" class="external free" href="http://www.zetcode.com/tutorials/pyqt4/">http://www.zetcode.com/tutorials/pyqt4/</a> - very complete in-depth tutorial</li></ul>
|
|
<h2><span class="mw-headline" id="Pivy">Pivy</span></h2>
|
|
<ul><li> homepage: <a rel="nofollow" class="external free" href="https://bitbucket.org/Coin3D/coin/wiki/Home">https://bitbucket.org/Coin3D/coin/wiki/Home</a></li>
|
|
<li> license: BSD</li>
|
|
<li> optional, but needed by several modules of FreeCAD: Draft, Arch</li></ul>
|
|
<p>Pivy is a needed by several modules to access the 3D view of FreeCAD. On windows, Pivy is already bundled inside the FreeCAD installer, and on Linux it is usually automatically installed when you install FreeCAD from an official repository. On MacOSX, unfortunately, you will need to compile pivy yourself.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Installation_2">Installation</span></h3>
|
|
<h4><span class="mw-headline" id="Prerequisites">Prerequisites</span></h4>
|
|
<p>I believe before compiling Pivy you will want to have Coin and SoQt installed.
|
|
</p><p>I found for building on Mac it was sufficient to install the <a rel="nofollow" class="external text" href="http://www.coin3d.org/lib/plonesoftwarecenter_view">Coin3 binary package</a>. Attempting to install coin from MacPorts was problematic: tried to add a lot of X Windows packages and ultimately crashed with a script error.
|
|
</p><p>For Fedora I found an RPM with Coin3.
|
|
</p><p>SoQt compiled from <a rel="nofollow" class="external text" href="http://www.coin3d.org/lib/soqt/releases/1.5.0">source</a> fine on Mac and Linux.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Debian_.26_Ubuntu">Debian & Ubuntu</span></h4>
|
|
<p>Med början i Debian Squeeze och Ubuntu Lucid, så kommer pivy att finnas tillgängligt direkt från de officiella förråden, vilket sparar mycket krångel. Innan dess, så kan du antingen ladda ned ett av de paket som vi har gjort (för debian och ubuntu karmic) tillgängliga på <a href="https://www.freecadweb.org/wiki/index.php?title=Download/sv" title="Download/sv">Nedladdningssidorna</a>, eller så kan du kompilera det själv.
|
|
</p>
|
|
<div class="mw-translate-fuzzy">
|
|
<p>Det bästa sättet att kompilera pivy smidigt är att hämta debians källkodspaket för pivy och göra ett paket med debuild. Det är samma källkod som på den officiella pivysajten, men debianfolket har gjort flera bugg-fixningstillägg. Det kompilerar också bra på ubuntu karmic: <a rel="nofollow" class="external free" href="http://packages.debian.org/squeeze/python-pivy">http://packages.debian.org/squeeze/python-pivy</a> (ladda ned .orig.gz och .diff.gz file, packa upp båda, tillämpa sedan .diff på källkoden: gå till den uppackade pivy källkodsmappen, och tillämpa .diff patchen:
|
|
</p>
|
|
</div>
|
|
<pre>patch -p1 < ../pivy_0.5.0~svn765-2.diff </pre>
|
|
<p>sedan
|
|
</p>
|
|
<pre>debuild </pre>
|
|
<p>för att få pivy korrekt byggt till ett officiellt installerbart paket. Sedan så är det bara att installera paketet med gdebi.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Other_linux_distributions">Other linux distributions</span></h4>
|
|
<p>First get the latest sources from the <a rel="nofollow" class="external text" href="http://pivy.coin3d.org/mercurial/">project's repository</a>:
|
|
</p>
|
|
<pre>hg clone http://hg.sim.no/Pivy/default Pivy </pre>
|
|
<p>As of March 2012, the latest version is Pivy-0.5.
|
|
</p><p>Sedan behöver du ett verktyg som kallas för SWIG för att generera C++ koden för Pythonbindningarna. Det rekommenderas att version 1.3.25 av SWIG används, inte den senaste versionen, därför att pivy för tillfället endast fungerar korrekt med 1.3.25. Ladda ned 1.3.25 source tarball från <a rel="nofollow" class="external free" href="http://www.swig.org">http://www.swig.org</a>. Packa sedan upp den, och gör som root följande i en konsol:
|
|
</p>
|
|
<pre>./configure
|
|
make
|
|
make install (or checkinstall if you use it) </pre>
|
|
<p>Det tar bara några sekunder att bygga.
|
|
</p><p>Alternatively, you can try building with a more recent SWIG. As of March 2012, a typical repository version is 2.0.4. Pivy has a minor compile problem with SWIG 2.0.4 on Mac OS (see below) but seems to build fine on Fedora Core 15.
|
|
</p><p>Efter det, gå till pivy källkoden och anropa
|
|
</p>
|
|
<pre>python setup.py build </pre>
|
|
<p>which creates the source files. Note that build can produce thousands of warnings, but hopefully there will be no errors.
|
|
</p><p>viltet skapar källkodsfilerna. Du kan få kompileringsfel där en 'const char*' inte kan konverteras till en 'char*'. För att fixa det så behöver du bara skriva en 'const' innan raderna som orsakade felet.
|
|
</p><p>Det finns sex rader att fixa. Efter det, installera genom att skriva (som root):
|
|
</p>
|
|
<pre>python setup.py install (or checkinstall python setup.py install) </pre>
|
|
<p>Klart! Pivy är installerat.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Mac_OS">Mac OS</span></h4>
|
|
<p>These instructions may not be complete. Something close to this worked for OS 10.7 as of March 2012. I use MacPorts for repositories, but other options should also work.
|
|
</p><p>As for linux, get the latest source:
|
|
</p>
|
|
<pre>hg clone http://hg.sim.no/Pivy/default Pivy </pre>
|
|
<p>If you don't have hg, you can get it from MacPorts:
|
|
</p>
|
|
<pre>port install mercurial </pre>
|
|
<p>Then, as above you need SWIG. It should be a matter of:
|
|
</p>
|
|
<pre>port install swig </pre>
|
|
<p>I found I needed also:
|
|
</p>
|
|
<pre>port install swig-python </pre>
|
|
<p>As of March 2012, MacPorts SWIG is version 2.0.4. As noted above for linux, you might be better off downloading an older version. SWIG 2.0.4 seems to have a bug that stops Pivy building. See first message in this digest: <a rel="nofollow" class="external free" href="https://sourceforge.net/mailarchive/message.php?msg_id=28114815">https://sourceforge.net/mailarchive/message.php?msg_id=28114815</a>
|
|
</p><p>This can be corrected by editing the 2 source locations to add dereferences: *arg4, *arg5 in place of arg4, arg5. Now Pivy should build:
|
|
</p>
|
|
<pre>python setup.py build
|
|
sudo python setup.py install </pre>
|
|
<h4><span class="mw-headline" id="Windows_2">Windows</span></h4>
|
|
<p>När du använder Visual Studio 2005 eller senare så ska du öppna en kommandoprompt med 'Visual Studio 2005 Command prompt' från Tools menyn.
|
|
Om du ännu inte har Pythontolken i systemsökvägen, gör
|
|
</p>
|
|
<pre>set PATH=path_to_python_2.5;%PATH% </pre>
|
|
<p>För att få pivy att fungera så ska du hämta den senaste källkoden från projektets förråd:
|
|
</p>
|
|
<pre>svn co https://svn.coin3d.org/repos/Pivy/trunk Pivy </pre>
|
|
<p>Sedan behöver du ett verktyg som kallas för SWIG för att generera C++ koden för Python bindningarna. Det rekommenderas att version 1.3.25 av SWIG används, inte den senaste versionen, därför att pivy för tillfället endast fungerar korrekt med 1.3.25. Ladda ned binärkoden för 1.3.25 från <a rel="nofollow" class="external free" href="http://www.swig.org">http://www.swig.org</a>. Packa sedan upp den och lägg till den i systemsökvägen från kommandoraden
|
|
</p>
|
|
<pre>set PATH=path_to_swig_1.3.25;%PATH% </pre>
|
|
<p>och ställ in COINDIR till den riktiga sökvägen
|
|
</p>
|
|
<pre>set COINDIR=path_to_coin </pre>
|
|
<p>På Windows så förväntar sig pivys konfigurationsfil SoWin istället för SoQt som standard. Jag har inte hittat en självklart sätt att bygga med SoQt, så Jag modifierade filen setup.py direkt.
|
|
</p><p>Ta på rad 200 bort delen 'sowin' : ('gui._sowin', 'sowin-config', 'pivy.gui.') (ta inte bort den stängande parentesen).
|
|
</p><p>Efter det, gå till pivy källkoden och anropa
|
|
</p>
|
|
<pre>python setup.py build </pre>
|
|
<p>vilket skapar källkodsfilerna. Du kan få kompileringsfel för att flera headerfiler inte kunde hittas. I detta fall så får du justera INCLUDE variabeln
|
|
</p>
|
|
<pre>set INCLUDE=%INCLUDE%;path_to_coin_include_dir </pre>
|
|
<p>och om SoQt headers int är på samma plats som Coin headers så får du också justera
|
|
</p>
|
|
<pre>set INCLUDE=%INCLUDE%;path_to_soqt_include_dir </pre>
|
|
<p>och slutligen Qt headers
|
|
</p>
|
|
<pre>set INCLUDE=%INCLUDE%;path_to_qt4\include\Qt </pre>
|
|
<p>Om du använder Expressutgåvan av Visual Studio så kan du få ett python keyerror undantag.
|
|
</p><p>I detta fall så måste du ändra en del saker i msvccompiler.py som finns i din python installation.
|
|
</p><p>Gå till rad 122 och byt ut raden
|
|
</p>
|
|
<pre>vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version </pre>
|
|
<p>mot
|
|
</p>
|
|
<pre>vsbase = r"Software\Microsoft\VCExpress\%0.1f" % version </pre>
|
|
<p>Försök sedan igen.
|
|
</p><p>Om du får ett andra fel som
|
|
</p>
|
|
<pre>error: Python was built with Visual Studio 2003;... </pre>
|
|
<p>Så måste du även byta ut rad 128
|
|
</p>
|
|
<pre>self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") </pre>
|
|
<p>mot
|
|
</p>
|
|
<pre>self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0") </pre>
|
|
<p>Försök igen. Om du åter får ett fel som
|
|
</p>
|
|
<pre>error: Python was built with Visual Studio version 8.0, and extensions need to be built with the same version of the compiler, but it isn't installed. </pre>
|
|
<p>så ska du kontrollera miljövariablerna DISTUTILS_USE_SDK och MSSDK med
|
|
</p>
|
|
<pre>echo %DISTUTILS_USE_SDK%
|
|
echo %MSSDK% </pre>
|
|
<p>Om de inte är inställda än, ställ in dem till 1
|
|
</p>
|
|
<pre>set DISTUTILS_USE_SDK=1
|
|
set MSSDK=1 </pre>
|
|
<p>Nu kan du få kompileringsfel där en 'const char*' inte kan konverteras till en 'char*'. För att fixa det så behöver du bara skriva en 'const' innan raderna som orsakade felet. Det finns sex rader att fixa.
|
|
</p><p>Kopiera sedan den genererade pivykatalogen till en plats där pythontolken i FreeCAD kan hitta den.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Usage_2">Usage</span></h3>
|
|
<p>To check if Pivy is correctly installed:
|
|
</p>
|
|
<pre>import pivy </pre>
|
|
<p>För att Pivy ska komma åt FreeCAD scengrafen, gör följande:
|
|
</p>
|
|
<pre>from pivy import coin
|
|
App.newDocument() # Open a document and a view
|
|
view = Gui.ActiveDocument.ActiveView
|
|
FCSceneGraph = view.getSceneGraph() # returns a pivy Python object that holds a SoSeparator, the main "container" of the Coin scenegraph
|
|
FCSceneGraph.addChild(coin.SoCube()) # add a box to scene </pre>
|
|
<p>Nu kan du utforska FCSceneGraph med dir() kommandot.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Dokumentation">Dokumentation</span></h3>
|
|
<p>Olyckligtvis så existerar det knappast ännu någon dokumentation om pivy på nätet. Men Coin dokumentationen kan vara användbar, eftersom pivy helt enkelt översätter Coin funktioner, noder och metoder i python, allt behåller samma namn och egenskaper, bara man tänker på syntaxskillnaden mellan C och python:
|
|
</p>
|
|
<ul><li> <a rel="nofollow" class="external free" href="https://bitbucket.org/Coin3D/coin/wiki/Documentation">https://bitbucket.org/Coin3D/coin/wiki/Documentation</a> - Coin3D API Reference</li>
|
|
<li> <a rel="nofollow" class="external free" href="http://www-evasion.imag.fr/~Francois.Faure/doc/inventorMentor/sgi_html/index.html">http://www-evasion.imag.fr/~Francois.Faure/doc/inventorMentor/sgi_html/index.html</a> - The Inventor Mentor - The "bible" of Inventor scene description language.</li></ul>
|
|
<p>Du kan också titta på Draft.py filen i FreeCAD Mod/Draft mappen, eftersom den använder pivy mycket.
|
|
</p>
|
|
<h2><span class="mw-headline" id="pyCollada">pyCollada</span></h2>
|
|
<ul><li> homepage: <a rel="nofollow" class="external free" href="http://pycollada.github.com">http://pycollada.github.com</a></li>
|
|
<li> license: BSD</li>
|
|
<li> optional, needed to enable import and export of Collada (.DAE) files</li></ul>
|
|
<p>pyCollada is a python library that allow programs to read and write <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/COLLADA">Collada (*.DAE)</a> files. When pyCollada is installed on your system, FreeCAD will be able to handle importing and exporting in the Collada file format.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Installation_3">Installation</span></h3>
|
|
<p>Pycollada is usually not yet available in linux distributions repositories, but since it is made only of python files, it doesn't require compilation, and is easy to install. You have 2 ways, or directly from the official pycollada git repository, or with the easy_install tool.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Linux_2">Linux</span></h4>
|
|
<p>In either case, you'll need the following packages already installed on your system:
|
|
</p>
|
|
<pre>python-lxml
|
|
python-numpy
|
|
python-dateutil </pre>
|
|
<h5><span class="mw-headline" id="From_the_git_repository">From the git repository</span></h5>
|
|
<pre>git clone git://github.com/pycollada/pycollada.git pycollada
|
|
cd pycollada
|
|
sudo python setup.py install </pre>
|
|
<h5><span class="mw-headline" id="With_easy_install">With easy_install</span></h5>
|
|
<p>Assuming you have a complete python installation already, the easy_install utility should be present already:
|
|
</p>
|
|
<pre>easy_install pycollada </pre>
|
|
<p>You can check if pycollada was correctly installed by issuing in a python console:
|
|
</p>
|
|
<pre>import collada </pre>
|
|
<p>If it returns nothing (no error message), then all is OK
|
|
</p>
|
|
<h4><span class="mw-headline" id="Windows_3">Windows</span></h4>
|
|
<p>On Windows since 0.15 pycollada is included in both the FreeCAD release and developer builds so no additional steps are necessary.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Mac_OS_2">Mac OS</span></h4>
|
|
<p>If you are using the Homebrew build of FreeCAD you can install pycollada into your system Python using pip.
|
|
</p><p>If you need to install pip:
|
|
</p>
|
|
<pre>$ sudo easy_install pip </pre>
|
|
<p>Install pycollada:
|
|
</p>
|
|
<pre>$ sudo pip install pycollada </pre>
|
|
<p>If you are using a binary version of FreeCAD, you can tell pip to install pycollada into the site-packages inside FreeCAD.app:
|
|
</p>
|
|
<pre>$ pip install --target="/Applications/FreeCAD.app/Contents/lib/python2.7/site-packages" pycollada </pre>
|
|
<p>or after downloading the pycollada code
|
|
</p>
|
|
<pre>$ export PYTHONPATH=/Applications/FreeCAD\ 0.16.6706.app/Contents/lib/python2.7/site-packages:$PYTHONPATH
|
|
$ python setup.py install --prefix=/Applications/FreeCAD\ 0.16.6706.app/Contents </pre>
|
|
<h2><span class="mw-headline" id="IfcOpenShell">IfcOpenShell</span></h2>
|
|
<ul><li> homepage: <a rel="nofollow" class="external free" href="http://www.ifcopenshell.org">http://www.ifcopenshell.org</a></li>
|
|
<li> license: LGPL</li>
|
|
<li> optional, needed to extend import abilities of IFC files</li></ul>
|
|
<p>IFCOpenShell is a library currently in development, that allows to import (and soon export) <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Industry_Foundation_Classes">Industry foundation Classes (*.IFC)</a> files. IFC is an extension to the STEP format, and is becoming the standard in <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Building_information_modeling">BIM</a> workflows. When ifcopenshell is correctly installed on your system, the FreeCAD <a href="Arch_Module.html" title="Arch Module">Arch Module</a> will detect it and use it to import IFC files, instead of its built-in rudimentary importer. Since ifcopenshell is based on OpenCasCade, like FreeCAD, the quality of the import is very high, producing high-quality solid geometry.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Installation_4">Installation</span></h3>
|
|
<p>Since ifcopenshell is pretty new, you'll likely need to compile it yourself.
|
|
</p>
|
|
<h4><span class="mw-headline" id="Linux_3">Linux</span></h4>
|
|
<p>You will need a couple of development packages installed on your system in order to compile ifcopenshell:
|
|
</p>
|
|
<pre>liboce-*-dev
|
|
python-dev
|
|
swig </pre>
|
|
<p>but since FreeCAD requires all of them too, if you can compile FreeCAD, you won't need any extra dependency to compile IfcOpenShell.
|
|
</p><p>Grab the latest source code from here:
|
|
</p>
|
|
<pre>git clone https://github.com/IfcOpenShell/IfcOpenShell.git </pre>
|
|
<p>The build process is very easy:
|
|
</p>
|
|
<pre>mkdir ifcopenshell-build
|
|
cd ifcopenshell-build
|
|
cmake ../IfcOpenShell/cmake </pre>
|
|
<p>or, if you are using oce instead of opencascade:
|
|
</p>
|
|
<pre>cmake -DOCC_INCLUDE_DIR=/usr/include/oce ../ifcopenshell/cmake </pre>
|
|
<p>Since ifcopenshell is made primarily for Blender, it uses python3 by default. To use it inside FreeCAD, you need to compile it against the same version of python that is used by FreeCAD. So you might need to force the python version with additional cmake parameters (adjust the python version to yours):
|
|
</p>
|
|
<pre>cmake -DOCC_INCLUDE_DIR=/usr/include/oce -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/python2.7.so ../ifcopenshell/cmake </pre>
|
|
<p>Then:
|
|
</p>
|
|
<pre>make
|
|
sudo make install </pre>
|
|
<p>You can check that ifcopenshell was correctly installed by issuing in a python console:
|
|
</p>
|
|
<pre>import ifcopenshell </pre>
|
|
<p>If it returns nothing (no error message), then all is OK
|
|
</p>
|
|
<h4><span class="mw-headline" id="Windows_4">Windows</span></h4>
|
|
<p><i>Copied from the IfcOpenShell README file</i>
|
|
</p><p>Users are advised to use the Visual Studio .sln file in the win/ folder. For Windows users a prebuilt Open CASCADE version is available from the <a rel="nofollow" class="external free" href="http://opencascade.org">http://opencascade.org</a> website. Download and install this version and provide the paths to the Open CASCADE header and library files to MS Visual Studio C++.
|
|
</p><p>For building the IfcPython wrapper, SWIG needs to be installed. Please download the latest swigwin version from <a rel="nofollow" class="external free" href="http://www.swig.org/download.html">http://www.swig.org/download.html</a> . After extracting the .zip file, please add the extracted folder to the PATH environment variable. Python needs to be installed, please provide the include and library paths to Visual Studio.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Links">Links</span></h3>
|
|
<p>Tutorial <a href="https://www.freecadweb.org/wiki/index.php?title=Import/Export_IFC_-_compiling_IfcOpenShell" title="Import/Export IFC - compiling IfcOpenShell">Import/Export IFC - compiling IfcOpenShell</a>
|
|
</p>
|
|
<h2><span class="mw-headline" id="Teigha_Converter">Teigha Converter</span></h2>
|
|
<ul><li> homepage: <a rel="nofollow" class="external free" href="http://www.opendesign.com/guestfiles/Teigha_File_Converter">http://www.opendesign.com/guestfiles/Teigha_File_Converter</a></li>
|
|
<li> license: freeware</li>
|
|
<li> optional, used to enable import and export of DWG files</li></ul>
|
|
<p>The Teigha Converter is a small freely available utility that allows to convert between several versions of DWG and DXF files. FreeCAD can use it to offer DWG import and export, by converting DWG files to the DXF format under the hood,then using its standard DXF importer to import the file contents. The restrictions of the <a href="Draft_DXF.html" title="Draft DXF">DXF importer</a> apply.
|
|
</p>
|
|
<h3><span class="mw-headline" id="Installation_5">Installation</span></h3>
|
|
<p>On all platforms, only by installing the appropriate package from <a rel="nofollow" class="external free" href="http://www.opendesign.com/guestfiles/Teigha_File_Converter">http://www.opendesign.com/guestfiles/Teigha_File_Converter</a> . After installation, if the utility is not found automatically by FreeCAD, you might need to set the path to the converter executable manually, Change workbench to "Draft", than in the menu Edit -> Preferences -> Import/Export -> DWG and fill "Path to Teigha File Converter" appropriately.
|
|
</p>
|
|
|
|
<div style="clear:both"></div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Extra_python_modules/sv&oldid=277144">http://www.freecadweb.org/wiki/index.php?title=Extra_python_modules/sv&oldid=277144</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |