Website: http://www.pyslvs.com/blog/index.html
A GUI-based tool solving 2D linkage subject.
-
Planar Linkages Simulation: Kernel from Solvespace with Python bundle (SWIG).
-
Dimensional Synthesis: Kernel from three Cython algorithm API (rewrite).
Compatible with Python 3.5, PyQt 5.7 (for PyQtChart) and above.
Cross-platform Development: Ubuntu and Windows (64-bit).
You should install Graphviz first. See here.
Please note that the other platforms may be available but I have not tested before.
Previews in KDE Plasma desktop:
Previews in Windows 8.1 theme:
Open GUI by Python:
python3 launch_pyslvs.py
Or see the help:
python3 launch_pyslvs.py --help
Referring symbolic from PMKS.
The PMKS expression is using a name label to present a link bar.
A joint between two links will get two name labels, and so on.
The "ground" label is a default name, this link will be the absolute coordinate in the system, might be a frame of your mechanism.
Pyslvs was translate the PMKS expression as a string, like below:
M[J[R, color[Green], P[0.0, 0.0], L[ground, link_0]], J[R, color[Green], P[12.92, 32.53], L[link_0, link_1]], J[R, color[Green], P[73.28, 67.97], L[link_1, link_2]], J[R, color[Green], P[33.3, 66.95], L[link_1]], J[R, color[Green], P[90.0, 0.0], L[ground, link_2]]]
Then the expression can be parse in Pyslvs to create the mechanism.
Analysis a type of mechanism that exists, and find out other possibilities.
We have a topological algorithm to combine atlas with:
- Same degree of freedom.
- Same number of link.
- Same number of joint.
And use a type of mechanism to do grounding combine.
Grounding combine can merge the structure diagram immediately to canvas.
But in the common ways, you can give it to dimensional synthesis to make it more useful.
Before doing dimensional synthesis, a structure diagram has to configure it's verification formula.
PLAP function is using two known points, a length variable and an angle variable to find out the position of third point.
PLLP function is using two known points and two length variables to find out the position of third point.
When the structure profile is complete, is time to doing dimensional synthesis!
Generate a mechanism with path requirement by random variables.
Contains three algorithms:
- Real Genetic Algorithm
- Firefly Algorithm
- Differential Evolution
Specify a path and options to generate a crank rocker.
This function has a simple TCP ZMQ connecting mode.
You should install some python module and SDK first.
The Makefile is included at compile steps, so some environment setting also should be set.
Ubuntu:
$ sudo pip3 install -r requirements.txt
Windows:
Python 3: Official Python for Windows 64 bit.
Makefile tool: MinGW or Msys 2.
> pip install -r requirements.txt
Graphviz tools provide some graph engine that can make the position of dots in atlas looks more pretty.
Download it from here or:
$ sudo apt install graphviz
Windows user please make sure to add Graphviz bin
folder path to environment variables.
Then use the dot
command to check if it works.
If you are not willing to install Graphviz, you can just using built-in layout from NetworkX.
PyQt5 and QtChart are now pack into the wheel file that Windows and Ubuntu can use them.
When the installation is complete by pip, some stuff need to remind you.
Qt tools can use to design the user interface, they are not the requirement if you just want to run Pyslvs.
Ubuntu:
Download Qt5 and install it, then we will get the tools.
If your desktop is made by earlier Qt version, you should install in another place.
Download and install / upgrade SIP.
>>> import sip
>>> print(sip, sip.SIP_VERSION_STR)
Then remove SIP from the location:
$ sudo rm -fr /usr/local/libs/python3.5/dist-packages/sip*
Or maybe directly:
$ sudo pip3 install sip -U
Windows:
Windows user can get Qt tools by pip, and don't need to install Qt package.
> pip install pyqt5-tools
Make command:
make build-kernel
This project including 2 kernels should build, please following the steps if you are first time to use.
Make command:
make -C core/libs/python_solvespace
Ubuntu:
First, install SWIG. This tool kit can make a Python bundle with C/C++ library.
If your not, install python development kit.
sudo apt install swig python3-dev
Windows:
Download and install SWIG.
If your Python doesn't have development library, like libpython35.a
, using gendef
to generate it.
In Python 3.6 and above versions, you do not have to get lib file.
First copy python3x.dll
to where_your_python\libs
folder.
Then using this command:
gendef python3x.dll
dlltool --dllname python3x.dll --def python3x.def --output-lib libpython3x.a
You need to modify a few of Python files to avoid these conflicts before compile the library. But you can be assured that the changes won't cause any negative impact.
Find this code in where_your_python\Lib\distutils\cygwinccompiler.py
:
# no additional libraries needed
self.dll_libraries=[]
# Include the appropriate MSVC runtime library if Python was built
# with MSVC 7.0 or later.
self.dll_libraries = get_msvcr()
Commit self.dll_libraries = get_msvcr()
.
And then adjust source code about Virtual Studio. Find this code in where_your_python\include\pyconfig.h
.
#ifdef _WIN64
#define MS_WIN64
#endif
Cut them and paste Above this:
#ifdef _MSC_VER
You also will get warning with _hypot
in pyconfig.h
, and you should do this step.
In where_your_python\include\pyconfig.h
, find this:
#define COMPILER "[gcc]"
#define hypot _hypot
Edit it to this:
#define COMPILER "[gcc]"
#ifndef _MATH_H_
#define hypot _hypot
#endif
Type and Dimensional synthesis libraries.
Make command:
make build-cython
Ubuntu:
Ubuntu user can compile the kernel by Cython directly.
Windows:
There's two options to choose SDK:
- Using Microsoft Visual Studio. You can get it from here, then startup the Visual Studio Community and install Windows SDK.
- Using Msys 2. It is based on MinGW 64-bit version.
After the actual test, Microsoft Visual Studio SDK will take a large of file size in your disk, but the executable file will smaller than Msys.
One benefit of Msys is that it is portable.
As your wish, it can be renamed or moved out and operate independently in no-Python environment.
Ubuntu:
Use shell command to build as AppImage.
After following operation, the executable file is in out
folder.
Make command:
$ sudo pip3 install virtualenv
$ make
Windows:
Use PyInstaller to build.
After following operation, the executable file is in dist
folder.
Make command:
> pip install pyinstaller
> make
Made by Qt5 and Python IDE Eric 6.
Including Python modules:
- SIP (GPLv2, GPLv3)
- PyQt5, PyQtChart (GPLv3)
- dxfwrite (MIT)
- numpy (BSD 3-Clause)
- Cython (Apache 2.0)
- PyZMQ (New BSD 3-Clause, LGPL, Apache)
- openpyxl (MIT)
- psutil (BSD)
- peewee (MIT)
- Lark-parser (MIT)
- NetworkX (BSD 3-Clause)
- Pydot (MIT)
Pyslvs is under GNU Affero General Public License v3.
Here is the origin kernel repository: