Get flex out there


Other part families Re: Get flex out there
#22
What other parts need a similar treatment? I've already modded the code to deal with flexibile hose with

0 Technic Ribbed Hose XX Ribs

but it's easy to modify for other standardised parts.

Tim

PS. perl code below for anyone who wishes to do their own sets
Code:
use POSIX;
sub round {
    return(floor(0.5+$_[0]));
}

# Auto generation file prefix (suffix is length)
$fpre="79c";
$author="Timothy Gould [timgould]";
#Description prefix
$pdesc="Technic Ribbed Hose ";
#Description suffix
$ldesc=" Ribs";

@length=();
foreach $i (2..30) {
    push @length, round(10*$i/3.1)
}

# Length => Part number, Length => Part number, ...
%specno = (13=>71952);

foreach $l (@length)
{
    $id=sprintf("%02d",$l); # Ensure space for two characters (with 0)
    $tlen=sprintf("%2d",$l); # Ensure space for two characters (no 0)
    if (exists $specno{$l}) {
    # If there's a special name
    $fname=$specno{$l}.".dat";
    } else {
    # Otherwise
    $fname=$fpre.$id.".dat";
    }
    # Set the part description
    $partdesc="$pdesc$tlen$ldesc";

    print $fname." => ".$partdesc."\n";

    # Length of a segment
    $lseg=6.2;
    # Start segment (for centering)
    $sseg=($l-1)/2*$lseg;

    # Generate the body of the part
    $body="";
    # First segment
    $y=$sseg;
    $body=$body.sprintf("1 16 %.1f 0 0 0 1 0 1 0 0 0 0 -1 79.DAT\n", $y);
    # Middle segments
    foreach $i (1..($l-2)) {
    $y=$sseg-$i*$lseg;
    $body=$body.
        sprintf("1 16 %.1f 0 0 0 -1 0 1 0 0 0 0 1 80.DAT\n",$y);
    }
    # Last segment
    $y=-$sseg;
    $body=$body.sprintf("1 16 %.1f 0 0 0 -1 0 1 0 0 0 0 1 79.DAT\n",$y);

# Make the part text
$mask="0 $partdesc
0 Name: $fname
0 Author: $author
0 !LDRAW_ORG Unofficial_Part
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt

0 BFC CERTIFY CCW

$body
";
# Write the part
    open(FIL,">$fname");
    print FIL $mask;
    close(FIL);
}

$no=$#length+1;
print "Generated $no parts\n";
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Get flex out there - by Tim Gould - 2011-12-20, 21:08
Re: Get flex out there - by Tim Gould - 2011-12-20, 21:10
Re: Get flex out there - by Travis Cobbs - 2011-12-20, 21:13
Re: Get flex out there - by Tim Gould - 2011-12-20, 21:17
Re: Get flex out there - by Travis Cobbs - 2011-12-20, 21:32
Re: Get flex out there - by Steffen - 2011-12-20, 21:23
Re: Get flex out there - by Tim Gould - 2011-12-20, 21:28
Re: Get flex out there - by Orion Pobursky - 2011-12-20, 22:06
Re: Get flex out there - by Orion Pobursky - 2011-12-20, 22:11
Re: Get flex out there - by Tim Gould - 2011-12-20, 22:21
Re: Get flex out there - by Tim Gould - 2011-12-20, 22:23
Re: Get flex out there - by Tim Gould - 2011-12-21, 9:07
Re: Get flex out there - by Chris Dee - 2011-12-21, 13:02
Re: Get flex out there - by Orion Pobursky - 2011-12-21, 14:17
Re: Get flex out there - by Chris Dee - 2011-12-21, 14:29
Re: Get flex out there - by Orion Pobursky - 2011-12-21, 15:26
Re: Get flex out there - by Steffen - 2011-12-21, 17:03
Re: Get flex out there - by Tim Gould - 2011-12-21, 20:24
Re: Get flex out there - by Chris Dee - 2011-12-21, 20:35
Re: Get flex out there - by Tim Gould - 2011-12-21, 20:44
Other part families Re: Get flex out there - by Tim Gould - 2012-01-01, 0:58

Forum Jump:


Users browsing this thread: 2 Guest(s)