GO2cam Javascript API
GO2SNesting Class Reference

Class for nesting computation The purpose of this class is to compute placement of several parts into a sheet. More...

Inherits QObject.

Public Member Functions

 GO2SNesting ()
 
GO2SEnum::GO2SError AddPart (GO2SGeometry geom, GO2SEnum::GO2SNestingOrientation orientation, Number nbParts, Number part_dist)
 
GO2SEnum::GO2SError AddSheet (GO2SGeometry sheet, Number border_dist)
 
Array< GO2SGeometryApply ()
 
void Compute (Number time=5.0)
 
Number GetNbPartsNested (GO2SGeometry solid, Boolean sym)
 

Detailed Description

Class for nesting computation The purpose of this class is to compute placement of several parts into a sheet.

// 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, 1) // keep 1mm free border
// 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, GO2SNestingOrientation.Free, 12, 1)
// create a mesh shape to be nested
let mesh = GO2SMeshCreate.Cuboid(new GO2SXYZ(), new GO2SXYZ(40, 0, 0), new GO2SXYZ(10, 60, 0), 10)
nesting.AddPart(mesh, GO2SNestingOrientation.Free, 8, 1)
// create a wireframe shape to be nested
let ellipse = GO2SEllipseCreate.From3Points(new GO2SXYZ(), new GO2SXYZ(20, 0, 0), new GO2SXYZ(0, 10, 0))
nesting.AddPart(ellipse, GO2SNestingOrientation.Free, 8, 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, GO2SNestingOrientation.Free, 6, 1)
nesting.Compute()
nesting.Apply()
solid.Delete()
mesh.Delete()
ellipse.Delete()
ply.Delete()
profile.Delete()
GO2SInteract.UpdateGeometry()
GO2SInteract.Redraw(true)
\image html nesting.png
Helper class to create ellipse.
Definition GO2SEllipse.hpp:40
Class to manage interactivity with GO2cam.
Definition GO2SInteract.hpp:15
Helper class to create Mesh.
Definition GO2SMesh.hpp:178
GO2SEnum::GO2SError AddSheet(GO2SGeometry sheet, Number border_dist)
void Compute(Number time=5.0)
GO2SEnum::GO2SError AddPart(GO2SGeometry geom, GO2SEnum::GO2SNestingOrientation orientation, Number nbParts, Number part_dist)
Array< GO2SGeometry > Apply()
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:251
Creation of a coordinate reference.
Definition GO2SXYZ.hpp:89
Warning
this class needs a specific license to be used
Version
2026

Constructor & Destructor Documentation

◆ GO2SNesting()

GO2SNesting::GO2SNesting ( )

Default constructor

Version
2026

Member Function Documentation

◆ AddPart()

GO2SEnum::GO2SError GO2SNesting::AddPart ( GO2SGeometry geom,
GO2SEnum::GO2SNestingOrientation orientation,
Number nbParts,
Number part_dist )

Add a part to be nested in the sheet.

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]orientationOrientation constraint for the nesting
[in]nbPartsNumber of parts to be nested
[in]part_distDistance between parts

◆ AddSheet()

GO2SEnum::GO2SError GO2SNesting::AddSheet ( GO2SGeometry sheet,
Number border_dist )

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
Returns
GO2SError.success (0) if successful, see GO2SError otherwise
Version
2026
Parameters
[in]sheetgeometry representing the sheet
[in]border_distDistance between the sheet border and the parts

◆ Apply()

Array< GO2SGeometry > GO2SNesting::Apply ( )

Apply the computed positioning of the parts

Returns
All the nested geometries

◆ Compute()

void GO2SNesting::Compute ( Number time = 5.0)

Compute the nesting solution

Version
2026
Parameters
[in]timeMaximum time in seconds used to optimize the solution

◆ GetNbPartsNested()

Number GO2SNesting::GetNbPartsNested ( GO2SGeometry solid,
Boolean sym )

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
[in]symIndicates whether to give the number of symmetrical