Skip to main content

The LDraw to OpenSCAD converter library

Project description

ldraw-to-scad

A tool to convert from an LDraw drawing to an Open SCAD CAD file

State: Alpha Intent: Converting LDraw projects to Open SCAD to render, animate or use for other assemblies.

Usage

Requires python3, with no external python dependancies:

ldraw2scad <ldraw file> <scad file>

Besides this basic parameters several options are available to generate results either as self-contained OpenSCAD files or relying on an LDraw OpenSCAD library that can be generated with this tool as well. Invoke the tool with the --help option for more information.

By default it requires the ldraw library in lib/ldraw relative to the working directory you run this from. Alternatively you can point the tool to a different location for the libray with the --lib option. It also (naively) expects the ldraw library filenames to be lowercase.

Testing

Install the test-requirements.txt file, then run pip install -e . and finally pytest ..

Making animations

This requires a bit of OpenSCAD knowledge. First - ensure you have clearly separated the sections that will move relative to each other. You can put them either in one single MPD file or put them in a couple of separate LDraw DAT files.

You can then add the movement transformations. LDraw actually stores matrices that are relative to the parts origin. You will want to wrap these in simple transformations - like translate and rotate.

OpenSCAD has a special variable $t - which is a time offset between 0 and 1. You can multiple $t by a value to create movement. You can then enable animation in the window options, and specify a framerate, and the total number of steps in the animation.

This will start OpenSCAD rendering in the preview window. To start exporting the frames - tick the "Dump Pictures" box under the window. Warning - "Dump Pictures" will dump the resolution the preview window is in, which may be a bit odd.

You can then use FFMpeg or AVtools to stitch them into a video:

avconv -framerate 20 -i frame%05d.png -c:v libx264 -r 30 out.mp4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ldraw_to_scad-0.5.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ldraw_to_scad-0.5.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file ldraw_to_scad-0.5.0.tar.gz.

File metadata

  • Download URL: ldraw_to_scad-0.5.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ldraw_to_scad-0.5.0.tar.gz
Algorithm Hash digest
SHA256 42d0eb2476ed618f7545fc5ccc6bd9d6f46b1ca1e0736a251935507b0be001e6
MD5 ed5b81b904c0aa001827d0ef53bebbdf
BLAKE2b-256 7ba00e28240208c8a7bd47985927c79f61a71cbc85da2748a28377126d508997

See more details on using hashes here.

File details

Details for the file ldraw_to_scad-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ldraw_to_scad-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ldraw_to_scad-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a384cb998a6ff4b85ff22ccd810b3538e4d562fb53b17f3e1604e2d888b63b08
MD5 eb27d8d25c48c30ab407711436c2f6cd
BLAKE2b-256 7287bc710b4b9b4b72128fb3c2afe2859676910bf5c8689aca4cdf6f502f3fa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page