Package: pyldraw
pyldraw Python PackageAuthor:rienafairefrcode originally fromDavid BoddieContentspyldraw Python PackageIntroductionCompatibilityInstallationAuto-generation of the ldraw.library.* packageExamplesPart DescriptionsWriters and ToolsLicenseTrademarksOriginsIntroductionLDrawis a standard format used by CAD applications that create LEGO models
and scenes.Thepyldrawpackage provides facilities to allow users to create LDraw scene
descriptions using thePythonprogramming language. Pieces are specified by
their positions, orientations and other properties in normal executable Python
scripts which are run to create model files.Thepyldrawpackage includes code to have the complete LDraw library available
to you through normal Python imports, like:from ldraw.library.colours import Light_Grey
from ldraw.library.parts.minifig.accessories import Seat2X2
from ldraw.library.parts.others import Brick1X2WithClassicSpaceLogoPatternThe actual parts library hierarchy (in which subpackage each brick is, etc…),
is still a work in progress. You can always specify parts by their LDraw code:rover = group()
Piece(Light_Grey, Vector(-10, -32, -90),
          Identity(), "3957a", rover)CompatibilityThis is tested on Python 2.7, and 3.4+InstallationThe simplest way is through pip:pip install pyldrawAuto-generation of the ldraw.library.* packageThe ldraw.library.* package is kind of special, it is auto-generated from a LDraw parts library (complete.zip)
with the parts.lst itself auto-generated usingpymklist.
On running code that needs something in the ldraw.library, pyldraw will know (through asys.meta_pathhook)
and attempt to auto-generate it on-the-fly.
Considering that the toolchain complete.zip download, parts.lst generation, python code generation takes
quite some time, and we don’t want to re-download anyway,
the generated library will be cached and reused on subsequent import or python scripts run.
If you setup another parts.lst or modify it, the library will be re-generated.
The cached generated library is stored in the directory where the ldraw package is, if that’s user-writeable,
otherwise in an OS-dependent cache directory (somewhere in ~/.cache for example)ConfigurationThe parts.lst that is used for this generation is setup inside the configuration file (a simple YAML file)
To get some info about where the configuration file is, usepython -m ldraw.configYou can specify where the library is generated by providing alibraryoption in this configurationExamplesA number of examples are provided in theexamplesdirectory. When run, each
of these will write model information to the console. To create a model file
from an example, redirect its output to a file.Part DescriptionsEven though this package does include a list of parts derived from those supplied in
the official LDraw archive, users can download or modify this
list separately. The ldraw.library.* hierarchy will stay current with the LDraw database
setup in the configurationParts are available from the ldraw.library namespace as described above, but you can also use the Parts class:from ldraw.parts import Parts
parts = Parts("parts.lst") # provide your custom parts.lst pathParts can then be accessed using the relevant dictionary
attributes of thepartsinstance. For example:cowboy_hat = parts.minifig.hats["Hat Cowboy"]
head = parts.minifig.heads["Head with Solid Stud"]
brick1x1 = parts.others["Brick  1 x  1"]Writers and ToolsTheldraw.writerspackage aims to provide a set of classes that write out
LDraw descriptions in other file formats. Currently, it contains thepovraymodule which provides a class for writing out LDraw descriptions as POV-Ray
scenes.Theldr2povtool, uses thepovraymodule to allow LDraw (.ldr) files
to be conveniently converted to POV-Ray (.pov) scene files.
Note that, since the LDraw format does not include
information about camera locations, it is necessary to pass this information
on the command line.For example, on a GNU/Linux system, we can execute command lines like these
to take thefigures.pyexample file, create an LDraw model file (temp.ldr),
and convert that to a POV-Ray scene file (temp.pov):python examples/figures.py > temp.ldr
ldr2pov /path/to/parts.lst models/figures.ldr temp.pov 160.0,80.0,-240.0
povray +Itemp.pov +FN16 +Otemp.png +Q6Finally, POV-Ray is used to process the scene description and create a PNG
image file (temp.png).Some other tools and writers are included,ldr2inv:Transforms a LDR file into a file containing the Bill Of Materials or Inventory of the modelldr2pngRenders the LDR file into a PNG fileldr2svgRenders the LDR file into a vector image in SVGLicenseThe contents of this package are licensed under the GNU General Public License
(version 3 or later):pyldraw, a Python package for creating LDraw format files.
Copyright (C) 2008 David Boddie <david@boddie.org.uk>

Some parts Copyright (C) 2018 Matthieu Berthomé <rienafairefr@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.TrademarksLDraw is a trademark of the Estate of James Jessiman. LEGO is a registered
trademark of the LEGO Group.OriginsThis repo was extracted from the mercurial repository athttps://anonscm.debian.org/hg/python-ldraw/mainIt will not try to stay updated with the upstream repo of the original author, David Boddie,
The goal is to see what might be done, the original repo hasn’t been updated since 2011