Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
projets:laserbox-parametrique:accueil [2015/08/23 11:31] resonance [Titre du projet] |
projets:laserbox-parametrique:accueil [2016/04/27 12:20] (Version actuelle) resonance [Laserbox paramétrique] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Laserbox paramétrique ====== | ====== Laserbox paramétrique ====== | ||
* Porteur du projet : [[participants: | * Porteur du projet : [[participants: | ||
- | * Date : 20/08/2015 | + | * Date : 21/08/2015 |
* Licence : libre ! | * Licence : libre ! | ||
- | * Contexte : [[projets: | + | * Contexte : recherche pour brutbox |
* Fichiers : {{: | * Fichiers : {{: | ||
* Lien : Depuis http:// | * Lien : Depuis http:// | ||
+ | |||
===== Description ===== | ===== Description ===== | ||
{{ : | {{ : | ||
- | Essai de boite laser en CP pour les capteurs de la brutbox avec de jolies arrondies. | + | De passage au [[http:// |
- | Le fichier .ps est parametrique, en l' | + | Essai de boite laser en CP pour les capteurs de la brutbox avec de jolies arrondies.\\ |
+ | {{: | ||
* [[http:// | * [[http:// | ||
+ | |||
+ | {{ : | ||
+ | ==== Le Code ==== | ||
+ | |||
+ | < | ||
+ | %!PS | ||
+ | % | ||
+ | % flexbox.ps | ||
+ | % A 3 piece flexible box that can be laser cut from semi-rigid materials | ||
+ | % | ||
+ | % Edited my Tom Speller (@Seithing) | ||
+ | % | ||
+ | % V1.3 by Tom | ||
+ | % change log and updates on thingiverse | ||
+ | % | ||
+ | % Originaly | ||
+ | % by Brian Dahlem | ||
+ | % based on the simple box - type 2 by FdS - http:// | ||
+ | % using the sninge technique from snijlab - http:// | ||
+ | |||
+ | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
+ | % The following lines define basic information about your box, change as necessary | ||
+ | |||
+ | % Define basic measurement units -- don't change put the desiered unit in the unit var below | ||
+ | /inch 72 def | ||
+ | /cm 28.3465 def | ||
+ | /mm 2.83465 def | ||
+ | |||
+ | /unit mm def %selects what unit is used in the following vars + the text (selection about) | ||
+ | |||
+ | % Define box parameters -- This is the size of the box you want | ||
+ | /boxlength 60 unit mul def % long dimension of flat side of the box | ||
+ | /boxwidth 60 unit mul def % dimension across the hinge | ||
+ | /boxheight 60 unit mul def % short dimension across flat side of the box | ||
+ | / | ||
+ | / | ||
+ | /tabwidth materialthickness 2 mul def % suggested width of tabs in the joints | ||
+ | |||
+ | /fingerTab 0 unit mul def %finger hole for opening box, set to 0 for none. 12 is a good size for a finger | ||
+ | / | ||
+ | |||
+ | % Define the laser cutter page size A3 420x290mm | ||
+ | /pagewidth 420 unit mul def | ||
+ | /pageheight 290 unit mul def | ||
+ | |||
+ | |||
+ | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
+ | % Here down is the code that makes your pretty little box, change only if you dare. | ||
+ | % | ||
+ | % Warning... it gets ugly ahead | ||
+ | |||
+ | % setup the page | ||
+ | << /PageSize [pagewidth pageheight] >> setpagedevice % Set the pagesize, only sometimes works? | ||
+ | |||
+ | /border materialthickness def % Move away from the edge of the material, for that nice scorched edges goodness | ||
+ | 0 pageheight translate | ||
+ | 1 -1 scale | ||
+ | border border translate | ||
+ | |||
+ | % 0 - 1 for colour | ||
+ | |||
+ | % outside cut colour | ||
+ | /outR 0 def | ||
+ | /outG 0 def | ||
+ | /outB 0 def | ||
+ | |||
+ | % hinge cut colour due to the way my laser software works it tries to cut the outside before the inside. | ||
+ | % making it different colours mean I can set the cut manauly | ||
+ | /hingeR 1 def | ||
+ | /hingeG 0 def | ||
+ | /hingeB 0 def | ||
+ | |||
+ | 0.01 setlinewidth | ||
+ | outR outG outB setrgbcolor | ||
+ | |||
+ | % draw a rectangle | ||
+ | /box { % Draw a box with a given width and height from the current location | ||
+ | /height exch def | ||
+ | /width exch def | ||
+ | |||
+ | 0 height rlineto | ||
+ | width 0 rlineto | ||
+ | 0 height neg rlineto | ||
+ | width neg 0 rlineto | ||
+ | } def | ||
+ | |||
+ | % Some basics... | ||
+ | /min { 2 copy gt { exch } if pop } bind def | ||
+ | /max { 2 copy lt { exch } if pop } bind def | ||
+ | /pi 3.14159 def | ||
+ | |||
+ | % Define some features of the box | ||
+ | / | ||
+ | /tablen materialthickness def % How tall to make tabs | ||
+ | /toplen boxlength cornerradius 2 mul sub def % How long is the top / bottom side | ||
+ | / | ||
+ | /frontwidth boxlength tablen 2 mul sub def % How wide is the front face, minus tabs | ||
+ | /sideheight boxheight cornerradius 2 mul sub def % How tall are the sides, not counting hinges | ||
+ | /hingelen innerradius 2 div pi mul def % How long is a flattened out hinge (the circumference of 1/4 inner radius) | ||
+ | |||
+ | /breaklen materialthickness 2 div def % How long should breaks in the hinge lines be | ||
+ | / | ||
+ | /winglen toplen 2 div hingelen 2 mul sideheight add add def % How long a wing of the drawing is when drawn out flat | ||
+ | |||
+ | %for the tabs at the base (between the wings). | ||
+ | / | ||
+ | / | ||
+ | |||
+ | %finger tab maths | ||
+ | %see if fingerTab is greater then 0. if so add hole | ||
+ | fingerTab 0 gt { | ||
+ | /x fingerTab fingerinset sub def %work out how far form the edge of the circle the sagitta is | ||
+ | /y 2 2 fingerTab mul x mul x 2 exp sub sqrt mul def % the maths that calulates the offset, some how works. | ||
+ | / | ||
+ | /lineloss fingerTab y 2 div sub def % add a little more to the line to compensate for what was lost in moving the circle | ||
+ | } { | ||
+ | %if finger tab set to 0 set all to 0. don't add hole | ||
+ | /x 0 def | ||
+ | /y 0 def | ||
+ | / | ||
+ | /lineloss 0 def | ||
+ | / | ||
+ | } ifelse | ||
+ | |||
+ | % Draw 1/2 of the top, one " | ||
+ | /drawflap { | ||
+ | newpath | ||
+ | toplen 2 div 0 moveto | ||
+ | tabwidth 2 mul 0 lineto | ||
+ | 0 tablen rlineto | ||
+ | tabwidth neg 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabwidth neg 0 rlineto | ||
+ | | ||
+ | fingerinset neg boxwidth 2 div fingerTab 270 changeangle add 90 changeangle sub arc % draw arc for finger hole | ||
+ | | ||
+ | 0 boxwidth 2 div fingerTab sub lineloss add rlineto | ||
+ | | ||
+ | tabwidth 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabwidth 0 rlineto | ||
+ | 0 tablen rlineto | ||
+ | toplen 2 div boxwidth lineto | ||
+ | stroke | ||
+ | } def | ||
+ | |||
+ | % Draw a hinge line going all the way across the hinge | ||
+ | /longline { | ||
+ | /linelen boxwidth numhingelines breaklen 2 mul sub numhingelines div def % How long is a segment in a long line? | ||
+ | |||
+ | % Draw 1/2 a line to start | ||
+ | 0 linelen 2 div rlineto | ||
+ | |||
+ | % Fill in the space with full lines | ||
+ | 2 1 numhingelines { | ||
+ | 0 breaklen 2 mul rmoveto | ||
+ | 0 linelen rlineto | ||
+ | } for | ||
+ | |||
+ | % Draw the last half line to even it out | ||
+ | 0 breaklen 2 mul rmoveto | ||
+ | 0 linelen 2 div rlineto | ||
+ | |||
+ | } def | ||
+ | |||
+ | % Draw a hinge line with end caps | ||
+ | /shortline { | ||
+ | /linelen boxwidth numhingelines 1 sub breaklen 2 mul mul breaklen 2 mul add sub numhingelines div def | ||
+ | |||
+ | % Skip a break then fill the space with evenly spaced lines | ||
+ | 0 breaklen neg rmoveto | ||
+ | 1 1 numhingelines { | ||
+ | 0 linelen neg rlineto | ||
+ | 0 breaklen 2 mul neg rmoveto | ||
+ | } for | ||
+ | } def | ||
+ | |||
+ | % Draw a flattened out hinge - alternating short and long lines | ||
+ | /drawhinge { | ||
+ | /minwidth materialthickness def % the minimum width for a hinge section (2 lines) | ||
+ | /numbars hingelen minwidth div floor def % the number of hinge sections per hinge | ||
+ | /barwidth hingelen numbars div def % the actual width of a hinge section | ||
+ | | ||
+ | hingeR hingeG hingeB setrgbcolor | ||
+ | |||
+ | newpath | ||
+ | 0 boxwidth moveto | ||
+ | shortline | ||
+ | |||
+ | 1 1 numbars { % for each of the sections in the hinge | ||
+ | /i exch def | ||
+ | i barwidth mul barwidth 2 div sub 0 moveto | ||
+ | longline | ||
+ | i barwidth mul boxwidth moveto | ||
+ | shortline | ||
+ | } for | ||
+ | stroke | ||
+ | outR outG outB setrgbcolor | ||
+ | newpath | ||
+ | 0 0 moveto | ||
+ | hingelen 0 rlineto | ||
+ | 0 boxwidth rmoveto | ||
+ | hingelen neg 0 rlineto | ||
+ | stroke | ||
+ | } def | ||
+ | |||
+ | %draw tabs for bottom of the sides of box (ones between the wings) | ||
+ | / | ||
+ | newpath | ||
+ | 0 0 moveto | ||
+ | tabsizebase 0 rlineto | ||
+ | 1 1 numtabsbase 2 div { | ||
+ | 0 tablen rlineto | ||
+ | tabsizebase 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabsizebase 0 rlineto | ||
+ | } for | ||
+ | stroke | ||
+ | } def | ||
+ | |||
+ | % Draw an edge of the box, using tabs to connect to the front/back if the side is large enough | ||
+ | / | ||
+ | /numtabs sideheight tabwidth div 2 div ceiling 2 mul 1 add def % how many tabs to connect to front | ||
+ | /tabsize sideheight numtabs div def % how big should the tabs be | ||
+ | |||
+ | newpath | ||
+ | 0 0 moveto | ||
+ | tabsize 0 rlineto | ||
+ | 1 1 numtabs 2 div { % if there are more tabs | ||
+ | 0 tablen rlineto | ||
+ | tabsize 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabsize 0 rlineto | ||
+ | } for | ||
+ | stroke | ||
+ | } def | ||
+ | |||
+ | % Draw an end of the box horizontally | ||
+ | /drawend { | ||
+ | gsave | ||
+ | drawendedge | ||
+ | sideheight boxwidth translate | ||
+ | -1 -1 scale | ||
+ | drawendedge | ||
+ | grestore | ||
+ | } def | ||
+ | |||
+ | % Draw a " | ||
+ | /drawwing { | ||
+ | % Draw the two hinges before drawing the outline of the wing - use this order for laser cutting betterment | ||
+ | gsave | ||
+ | toplen 2 div 0 translate | ||
+ | drawhinge | ||
+ | hingelen sideheight add 0 translate % Skip over the end/side | ||
+ | drawhinge | ||
+ | grestore | ||
+ | gsave % Go back to the beginning of the wing | ||
+ | drawflap | ||
+ | toplen 2 div hingelen add 0 translate % skip over the hinge | ||
+ | gsave %draw only the bottom edge as the box sides do the other side | ||
+ | sideheight boxwidth translate | ||
+ | -1 -1 scale | ||
+ | drawendedge | ||
+ | grestore | ||
+ | grestore | ||
+ | } def | ||
+ | |||
+ | |||
+ | % Draw the front/back side of the box | ||
+ | /drawfront { | ||
+ | |||
+ | gsave | ||
+ | tablen tablen translate | ||
+ | |||
+ | % Connect the front side to the bottom with tabs | ||
+ | newpath | ||
+ | innerradius frontheight moveto | ||
+ | tabsizebase 0 rlineto | ||
+ | 1 1 numtabsbase 2 div { | ||
+ | 0 tablen rlineto | ||
+ | tabsizebase 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabsizebase 0 rlineto | ||
+ | } for | ||
+ | frontwidth innerradius sub frontheight moveto | ||
+ | frontwidth innerradius sub frontheight innerradius sub innerradius 90 0 arcn | ||
+ | stroke | ||
+ | |||
+ | % draw a corner radius then the side connecting one end to the front | ||
+ | gsave | ||
+ | frontwidth frontheight innerradius sub translate % move to the bottom of the right edge | ||
+ | 270 rotate | ||
+ | drawendedge | ||
+ | grestore | ||
+ | |||
+ | % draw another corner radius, the side connecting the top flaps to the front, and another corner | ||
+ | newpath | ||
+ | frontwidth innerradius sub innerradius innerradius 0 270 arcn % draw the top right corner | ||
+ | toplen 2 div neg tabwidth 2 mul add 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabwidth neg 0 rlineto | ||
+ | 0 tablen rlineto | ||
+ | tabwidth 2 mul neg 0 rlineto | ||
+ | 0 tablen neg rlineto | ||
+ | tabwidth neg 0 rlineto | ||
+ | 0 tablen rlineto | ||
+ | innerradius 0 lineto | ||
+ | innerradius innerradius innerradius 270 180 arcn % with a top left corner | ||
+ | stroke | ||
+ | |||
+ | % draw the last side of the front, connecting the front to another end | ||
+ | gsave | ||
+ | 0 innerradius translate | ||
+ | 90 rotate | ||
+ | drawendedge | ||
+ | grestore | ||
+ | |||
+ | % finish off the front with the last corner radius | ||
+ | newpath | ||
+ | innerradius frontheight innerradius sub innerradius 180 90 arcn % draw the bottom left corner to finish this side | ||
+ | stroke | ||
+ | grestore | ||
+ | } def | ||
+ | |||
+ | % Go ahead and actually draw the box | ||
+ | |||
+ | % Draw the two wings - the top flaps and ends | ||
+ | gsave | ||
+ | 0 boxlength tablen sub translate | ||
+ | drawwing | ||
+ | gsave | ||
+ | winglen 0 translate %move to wing middle | ||
+ | drawbasetabs %draw tabs between wings | ||
+ | 0 boxwidth translate | ||
+ | 1 -1 scale %mirror horisontal | ||
+ | drawbasetabs %draw bottom tabs fo wings | ||
+ | grestore | ||
+ | 2 toplen mul sideheight 2 mul add hingelen 4 mul add 0 translate | ||
+ | -1 1 scale | ||
+ | drawwing | ||
+ | grestore | ||
+ | |||
+ | % Draw the front and back of the box, connected up to the wings this also makes the bottom | ||
+ | gsave | ||
+ | | ||
+ | toplen 2 div hingelen add cornerradius sub boxlength translate | ||
+ | -90 rotate | ||
+ | drawfront | ||
+ | |||
+ | 0 boxheight hingelen 2 mul add sideheight add toplen add translate | ||
+ | 1 -1 scale %scale (mirror) to save having to work with vertical offset | ||
+ | drawfront | ||
+ | grestore | ||
+ | |||
+ | % We're done here, lets go home. | ||
+ | showpage | ||
+ | %%EOF | ||
+ | </ | ||
===== Matériaux ===== | ===== Matériaux ===== | ||
* CP 3mmm | * CP 3mmm | ||
Ligne 19: | Ligne 379: | ||
- | Les mots clés (tags) représentant votre travail | + | |
{{tag> | {{tag> |