Project operator

The Project operator allows you to get access from the code of the postprocessor to the information about the SprutCAM project (information that relates to the entire project, and not to individual operations), which lies in the CLData. Operator syntax is as follows.

Project.Ptr|Str|Int|Flt["ParameterName"]

Here, Project is the key word to access SprutCAM project level parameters.

Ptr or Str or Int or Flt is a keyword that defines the form in which you want to represent the value of a property — as a string, as an integer, as a floating point number, or as a pointer to a property. Read more about this in Named CLData parameters topic.

Further in square brackets follows the string identifier of the property whose value is to be obtained. It can be a string constant, as shown here, as well as any string expression or variable.

For a description of possible properties and their values, see the appendix in the Project information in CLData article.


Consider an example of obtaining information about the workpiece using this operator.

PrintAllWorkpiece
sub PrintAllWorkpiece
i: Integer
j: Integer
px, py, pz, pv: Real
for i = 1 to Project.Ptr["Parts"].ItemCount do begin
Output "( Part" + str(i) + ".Workpiece )"
for j = 1 to Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].ItemCount do begin
Output "( Primitive " + str(j) + " )"
case Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Int["PrimitiveType"] of
0: begin !Unknown
Output "( Type: Unknown )"
end
1: begin !Empty
Output "( Type: Empty workpiece )"
end
2: begin !Faces
Output "( Type: Faces )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.Z"]
Output "( Min point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.Z"]
Output "( Max point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
end
3: begin !Casting
Output "( Type: Casting )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Stock"]
Output "( Stock: " + str(pv) + " )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Min.Z"]
Output "( Min point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Box.Max.Z"]
Output "( Max point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
end
4: begin !Box
Output "( Type: Box )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Min.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Min.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Min.Z"]
Output "( Min point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Max.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Max.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Max.Z"]
Output "( Max point: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
end
5: begin !RevBody
Output "( Type: Turn envelope )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Z"]
Output "( Origin: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Z"]
Output "( Axis: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
end
6: begin !Cylinder
Output "( Type: Cylinder )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Z"]
Output "( Origin: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Z"]
Output "( Axis: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMin"]
Output "( Min level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMax"]
Output "( Max level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["ROut"]
Output "( Outer radius: " + str(pv) + " )"
end
7: begin !Tube
Output "( Type: Tube )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Z"]
Output "( Origin: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Z"]
Output "( Axis: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMin"]
Output "( Min level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMax"]
Output "( Max level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["ROut"]
Output "( Outer radius: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["RInn"]
Output "( Inner radius: " + str(pv) + " )"
end
8: begin !Prism
Output "( Type: Prism )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Z"]
Output "( Origin: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Z"]
Output "( Axis: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMin"]
Output "( Min level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMax"]
Output "( Max level: " + str(pv) + " )"
end
9: begin !PolygonalPrism
Output "( Type: Polygonal prism )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Origin.Z"]
Output "( Origin: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
px = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.X"]
py = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Y"]
pz = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Axis.Z"]
Output "( Axis: (" + str(px) + ", " + str(py) + ", " + str(pz) + " ) )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Int["CornerCount"]
Output "( Corner count: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["RInn"]
Output "( Inscribed radius: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["Angle"]
Output "( Angle around axis: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMin"]
Output "( Min level: " + str(pv) + " )"
pv = Project.Ptr["Parts"].Item[i].Ptr["Workpiece"].Item[j].Flt["HMax"]
Output "( Max level: " + str(pv) + " )"
end
else begin
Output "( Type: Something else )"
end
end
end
end
subend


The result of this subroutine may be the following text block.

Results
( Part1.Workpiece )
( Primitive 1 )
( Type: Tube )
( Origin: (0, 0, 117.5 ) )
( Axis: (0, 0, 1 ) )
( Min level: -149.5 )
( Max level: 149.5 )
( Outer radius: 66 )
( Inner radius: 29 )
( Primitive 2 )
( Type: Cylinder )
( Origin: (0, 0, 117.5 ) )
( Axis: (0, 0, 1 ) )
( Min level: -147.5 )
( Max level: 147.5 )
( Outer radius: 64 )
( Primitive 3 )
( Type: Turn envelope )
( Origin: (0, 0, 117.5 ) )
( Axis: (0, 0, 1 ) )
( Primitive 4 )
( Type: Box )
( Min point: (-64, -64, -30 ) )
( Max point: (64, 64, 265 ) )
( Primitive 5 )
( Type: Casting )
( Stock: 1 )
( Min point: (-65, -65, -31 ) )
( Max point: (65, 65, 266 ) )
( Primitive 6 )
( Type: Faces )
( Min point: (-54, -54, -30 ) )
( Max point: (54, 54, 265 ) )
( Primitive 7 )
( Type: Polygonal prism )
( Origin: (0, 0, 117.5 ) )
( Axis: (0, 1, 0 ) )
( Corner count: 6 )
( Inscribed radius: 160.786 )
( Angle around axis: 0 )
( Min level: -64 )
( Max level: 64 )
( Primitive 8 )
( Type: Empty workpiece )