GO2cam Javascript API
GO2SNesting Class Reference

Class for nesting computation. More...

Inherits QObject.

Public Member Functions

 GO2SNesting ()
 
GO2SEnum::GO2SError AddPart (GO2SGeometry geom, Number part_dist, Number angleStep=10.0)
 
GO2SEnum::GO2SError AddSheet (GO2SGeometry sheet)
 
Array< GO2SGeometry > Apply ()
 
void Compute ()
 
Number GetNbPartsNested (GO2SGeometry solid)
 
void SetPlacement (Number placement)
 
void SetTimeLimit (Number seconds)
 

Detailed Description

Class for nesting computation.

The purpose of this class is to compute placement of several parts into a sheet. It uses GO2cam internal nesting engine and needs no specific license.

// nesting object
let nesting = new GO2SNesting()
// add a rectangle as nesting sheet
let sheet = new GO2SRectangle(new GO2SXYZ, new GO2SXYZ(300, 200, 0))
sheet.SetColor(0x0000FF)
nesting.AddSheet(sheet)
// create a solid shape to be nested
let solid = GO2SSolidCreate.Cuboid(new GO2SXYZ(), new GO2SXYZ(30, 0, 0), new GO2SXYZ(20, 50, 0), 10)
nesting.AddPart(solid, 1)
// create a profile shape to be nested
let ply = GO2SPolygonCreate.From2Points(new GO2SXYZ(), new GO2SXYZ(25, 0, 0), 8, true)
let profile = GO2SProfileCreate.FromMultiGeom(ply)
nesting.AddPart(profile, 1)
nesting.Compute()
nesting.Apply()
solid.Delete()
ply.Delete()
profile.Delete()
GO2SInteract.UpdateGeometry()
GO2SInteract.Redraw(true)
Class to manage interactivity with GO2cam.
Definition GO2SInteract.hpp:10
GO2SEnum::GO2SError AddPart(GO2SGeometry geom, Number part_dist, Number angleStep=10.0)
Array< GO2SGeometry > Apply()
GO2SEnum::GO2SError AddSheet(GO2SGeometry sheet)
void Compute()
Helper class to create polygons.
Definition GO2SPolygon.hpp:58
Helper class to create profiles.
Definition GO2SProfile.hpp:45
Rectangle object.
Definition GO2SRectangle.hpp:8
Helper class to create solid.
Definition GO2SSolid.hpp:265
Creation of a coordinate reference.
Definition GO2SXYZ.hpp:93
Remarks
this computation engine handles a single sheet and nests one copy of each added part. Orientation is optimized automatically.
Version
2026

Constructor & Destructor Documentation

◆ GO2SNesting()

GO2SNesting::GO2SNesting ( )

Default constructor

Version
2026

Member Function Documentation

◆ AddPart()

GO2SEnum::GO2SError GO2SNesting::AddPart ( GO2SGeometry geom,
Number part_dist,
Number angleStep = 10.0 )

Add a part to be nested in the sheet. A single copy of the part is nested.

Remarks
wireframe geometry must be closed, planar (Z direction). For volume geometry, silhouette in Z direction will be considered
Returns
GO2SError.success (0) if successful, see GO2SError otherwise
Version
2026
Parameters
[in]geomGeometry object to be nested
[in]part_distDistance between parts
[in]angleStepAngular step in degrees to search the best orientation (<= 0 means no rotation)

◆ AddSheet()

GO2SEnum::GO2SError GO2SNesting::AddSheet ( GO2SGeometry sheet)

Create a nesting sheet from a geometry.

Remarks
wireframe geometry must be closed, planar (Z direction). For volume geometry, silhouette in Z direction will be considered
only a single sheet is supported: the first sheet added is used
Returns
GO2SError.success (0) if successful, see GO2SError otherwise
Version
2026
Parameters
[in]sheetgeometry representing the sheet

◆ Apply()

Array< GO2SGeometry > GO2SNesting::Apply ( )

Apply the computed positioning of the parts

Returns
All the nested geometries

◆ Compute()

void GO2SNesting::Compute ( )

Compute the nesting solution

Version
2026

◆ GetNbPartsNested()

Number GO2SNesting::GetNbPartsNested ( GO2SGeometry solid)

Get the number of parts successfully nested from a given geometry.

Returns
Number of nested parts if successful
Version
2026
Parameters
[in]solidGeometry object used for nesting

◆ SetPlacement()

void GO2SNesting::SetPlacement ( Number placement)

Set the side of the sheet towards which the parts are pushed, to keep a large free area elsewhere

Remarks
0: bottom left (default), 1: bottom right, 2: top left, 3: top right, 4: left, 5: right, 6: bottom, 7: top
Version
2026
Parameters
[in]placementpreferred placement (0 to 7)

◆ SetTimeLimit()

void GO2SNesting::SetTimeLimit ( Number seconds)

Set the maximum computation time of Compute() (default: 10 seconds)

Version
2026
Parameters
[in]secondsmaximum computation time in seconds (> 0)