mirror of
https://github.com/kristov/ldraw2stl.git
synced 2025-05-15 14:20:11 -07:00
Remove dependency on Moose
It was annoying to install tens of Perl modules for a few getters-setters.
This commit is contained in:
parent
e3f34ac87b
commit
ac0c4d00b8
12
README.md
12
README.md
@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
Convert LEGO LDraw files to STL, for super-sizing and 3d printing!!
|
Convert LEGO LDraw files to STL, for super-sizing and 3d printing!!
|
||||||
|
|
||||||
1) Get the ldraw parts archive at http://www.ldraw.org or apt-get install ldraw-parts
|
1) Get the ldraw parts archive at [](http://www.ldraw.org/article/13.html):
|
||||||
|
|
||||||
2) Install LeoCAD so you can find your parts
|
wget http://www.ldraw.org/library/updates/complete.zip
|
||||||
|
unzip complete.zip
|
||||||
|
bin/dat2stl --file ldraw/parts/3894.dat --ldrawdir ./ldraw
|
||||||
|
|
||||||
|
2) Install LeoCAD so you can find your parts (optional)
|
||||||
|
|
||||||
3) Make a note of the .dat file name in LeoCAD, and then run:
|
3) Make a note of the .dat file name in LeoCAD, and then run:
|
||||||
|
|
||||||
bin/dat2stl --file /usr/share/ldraw/parts/3894.dat --scale 4 > 3894.stl
|
bin/dat2stl --file /usr/share/ldraw/parts/3894.dat --ldrawdir ./ldraw --scale 4 > 3894.stl
|
||||||
|
|
||||||
For a 4X scale one of those!
|
For a 4X scale one of those!
|
||||||
|
|
||||||
Depends on Moose.
|
|
||||||
|
@ -1,55 +1,50 @@
|
|||||||
package LDraw::Parser;
|
package LDraw::Parser;
|
||||||
|
|
||||||
use Moose;
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
has file => (
|
sub new {
|
||||||
is => 'ro',
|
my ($class, $args) = @_;
|
||||||
isa => 'Str',
|
die "file required" unless $args->{file};
|
||||||
required => 1,
|
return bless({
|
||||||
documentation => 'The file to parse',
|
file => $args->{file},
|
||||||
);
|
ldraw_path => $args->{ldraw_path} // '/usr/share/ldraw',
|
||||||
|
scale => $args->{scale} // 1,
|
||||||
|
mm_per_ldu => $args->{mm_per_ldu} // 0.4,
|
||||||
|
invert => $args->{invert} // 0,
|
||||||
|
debug => $args->{debug} // 0,
|
||||||
|
d_indent => $args->{d_indent} // 0,
|
||||||
|
}, $class);
|
||||||
|
}
|
||||||
|
|
||||||
has ldraw_path => (
|
sub _getter_setter {
|
||||||
is => 'ro',
|
my ($self, $key, $value) = @_;
|
||||||
isa => 'Str',
|
if ($value) {
|
||||||
default => '/usr/share/ldraw',
|
$self->{$key} = $value;
|
||||||
documentation => 'Where to find ldraw files',
|
}
|
||||||
);
|
return $self->{$key};
|
||||||
|
}
|
||||||
|
|
||||||
has scale => (
|
# The file to parse
|
||||||
is => 'rw',
|
sub file { return shift->_getter_setter('file', @_); }
|
||||||
isa => 'Num',
|
|
||||||
default => 1.0,
|
|
||||||
documentation => 'Scale the model',
|
|
||||||
);
|
|
||||||
|
|
||||||
has mm_per_ldu => (
|
# Where to find ldraw files
|
||||||
is => 'rw',
|
sub ldraw_path { return shift->_getter_setter('ldraw_path', @_); }
|
||||||
isa => 'Num',
|
|
||||||
default => 0.4,
|
|
||||||
documentation => 'Number of mm per LDU (LDraw Unit)',
|
|
||||||
);
|
|
||||||
|
|
||||||
has invert => (
|
# Scale the model
|
||||||
is => 'rw',
|
sub scale { return shift->_getter_setter('scale', @_); }
|
||||||
isa => 'Bool',
|
|
||||||
default => 0,
|
|
||||||
documentation => 'Invert this part',
|
|
||||||
);
|
|
||||||
|
|
||||||
has debug => (
|
# Number of mm per LDU (LDraw Unit)
|
||||||
is => 'rw',
|
sub mm_per_ldu { return shift->_getter_setter('mm_per_ldu', @_); }
|
||||||
isa => 'Bool',
|
|
||||||
default => 0,
|
|
||||||
documentation => 'Print debugging messages to stderr',
|
|
||||||
);
|
|
||||||
|
|
||||||
has d_indent => (
|
# Invert this part
|
||||||
is => 'ro',
|
sub invert { return shift->_getter_setter('invert', @_); }
|
||||||
isa => 'Int',
|
|
||||||
default => 0,
|
# Print debugging messages to stderr
|
||||||
documentation => 'Indentation for debug messages (for subfiles)',
|
sub debug { return shift->_getter_setter('debug', @_); }
|
||||||
);
|
|
||||||
|
# Indentation for debug messages (for subfiles)
|
||||||
|
sub d_indent { return shift->_getter_setter('d_indent', @_); }
|
||||||
|
|
||||||
use constant X => 0;
|
use constant X => 0;
|
||||||
use constant Y => 1;
|
use constant Y => 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user