Python implementation of Valentina Pattern Making Software
Project description
PyValentina
PyValentina Home Page is located at http://fabricesalvaire.github.io/PyValentina
The latest documentation build from the git repository is available at readthedocs.org
Authored by Fabrice Salvaire.
Features
The features of PyValentina are :
read/write .val and .vit file
QMuParser expressions are translated to Python and evaluated on the fly
API to define patterns
compute the detail of a pattern
export the detail to latex/pgf as A0 or tiled A4 paper
Missing features:
full operation support
direct PDF export
SVG export
Introduction
PyValentina is a python implementation of the Valentina Pattern Making software, which only focus to implement the core engine and not the graphical user interface.
A pattern in flat pattern design is build from geometrical operations which can be turned to a computer program and is thus a field of applications of Computer Aided Design. It corresponds more precisely to parametric modelling with dedicated features to fashion modelling and manufacturing.
What is the requirements of a pattern drafting software ?
The core functionality of a CAD system for pattern drafting consists of these two software components :
an open file format to store and exchange the pattern,
a geometrical engine to compute the pattern, e.g. to generate the layout of each fabric’s piece of a clothe.
The XML language is a natural candidate to define an open file format to store and exchange the pattern. Valentina uses XML to sore measurements in .vit files and patterns in .val files.
Another solution to define and store a pattern is to use a programming language, it can be a dedicated language or any programming language associated to a dedicated API. Many graphical languages was invented for specific usages, e.g. PostScript for printer, Metafont and MetaPost for publishing, G-code for machining etc.
Usually the geometrical operations of a pattern are simple in comparison to the requirements of a mechanical or electronic CAD software. In first hand it is only 2D and the number of operations should be handled smoothly by a computer of these days, whereas it is still challenging for other domains.
Finally, a pattern drafting software requires an efficient graphical user interface so as to be used by fashion designers and not only by hackers. This software component is more challenging in therms of software engineering, i.e. in therms of design and cost.
Why Python is a good language for this library ?
The Python language has a large audience in engineering, due to its canonical syntax and richness of its ecosystem (scientific libraries).
Python is a high level language and thus more productive.
Python is used as scripting language to extend many softwares, in particular the famous open source 3D creation suite Blender, the parametric 3D modeller FreeCad as well as the SVG editor Inkscape. Moreover the 3D human model generator MakeHuman is written in Python.
Python can be easily extended by C libraries using CFFI and C++ libraries using SWIG.
Python as other dynamic languages is able to evaluate code on the fly which provide an expression evaluator for free. And this feature is even more pertinent in our case because of the canonical nature of the syntax of Python which is natural to somebody initiated to a basic mathematical language level.
What is the purpose of this library ?
This library could serve several purposes :
help to experiment core features for pattern drafting,
plug Valentina to software featuring a Python plugin mechanism like Blender, FreeCad etc.
Could we implement a full software using Python ?
The answer is yes we can! since Qt has as a nice binding so called PyQt.
But up to now Python has of course some drawbacks!
Its main drawback is due to the fact the standard interpreter cannot execute more than one Python bytecode thread at once, this limitation so called Global Interpreter Lock is required for implementation simplicity.
Despite a GUI implemented in PyQt is almost of the time more faster than the human perception on a computer of these days. It can be sometime difficult to overcome latency arising from the software stack. Thus yes we can do it, but it could requires some tricks to achieve the performance of a C++ application.
How to generate drawings in standard format like PDF or SVG ?
SVG is not difficult to generate from Python since it is based on XML. However the PDF format is more challenging, for efficiency reason PDF is a binary format and is thus much more complicated than PostScript which is a true programming language.
There is several possibilities to generate PDF.
The most disturbing one is to use the LaTeX publishing system in combination with the PGF package which provide an amazing graphical language on top of LaTeX. This solution could terrify many peoples, but it do the job very well for text and graphics. However user must install a LaTeX environment from their Linux distribution or using the TexLive distribution.
A more conventional solution requires a library that can generate PDF from standard graphical operations. Some libraries featuring that are :
Qt using QPainter API, Valentina solution, see https://wiki.qt.io/Handling_PDF
ReportLab open-source PDF Toolkit (more commercial and less known)
Matplotlib (but more oriented to plot)
and ???
Installation
The installation of PyValentina by itself is quite simple. However it will be easier to get the dependencies on a Linux desktop.
Dependencies
PyValentina requires the following dependencies:
Also it is recommanded to have these Python modules:
pip
virtualenv
For development, you will need in addition:
Installation from PyPi Repository
PyValentina is made available on the PyPI repository at https://pypi.python.org/pypi/PyValentina
Run this command to install the last release:
pip install PyValentina
Installation from Source
The PyValentina source code is hosted at https://github.com/FabriceSalvaire/PyValentina
To clone the Git repository, run this command in a terminal:
git clone git@github.com:FabriceSalvaire/PyValentina.git
Then to build and install PyValentina run these commands:
python setup.py build
python setup.py install
Bibliography
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file PyValentina-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: PyValentina-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 69.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e3a393690b9119de22f23f45871f7199ae920e556ad5a6c50b69b3b08c67b4 |
|
MD5 | 642fe95cafe20fe690a344ae764a2add |
|
BLAKE2b-256 | ef15113d4c14384fc8609f5bcdc59aaaed4d2be5d8acc7b151ffa7677124894c |