461 lines
36 KiB
HTML
461 lines
36 KiB
HTML
<html><head><title>Extra python modules/ru</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/ru</h1></div>
|
||
|
||
<div id="mw-content-text" lang="ru" 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="#.D0.94.D0.BE.D0.BA.D1.83.D0.BC.D0.B5.D0.BD.D1.82.D0.B0.D1.86.D0.B8.D1.8F"><span class="tocnumber">1.4</span> <span class="toctext">Документация</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="#.D0.A3.D1.81.D1.82.D0.B0.D0.BD.D0.BE.D0.B2.D0.BA.D0.B0"><span class="tocnumber">2.1</span> <span class="toctext">Установка</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="#.D0.94.D1.80.D1.83.D0.B3.D0.B8.D0.B5_linux_.D0.B4.D0.B8.D1.81.D1.82.D1.80.D0.B8.D0.B1.D1.83.D1.82.D0.B8.D0.B2.D1.8B"><span class="tocnumber">2.1.3</span> <span class="toctext">Другие linux дистрибутивы</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="#Additonal_Documentation"><span class="tocnumber">2.3</span> <span class="toctext">Additonal Documentation</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_2"><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_3"><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_4"><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>Note:</b> FreeCAD progressively moved away from PyQt after version 0.13, in favour of <a rel="nofollow" class="external text" href="http://qt-project.org/wiki/PySide">PySide</a>, which does exactly the same job but has a license (LGPL) more compatible with FreeCAD.
|
||
</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=".D0.94.D0.BE.D0.BA.D1.83.D0.BC.D0.B5.D0.BD.D1.82.D0.B0.D1.86.D0.B8.D1.8F">Документация</span></h3>
|
||
<p>Больше учебников по pyQt4 (в том числе от том как использовать в python интерфейс построенный с помощью Qt Designer):
|
||
</p>
|
||
<ul><li> <a rel="nofollow" class="external free" href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/classes.html">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/classes.html</a> - фициальное руководство по PyQt4 API</li></ul>
|
||
<ul><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> - простенькое введение</li></ul>
|
||
<ul><li> <a rel="nofollow" class="external free" href="http://www.zetcode.com/tutorials/pyqt4/">http://www.zetcode.com/tutorials/pyqt4/</a> - очень полный и подробный учебник</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=".D0.A3.D1.81.D1.82.D0.B0.D0.BD.D0.BE.D0.B2.D0.BA.D0.B0">Установка</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>Начиная с Debian Squeeze и Ubuntu Lucid, pivy стал доступен напрямую через официальные репозитории, экономя ваше время. В то же время вы можете скачать один из пакетов что мы сделали (для debian и ubuntu karmic) доступных на странице <a href="Download.html" title="Download">Загрузок</a> , или скомпилировать их самостоятельно.
|
||
</p>
|
||
<div class="mw-translate-fuzzy">
|
||
<p>Лучший способ скомпилировать pivy просто вытянуть debian пакет с исходными кодами для pivy и сделать пакет с помощью debuild. Это тот же исходный код что и на оффициальном сайте pivy , но люди debian исправили несколько ошибок. Он также хорошо компилируется в ubuntu karmic из: <a rel="nofollow" class="external free" href="http://packages.debian.org/squeeze/python-pivy">http://packages.debian.org/squeeze/python-pivy</a> (скачайте .orig.gz и .diff.gz файл, распокуйте оба, добавте .diff к исходному коду: перейдите к каталогу с распакованными кодами pivy , и примените .diff патч:
|
||
</p>
|
||
</div>
|
||
<pre>patch -p1 < ../pivy_0.5.0~svn765-2.diff </pre>
|
||
<p>затем
|
||
</p>
|
||
<pre>debuild </pre>
|
||
<p>теперь у вас есть правильно собраный pivy в оффициально устанавливаемых пакетах. Теперь, просто установите пакет с помощью gdebi.
|
||
</p>
|
||
<h4><span class="mw-headline" id=".D0.94.D1.80.D1.83.D0.B3.D0.B8.D0.B5_linux_.D0.B4.D0.B8.D1.81.D1.82.D1.80.D0.B8.D0.B1.D1.83.D1.82.D0.B8.D0.B2.D1.8B">Другие linux дистрибутивы</span></h4>
|
||
<p>Сперва получите код из официального репозитория проекта:
|
||
</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>Затем вам понадобится инструмент называемыйd SWIG для создания C++ кода для Python привязок. Рекомендуется использовать версию SWIG 1.3.25 , не последнюю версию, потому как на данный момент pivy корректно работает только с 1.3.25. Скачайте 1.3.25 tarball с исходными кодамииз <a rel="nofollow" class="external free" href="http://www.swig.org">http://www.swig.org</a>. Распакуйте и в командной строке (под root-ом):
|
||
</p>
|
||
<pre>./configure
|
||
make
|
||
make install (or checkinstall if you use it) </pre>
|
||
<p>Сборка занимает всего несколько секунд.
|
||
</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>After that go to the pivy sources and call
|
||
</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>This is probably obsolete, but you may run into a compiler error where a 'const char*' cannot be converted in a 'char*'. To fix that you just need to write a 'const' before in the appropriate lines. There are six lines to fix.
|
||
</p><p>After that, install by issuing (as root):
|
||
</p>
|
||
<pre>python setup.py install (or checkinstall python setup.py install) </pre>
|
||
<p>That's it, pivy is installed.
|
||
</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>Предполагается использование Visual Studio 2005 или позднии версии вы предется открыть командную строку 'Visual Studio 2005 Command prompt' из меню Tools.
|
||
Если Python интерпритатор ещё не прописан в системном пути, сделайте это
|
||
</p>
|
||
<pre>set PATH=path_to_python_2.5;%PATH% </pre>
|
||
<p>Чтобы получить работающий pivy вы должны получить последнюю версию исходников из репозитория проекта:
|
||
</p>
|
||
<pre>svn co https://svn.coin3d.org/repos/Pivy/trunk Pivy </pre>
|
||
<p>Затем вам понадобится инструмент называемыйd SWIG для создания C++ кода для Python привязок. Рекомендуется использовать версию SWIG 1.3.25 , не последнюю версию, потому как на данный момент pivy корректно работает только с 1.3.25. Скачайте 1.3.25 tarball с исходными кодамииз <a rel="nofollow" class="external free" href="http://www.swig.org">http://www.swig.org</a>. Затем распакуйте его и в командной строке добавте к системному пути
|
||
</p>
|
||
<pre>set PATH=path_to_swig_1.3.25;%PATH% </pre>
|
||
<p>и установите COINDIR на соответсвующий путь
|
||
</p>
|
||
<pre>set COINDIR=path_to_coin </pre>
|
||
<p>В Windows pivy конфигурационный файл нахотится в SoWin вместо SoQt по умолчанию. Мне не удалось найти очевидный способ собрать с SoQt, поэтому я изменил файл непосредственно setup.py.
|
||
В 200 строке удалите часть 'sowin' : ('gui._sowin', 'sowin-config', 'pivy.gui.') (не удалйте закрывающиеся скобки).
|
||
</p><p>После чего отправляйтесь к исходным кодам pivy и введите команду
|
||
</p>
|
||
<pre>python setup.py build </pre>
|
||
<p>которая создаст исходные файлы. Вы можете столкнуться с ошибками компилятора -несколько заголовочных файлов не может быть найдено. В этом случае отрегулируйте INCLUDE переменную
|
||
</p>
|
||
<pre>set INCLUDE=%INCLUDE%;path_to_coin_include_dir </pre>
|
||
<p>если нет заголовочных файлов SoQt на месте , также с заголовками Coin
|
||
</p>
|
||
<pre>set INCLUDE=%INCLUDE%;path_to_soqt_include_dir </pre>
|
||
<p>и в конце Qt заголовочные файлы
|
||
</p>
|
||
<pre>set INCLUDE=%INCLUDE%;path_to_qt4\include\Qt </pre>
|
||
<p>Если вы используете Express Edition версию Visual Studio вы можете получить исключение python keyerror.
|
||
В этом случае Вам необходимо изменить кое-что в msvccompiler.py расположенный в месте кужа вы установили Python.
|
||
</p><p>шагом марш на 122 строку и замените строку
|
||
</p>
|
||
<pre>vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version </pre>
|
||
<p>на
|
||
</p>
|
||
<pre>vsbase = r"Software\Microsoft\VCExpress\%0.1f" % version </pre>
|
||
<p>Повторите сборку снова.
|
||
Если вы получили вторую ошибку, вроде
|
||
</p>
|
||
<pre>error: Python was built with Visual Studio 2003;... </pre>
|
||
<p>вы должны поменять 128 строку
|
||
</p>
|
||
<pre>self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") </pre>
|
||
<p>на
|
||
</p>
|
||
<pre>self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0") </pre>
|
||
<p>Повторите сборку снова. Если вы опять получили ошибку
|
||
</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>проверте пересеменные окружения DISTUTILS_USE_SDK и MSSDK с помощью
|
||
</p>
|
||
<pre>echo %DISTUTILS_USE_SDK%
|
||
echo %MSSDK% </pre>
|
||
<p>Если они еще не установлены, то просто установите например, до 1
|
||
</p>
|
||
<pre>set DISTUTILS_USE_SDK=1
|
||
set MSSDK=1 </pre>
|
||
<p>Вы можете столкнуться при компиляции с ошибкой 'const char*' cannot be converted in a 'char*'. Чтобы исправить это вам необходимо написать 'const' перед следующей строкой(char*). Исправте ещё шесть строк.
|
||
После чего, скопируйте созданный pivy каталог, в место где python интрепритатор FreeCAD сможет найти его.
|
||
</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>Чтобы Pivy получил доступ FreeCAD древу сцен сделайте следующие:
|
||
</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>Теперь вы можете изучать FCSceneGraph с помощью команды dir().
|
||
</p>
|
||
<h3><span class="mw-headline" id="Additonal_Documentation">Additonal Documentation</span></h3>
|
||
<p>Unfortunately documentation about pivy is still almost inexistant on the net. But you might find Coin documentation useful, since pivy simply translate Coin functions, nodes and methods in python, everything keeps the same name and properties, keeping in mind the difference of syntax between C and 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>Вы также можете просмотреть в Draft.py файл в папке FreeCAD Mod/Draft , так как там часто используется pivy.
|
||
</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_2">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_3">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_4">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/ru&oldid=277146">http://www.freecadweb.org/wiki/index.php?title=Extra_python_modules/ru&oldid=277146</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> |