Scripting Shapes

Boxshot features many built–in shapes, each having its own API for configuring its properties. You use this API when editing shapes in the user interface, but the same can be done with Javascript. Click the links below to jump to the shape you need:


 

Binders

Here’s how to create binders:

var m = scene.root.addMesh("angle-d", "generator.Binders.AngleD");
var g = m.generator;
g.width = 10;
g.height = 5;
g.coverAngle = 10;
g.fitToImages();

Other binders are created this way (all the other parameters are the same):

var m1 = scene.root.addMesh("comb", "generator.Binders.Comb");
var m2 = scene.root.addMesh("wire", "generator.Binders.Wire");
var m3 = scene.root.addMesh("coil", "generator.Binders.Coil");

m1.generator.thickness = 5;


 

Blu-ray Box

The Blu-ray Box shape has fixed dimensions and can’t be resized. Please use the following texture dimensions:

Here’s how you can create a Blu-ray Box object and adjust its properties:

var m = scene.root.addMesh("blu-ray", "generator.DiscBox.BluRay");
var g = m.generator;
g.coverAngle = 0.5;
g.showDisc = false;
g.showCover = false;
g.showInsert = false;
g.solidCoverImage = false; // do not wrap cover image


 

Books

Here’s how to create a hard cover book shape in Boxshot scripting:

var m = scene.root.addMesh("book", "generator.book2.HardCover");
// var m = scene.root.addMesh("book", "generator.book2.HardCoverSpread"); // use this one for hard cover spread
var g = m.generator;

// dimensions
g.width = 10; // cm
g.height = 20; // cm
g.thickness = 1; // cm
g.fitToImages(); // or use this
g.wrapCover = true;

// presets
// for standing book use one of: closed, open-a-bit-front, open-a-bit
// for spread use one of: spread-middle, spread-first-page, spread-beginning, spread-end
// g.preset = "closed"; 

// cover
g.coverThickness = 0.2;
g.coverRadius = 1;
g.jointWidth = 0.1;
g.jointDepth = 0.2;
g.wrappedArtwork = 0.001;

// dust jacket
g.showDustJacket = true;
g.dustJacketWidth = 100;
g.dustJacketThickness = 0.01;
g.wrapArtworkToDustJacketEdge = true;

// leaves
g.leavesCoverGap = 0;
g.leavesPerCm = 100;
g.complexLeaves = true;
g.leavesOffsetH = 0.1;
g.leavesOffsetV = 0.2;
g.leavesLengthAdjustment = 0;

// headband
g.headbandAdjustment = 0;
g.headbandThickness = 0.1;
g.headbandHeight = 1;
g.headbandEdgeRadius = 0.1;
g.headbandPadding = 0;

// other
g.lod = 1.0;

Here’s a similar script example for paperback book shape:

var m = scene.root.addMesh("book", "generator.book2.Paperback");
// var m = scene.root.addMesh("book", "generator.book2.PaperbackSpread"); // use this one for paperback spread
var g = m.generator;

// paperback dimensions
g.width = 10;
g.height = 20;
g.thickness = 1;
g.fitToImages();
g.wrapCover = true;

// preset
// for standing paperback use: closed, open-a-bit-front, open-a-bit, open-flat-sides, open-middle
// for paperback spreads use: spread-middle, spread-first-page, spread-beginning, spread-end
// g.preset = "closed";

// cover
g.coverThickness = 0.1;
g.wrapArtworkToCoverEdge = true;

// leaves
g.leavesPerCm = 100;
g.complexLeaves = true;
g.leavesOffsetH = 0.1;
g.leavesOffsetV = 0.01;
g.leavesAdjustment = 0;

// other
g.lod = 1.0;

Finally, the sample script for magazines:

var m = scene.root.addMesh("magazine", "generator.book2.Magazine");
// var m = scene.root.addMesh("magazine", "generator.book2.MagazineSpread"); // use this one for magazine spread
var g = m.generator;

// magazine dimensions
g.width = 10;
g.height = 15;
g.thickness = 0.5;
g.fitToImages();
g.wrapCover = true;

// preset
// for standing magazine use: closed, open-a-bit-front
// for magazine spreads use: spread-middle, spread-beginning, spread-end
// g.preset = "closed";

// cover
g.coverThickness = 0.2;
g.wrapArtworkToCoverEdge = true;

// leaves
g.leavesPerCm = 100;
g.complexLeaves = true;
g.leavesOffsetH = 0.1;
g.leavesOffsetV = 0.2;

// other
g.lod = 1.0;


 

Booklet On The Floor

Here is a sample script that creates a booklet on the floor object:

var m = scene.root.addMesh("booklet", "generator.Stationery.BookletOnTheFloor");
var g = m.generator;
g.width = 10;
g.height = 5;
g.extrude = 0.1;
g.threePages = true;
g.flipped = false;

Here’s how to load image and resize the shape automatically:

var m = scene.root.addMesh("booklet", "generator.Stationery.BookletOnTheFloor");
var g = m.generator;
m.material("Front").diffuseSlot.filename = "/path/to/image.jpg";
g.fitToImages();


 

Booklet

Here is a sample script that creates a booklet object:

var m = scene.root.addMesh("booklet", "generator.Stationery.Booklet");
var g = m.generator;
g.width = 10;
g.height = 5;
g.frames = 3;
g.angle1 = -60;
g.angle2 = -60;

Angles are controlled by variables angle1 - angle8.

Here’s how to load image and resize the shape automatically:

var m = scene.root.addMesh("booklet", "generator.Stationery.Booklet");
var g = m.generator;
m.material("Front").diffuseSlot.filename = "/path/to/image.jpg";
g.fitToImages();


 

Canvas

Here’s how you can create a canvas object using script:

var m = scene.root.addMesh("canvas", "generator.canvas.simple");
var g = m.generator;
g.width = 50;
g.height = 20;
g.thickness = 2;
g.radius = 0.1;

Here’s how to automatically fit to image:

var m = scene.root.addMesh("canvas", "generator.canvas.simple");
var g = m.generator;
m.material("Image").diffuseSlot.filename = "/path/to/image.jpg";
g.fitToImages();


 

Caps

Here is a sample script that creates a cap object:

var m = scene.root.addMesh("cap", "generator.pharma.cap");
var g = m.generator;
g.neckDiameter = 10;
g.capHeight = 20;
g.capType = "beer"; // use the same values you see in the user interface


 

Coffee Cup

Here’s how you can create a coffee cup object using script:

var m = scene.root.addMesh("tall", "generator.mugs.CoffeeCup");
var g = m.generator;
g.diameter = 9;
g.empty = true;
g.showLid = false;
g.height = 13;

Here’s how to automatically fit to image:

var m = scene.root.addMesh("custom coffee", "generator.mugs.CoffeeCup");
var g = m.generator;
m.material("Body").diffuseSlot.filename = "/path/to/image.jpg";
g.fitToImages();


 

Compact Disc

Here’s how you can create a Compact Disc object:

var m = scene.root.addMesh("disc", "generator.DiscBox.Disc");


 

Cylinder

Here is a sample script that creates a cylinder object:

var m = scene.root.addMesh("cylinder", "generator.simple.cylinder");
var g = m.generator;
g.height = 10;
g.radius = 5;
g.segments = 16;
g.topCurve = 0.3;
g.bottomCurve = 0;
g.fitToImages();


 

Devices

Here’s how to create device shapes in Boxshot using Javascript:

var m1 = scene.root.addMesh("Mobile Phone", "generator.Devices.Mobile");
var m2 = scene.root.addMesh("Tablet", "generator.Devices.Tablet");
var m3 = scene.root.addMesh("Monitor", "generator.Devices.Monitor");


 

Digipak DVD Box

The Digipak shapes have fixed dimensions and can’t be resized. Please use the following texture dimensions for DVD box:

And these for CD Box:

Here’s how you can create a Digipak DVD Box object and adjust its properties:

var m = scene.root.addMesh("digipak dvd", "generator.DiscBox.DigipakDVD");
var g = m.generator;
g.coverAngle = 0.5;
g.showDisc = false;
g.solidCoverImage = true; // wrap cover image

To create a Digipak CD Box, use the following code:

var m = scene.root.addMesh("digipak cd", "generator.DiscBox.DigipakCD");
var g = m.generator;
g.coverAngle = 0.5;
g.showDisc = false;
g.solidCoverImage = false; // do not wrap cover image


 

Extrude

Here’s how you can create and setup extruded object using Boxshot scripting:

var m = scene.root.addMesh("extruded", "generator.extrude");
var g = m.generator;
g.thickness = 3; // 3cm deep
g.smoothness = 0.5; // 50%
g.upz = true; // 'true' for look up, 'false' for look front
g.bevelSize = 0.2; // cm
g.bevelSteps = 0;
g.bevelSmooth = false;

Here’s how to load a custom SVG file to Extrude object:

g.loadSVG("/path/to/file.svg");


 

Flexible Bags

Here’s how to create a gusseted bag from script:

var m = scene.root.addMesh("gusseted", "generator.flexible.GussetedBag");
var g = m.generator;
g.width = 15;
g.height = 20;
g.thickness = 0.5;
g.topSeal = 1;
g.bottomSeal = 1;
g.backSeal = 2;
g.flipBackSeal = false;
g.centerBackSeal = false;
g.asymmetry = 0.2;
g.deformation = 0.1;
g.volume = 0.4;
g.seed = 12345;
g.fitToImages();

Here’s the same for sachet bag:

var m = scene.root.addMesh("sachet", "generator.flexible.SachetBag");
var g = m.generator;
g.width = 10;
g.height = 15;
g.topSeal = 1;
g.bottomSeal = 1;
g.sideSeal = 1;
g.asymmetry = 0.2;
g.deformation = 0;
g.volume = 0.6;
g.seed = 111;
g.fitToImages();

A pillow bag:

var m = scene.root.addMesh("pillow", "generator.flexible.PillowBag");
var g = m.generator;
g.width = 10;
g.height = 15;
g.topSeal = 1;
g.bottomSeal = 1;
g.backSeal = 2;
g.flipBackSeal = false;
g.centerBackSeal = true;
g.asymmetry = 0.2;
g.deformation = 0.3;
g.volume = 0.1;
g.seed = 4432;
g.fitToImages();

Finally, a doypack bag:

var m = scene.root.addMesh("doy", "generator.flexible.Doypack");
var g = m.generator;
g.width = 10;
g.height = 15;
g.topSeal = 1;
g.sideSeal = 1;
g.asymmetry = 0.2;
g.deformation = 0.3;
g.volume = 0.4;
g.seed = 4432;
g.fitToImages();


 

Image Stacks

Here’s how to create a simple stack:

var m = scene.root.addMesh("stack1", "generator.Images.Stack");
var g = m.generator;
g.width = 10;
g.length = 5;
g.thickness = 0.03;
g.corner = 0.02;
g.border = 0;
g.space = 0.01;
g.disorder = 0.2;
g.twist = 0.1;
g.numberOfImages = 20;
m.material("Image").diffuseSlot.filename = "/path/to/image.png";
g.fitToImages();

The “Stack + 1” shape can be created the same way, here’s the difference:

var m = scene.root.addMesh("stack2", "generator.Images.StackPlus1");
var g = m.generator;
// the same initialization
g.imageDistance = 0.5;

Finally the Fan stack is created this way:

var m = scene.root.addMesh("stack3", "generator.Images.Fan");
var g = m.generator;
// the same initialization
g.spread = 0.5;


 

Image

Here is a sample script that creates an image object:

var m = scene.root.addMesh("image", "generator.Images.Image");
var g = m.generator;
g.width = 10;
g.length = 5;
g.thickness = 0.03;
g.corner = 0.02;
g.border = 0;
g.bend = 0.5;
m.material("Image").diffuseSlot.filename = "/path/to/image.png";
g.fitToImages();


 

Labels

Here’s how to make a conical label using Boxshot scripting:

var m = scene.root.addMesh("label", "generator.pos.ConicalLabel");
var g = m.generator;
g.width = 20;
g.height = 10;
g.topDiameter = 10;
g.bottomDiameter = 9;
g.segments = 64;
g.offsetX = 0;
g.offsetY = 0;

Here is a sample script that creates a straight label shape:

var m = scene.root.addMesh("label", "generator.pos.Label");
var g = m.generator;
g.width = 20;
g.height = 10;
g.diameter = 10;
g.segments = 64;
g.scale = 1;
g.fitToImages(); 


 

Lathe

You can almost everything mentioned above using scripts.

var m = scene.root.addMesh("lathe", "generator.lathe");
var g = m.generator;

g.segments = 64;
g.smoothness = 0.8;

g.topCap = true;
g.bottomCap = false;
g.automaticAlignment = false;
g.generateBackfaces = false;
g.flipNormals = true;
g.flipTextureMapping = true;
g.hardVerticalEdges = false;
g.hardHorizontalEdges = true;

g.startAngle = 10;
g.endAngle = 90;
g.caps = true;

Here’s how you can load the SVG file to a Lathe object:

g.loadSVG("/path/to/file.svg");


 

Loft

Loft objects are too complex for scripting, so all you can control is the left of details:

var m = scene.root.addMesh("loft", "generator.loft");
var g = m.generator;
g.lod = 0.8;

The rest is better done using loft editor window.


 

Pallet

Here’s how to create a pallet shape using Boxshot scripting:

var m = scene.root.addMesh("bucket", "generator.pos.Pallet");
var g = m.generator;

g.palletType = "eur6"; // use: eur, eur2, eur3, eur6, us_40x48, us_44x44, us_48x40


 

Paper Bag

Here is a sample script that creates a paper bag object:

var m = scene.root.addMesh("paper bag", "generator.Bags.Paper");
var g = m.generator;
g.width = 10;
g.height = 20;
g.thickness = 5;
g.spread = 0.3;
g.bagType = "handles-up"; // use paper-handles, handles-up, handles-down, square-holes, round-holes, no-holes
g.fitToImages();


 

Pharma Bottle

Here’s how to create and setup a pharma bottle shape:

var m = scene.root.addMesh("bottle", "generator.pharma.Bottle");
var g = m.generator;
g.diameter = 10;
g.height = 20;
g.labelHeight = 5;
g.topHeight = 2;
g.showLabel = true;
g.replaceGlassWithLabel = true;
g.showLiquid = true;
g.liquidLevel = 3;

g.capType = "plastic-1";
g.capHeight = 0.7;
g.neckDiameter = 4;

g.neckCurve = 0.2;
g.topCurve = 0.5;
g.bottomCurve = 0.9;

g.fitToImages();


 

Creme Jar

Here’s how to create the “Pharma creme jar” shape:

var m = scene.root.addMesh("creme jar", "generator.pharma.CremeJar");
var g = m.generator;
g.diameter = 10;
g.height = 20;
g.labelHeight = 5;

// or you can fit the shape to images
g.fitToImages();


 

Pharma Pill

Here’s how to create a 3d pharma pill shape using scripting:

var m = scene.root.addMesh("pill", "generator.pharma.Pill");
var g = m.generator;
g.pillType = "Capsule"; // use the same names, as in the user interface


 

Pharma Blister Pack

Here’s how to create a 3d pharma pills shape using scripting:

var m = scene.root.addMesh("blister pack", "generator.pharma.Pills");
var g = m.generator;


g.pillType = "Capsule 35"; // use the same names, as in the user interface
g.rows = 2;
g.columns = 3;
g.randomize = true;
g.seed = 123;

g.pillSize = 1.2;
g.gap = 2.2;
g.rowGap = 2.1;
g.cornerRadius = 0.2;

g.tileFront = true;
g.tileBack = false;
g.bend1 = -1;
g.bend2 = 0.5;

g.fitToImages();


 

Pharma Tube

Here’s how to create a 3d toothpaste tube from script:

var m = scene.root.addMesh("gusseted", "generator.pharma.Tube");
var g = m.generator;

g.length = 15;
g.diameter = 3;
g.bottomLength = 0.7;
g.headHeight = 0.2;
g.volume = 0.7;

g.capType = "flip-top-small-open";
g.capHeight = 1.4;
g.neckDiameter = 0.8;
g.neckLength = 0.3;

g.fitToImages();


 

Plane

Here is a sample script that creates a plane object:

var m = scene.root.addMesh("plane", "generator.simple.plane");
var g = m.generator;
g.width = 10;
g.length = 5;
g.fitToImages();


 

Plastic Bucket

Here’s how to create a plastic bucket using Boxshot scripting:

var m = scene.root.addMesh("bucket", "generator.pos.Bucket");
var g = m.generator;

g.bucketType = "bucket-1"; // use bucket-1, bucket-2 or bucket-3

g.height = 25;
g.topSize = 20;
g.bottomSize = 17;

g.showLabel = true;
g.labelHeight = 10;

g.showLid = true;
g.showLidLabel = true;
g.lidLabelSize = 5;
g.lidLabelAngle = 30;

g.showHandle = true;
g.handleAngle = 90;

g.fitToImages();


 

Plastic DVD Box

The DVD Box shape has fixed dimensions and can’t be resized. Use the following texture dimensions:

Here’s how you can create a Plastic DVD Box object and adjust its properties:

var m = scene.root.addMesh("dvd", "generator.DiscBox.DVD");
var g = m.generator;
g.coverAngle = 0.5;
g.showDisc = false;
g.showCover = false;
g.showInsert = false;
g.solidCoverImage = false; // do not wrap cover image


 

Slim CD Box

The Slim CD Box shape has fixed dimensions and can’t be resized. Use the following texture dimensions:

Here’s how you can create a Slim CD Box object and adjust its properties:

var m = scene.root.addMesh("slim cd", "generator.DiscBox.SlimCD");
var g = m.generator;
g.coverAngle = 0.5;
g.showDisc = false;
g.showTrayCard = false;
g.showInsert = false;
g.solidCoverImage = false; // use separate insert and tray card images


 

Soda Cans

Here is a sample script that creates a can object:

var m = scene.root.addMesh("can-330ml", "generator.cans.BeverageCanStandard330ml");
var g = m.generator;
g.size = 10;
g.height = 20;
g.fitToImages();

To create a 250ml can, use the following command:

var m = scene.root.addMesh("can-250ml", "generator.cans.BeverageCanSlim250ml");


 

Software Boxes

Here’s how to create and control a simple software box:

var m = scene.root.addMesh("Software Box", "generator.Boxes.Box");
var g = m.generator;
g.width = 10;
g.height = 20;
g.length = 2;
g.radius = 0.1;
g.splitInside = true;
g.fitToImages();

Here’s the script for a rounded box:

var m = scene.root.addMesh("Rounded Box", "generator.Boxes.RoundedBox");
var g = m.generator;
g.width = 10;
g.height = 20;
g.length = 2;
g.radiusV1 = 0.8;
g.radiusV2 = 0.7;
g.radiusV3 = 0.6;
g.radiusV4 = 0.5;
g.radiusTop = 0.3;
g.radiusBottom = 0.2;
g.splitInside = true;
g.fitToImages();

Sliding boxes are pretty much the same:

var m = scene.root.addMesh("Sliding Box", "generator.Boxes.SlidingBox");
var g = m.generator;
g.width = 10;
g.height = 20;
g.length = 2;
g.roundCorner = false;
g.innerBox = 0.2;
g.fitToImages();


 

Sphere

Here is a sample script that creates a sphere object:

var m = scene.root.addMesh("sphere", "generator.simple.sphere");
var g = m.generator;
g.radius = 20;
g.lod = 3;
g.solid = false;
t.thickness = 1;


 

Tagged Box

Here’s how to create a tagged box shape using script:

var m = scene.root.addMesh("tagged box", "generator.Boxes.TaggedBox");
var g = m.generator;
g.width = 10;
g.height = 20;
g.length = 2;
g.tagPosition = 0.5;
g.fitToImages();


 

Tea Mug

Here’s how you can create a tea mug object using script:

var m = scene.root.addMesh("my mug", "generator.mugs.TeaMug");
var g = m.generator;
g.diameter = 10;
g.height = 20;
g.empty = true;

Here’s how to automatically fit to image:

var m = scene.root.addMesh("my mug", "generator.mugs.TeaMug");
var g = m.generator;
m.material("Body").diffuseSlot.filename = "/path/to/image.jpg";
g.fitToImages();


 

3D Text

Here’s how you can create and setup a 3D text object using Boxshot scripting:

var m = scene.root.addMesh("3d text", "generator.text3d");
var g = m.generator;
g.text = "hello, world";
g.height = 10; // 10cm tall
g.thickness = 3; // 3cm deep
g.smoothness = 0.5; // 50%
g.upz = true; // 'true' for look up, 'false' for look front
g.font = "Arial";
g.align = "left"; // "left", "center" or "right"
g.bold = true;
g.italic = false;
g.underline = false;
g.bevelSize = 0.2; // cm
g.bevelSteps = 0;
g.bevelSmooth = false;


 

Torus Knot

Here is a sample script that creates a torus knot object:

var m = scene.root.addMesh("torus", "generator.simple.TorusKnot");
var g = m.generator;
g.size = 10;
g.amplitude = 5;
g.thickness = 3;
g.turns1 = 2;
g.turns2 = 3;
g.segments = 256;
g.sides = 32;


 

Torus

Here is a sample script that creates a torus object:

var m = scene.root.addMesh("torus", "generator.simple.Torus");
var g = m.generator;
g.size = 30;
g.thickness = 5;
g.segments = 32;
g.sides = 16;


 

USB Flash Drive

Here’s how to create a USB Flash Drive shape using Boxshot scripting:

var m = scene.root.addMesh("usb", "generator.Devices.USB");
var g = m.generator;

g.deviceType = "screw"; // use: twister, key, mini, wooden, waterproof, slider, screw, classic, ellipse, minitwister, halo, capsule, clip, rotator, card
g.phase = 0.2;
g.showBase = true;
g.showCap = false;
g.showRing = false;


 

Yogurt Pack

Here’s how to create a yogurt pack shape from script:

var m = scene.root.addMesh("pack", "generator.Dairy.YogurtPack");
var g = m.generator;
g.cupsInRow = 2;
g.numberOfRows = 3;

g.topWidth = 11;
g.topLength = 11;
g.topCurve = 0.3;
g.foilBump = 0.1;
g.solidCoverMapping = false;

g.cupWidth = 10;
g.cupLength = 10;
g.cupHeight = 15;
g.labelHeight = 10;
g.cupCurve = 0.8;
g.labelOffset = 0.3;

g.fitToImages();

More Scripting Tutorials