GO2cam Javascript API
GO2SWorkspace Class Reference

Workspace to compute geometries without displaying them. More...

Inherits QObject.

Public Member Functions

 GO2SWorkspace ()
 
GO2SEnum::GO2SError Activate ()
 
GO2SEnum::GO2SError Close ()
 
GO2SGeometry Copy (GO2SGeometry geom)
 
GO2SEnum::GO2SError CopyToolpath (GO2SGeometry geom, GO2SEnum::GO2SToolpathType type, GO2SXYZ dir=nullptr)
 
Boolean IsActive ()
 
Boolean IsMain ()
 
Boolean IsOpen ()
 

Detailed Description

Workspace to compute geometries without displaying them.

A workspace is a separate area where geometries can be created, modified and intersected. Its content is never displayed and is discarded when the workspace is closed, or at the end of the script. Several workspaces can be open at the same time; exactly one of them is active, the Main workspace by default. New geometries are always created in the active workspace.

Remarks
intersections are only computed between geometries of the same workspace: copy a geometry into the workspace with Copy() to intersect with it.
// Create a workspace for computation
let ws = new GO2SWorkspace()
// Do the computation. All entities are still invisible in the 3D scene
let org = new GO2SXYZ(0, 0, 0)
let line = GO2SLineCreate.FromAngle(org, 45)
let circle = GO2SCircleCreate.FromRadius(org, 10)
let points = new GO2SIntersect(line, circle).GetIntersections().map(i => new GO2SPoint(i))
// go back to main workspace (the 3D scene)
let main = GO2SWorkspaceUtil.GetMain()
main.Activate()
// set back the points only from the temporary workspace to the 3D scene
points.forEach(p => main.Copy(p))
Helper class to create circles.
Definition GO2SCircle.hpp:72
Intersections computation.
Definition GO2SCalcUtil.hpp:18
Helper class to create lines.
Definition GO2SLine.hpp:89
Point object.
Definition GO2SPoint.hpp:12
GO2SEnum::GO2SError Activate()
GO2SGeometry Copy(GO2SGeometry geom)
Access to the workspaces.
Definition GO2SWorkspace.hpp:178
Creation of a coordinate reference.
Definition GO2SXYZ.hpp:93
Version
2027

Constructor & Destructor Documentation

◆ GO2SWorkspace()

GO2SWorkspace::GO2SWorkspace ( )

Open a new workspace. It is not active: call Activate() to create geometries in it

Version
2027

Member Function Documentation

◆ Activate()

GO2SEnum::GO2SError GO2SWorkspace::Activate ( )

Make this workspace the active one: new geometries are created in it

Returns
GO2SError.success, or GO2SError.failed if the workspace is closed
Version
2027

◆ Close()

GO2SEnum::GO2SError GO2SWorkspace::Close ( )

Close the workspace and discard all its geometries. If it was the active workspace, the Main workspace becomes active

Returns
GO2SError.success, or GO2SError.failed if the workspace is already closed or is the Main workspace
Version
2027

◆ Copy()

GO2SGeometry GO2SWorkspace::Copy ( GO2SGeometry geom)

Copy a geometry of any workspace into this one

Returns
the copy, or null if failed (closed workspace, geometry plane missing in this workspace)
Remarks
the construction history is not copied
Warning
planes cannot be copied
Version
2027
Parameters
[in]geomgeometry to copy

◆ CopyToolpath()

GO2SEnum::GO2SError GO2SWorkspace::CopyToolpath ( GO2SGeometry geom,
GO2SEnum::GO2SToolpathType type,
GO2SXYZ dir = nullptr )

Copy a geometry of any workspace into the toolpath computed by a toolpath macro. The element is written as the macro writes its own: origin offset, layer, color and plane of the macro

  • a point gives a point (RapidPoint, ApproachPoint, ReturnPoint) or a techno function on toolpath (StartProbePoint, EndProbePoint)
  • a segment gives a line (FeedLine, RapidLine, RapidFeedLine, approach or return lines)
  • an arc in the XY plane gives an arc (FeedArc, RapidFeedArc), travelled from its first to its last point The tool direction is (0,0,1) by default: another direction is written on the toolpath element The name of the geometry, if any, is written as comment of the toolpath element
    Returns
    GO2SError.success, GO2SError.bad_parameters if the geometry does not match the type or if the direction is null, GO2SError.failed if this is not the Main workspace or if the writing failed
    Warning
    only available in a toolpath macro, on the Main workspace
    var seg = new GO2SSegment(p1, p2)
    main.CopyToolpath(seg, GO2SToolpathType.FeedLine)
    main.CopyToolpath(seg, GO2SToolpathType.FeedLine, new GO2SXYZ(0, 1, 1))
    Segment object.
    Definition GO2SSegment.hpp:8
    GO2SWorkspace GetMain()
    Version
    2027
Parameters
[in]geomgeometry to copy
[in]typetype of the toolpath element
[in]dirtool direction, (0,0,1) if null

◆ IsActive()

Boolean GO2SWorkspace::IsActive ( )
Returns
true if the workspace is the active one
Version
2027

◆ IsMain()

Boolean GO2SWorkspace::IsMain ( )
Returns
true if this is the Main workspace
Version
2027

◆ IsOpen()

Boolean GO2SWorkspace::IsOpen ( )
Returns
true if the workspace is open
Version
2027