Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Stone Access

Access the current gemstone's geometric properties and raw mesh data for custom calculations, validation, and advanced scripting.

The stone() Function

Call stone() anywhere in your script to get a snapshot of the current gemstone state. This returns an object containing computed metrics, raw vertices, and face data.

name = "Stone Access Demo"
gear = 96

// Cut some pavilion facets
P1 0 @ 41.8 : 0.18 x8

// Get current stone state
s = stone()

// Check metrics
print("Stone Name:", s.name)
print("Facets:", s.facetCount)
print("Table %:", s.tablePercentage)
print("Depth %:", s.depthPercentage)

Available Properties

Computed Metrics

PropertyTypeDescription
facetCountNumberTotal number of facets on the stone
tablePercentageNumberTable width as percentage of stone width
depthPercentageNumberTotal depth as percentage of width
crownHeightNumberCrown height as percentage of total depth
pavilionDepthNumberPavilion depth as percentage of total depth
girdleThicknessNumberAverage girdle thickness as percentage of width
compactnessNumberVolume filling of footprint envelope
lengthWidthRatioNumberRatio of longest to shortest horizontal dimension
isGirdleEvenBooleanWhether all girdle facets are uniform
isGirdleOKBooleanChecks overall integrity, corners, and angles
vertexCountNumberNumber of vertices in the polyhedron
nameStringName of the gemstone design
refractiveIndexNumberMaterial refractive index

Raw Geometry

PropertyTypeDescription
verticesArray of PointsAll vertex positions as Point(x, y, z)
facesArray of ArraysEach face as an array of vertex indices

Examples

Iterating Over Vertices

name = "Vertex Analysis"
gear = 96

P1 0 @ 41.8 : 0.18 x8

s = stone()

// Find the lowest point on the stone
minZ = 1000
s.vertices.forEach((v) => {
  minZ = v.z < minZ ? v.z : minZ
})

print("Lowest Z:", minZ)

Computing Face Normals

name = "Face Normal Computation"
gear = 96
size = 1.0

P1 0 @ 41.8 : 0.18 x8
G1 0 @ 90 : size x8

s = stone()

// Compute normal for first face
face = s.faces[0]
v0 = s.vertices[face[0]]
v1 = s.vertices[face[1]]
v2 = s.vertices[face[2]]

// Cross product of two edges
edge1 = v1 - v0
edge2 = v2 - v0
normal = edge1.cross(edge2).normalize()

print("Face 0 normal:", normal)

Checking Metrics for Validation

name = "Metric Validation"
gear = 96

P1 0 @ 41.8 : 0.18 x8

s = stone()

// Log a warning if depth is too shallow
msg = s.depthPercentage < 50 ? "Warning: shallow depth" : "Depth OK"
print(msg, s.depthPercentage, "%")

Computing Volume Bounds

name = "Bounding Box"
gear = 96

P1 0 @ 41.8 : 0.18 x8

s = stone()

minX = 1000; maxX = -1000
minY = 1000; maxY = -1000
minZ = 1000; maxZ = -1000

s.vertices.forEach((v) => {
  minX = v.x < minX ? v.x : minX
  maxX = v.x > maxX ? v.x : maxX
  minY = v.y < minY ? v.y : minY
  maxY = v.y > maxY ? v.y : maxY
  minZ = v.z < minZ ? v.z : minZ
  maxZ = v.z > maxZ ? v.z : maxZ
})

print("Bounds X:", minX, "to", maxX)
print("Bounds Y:", minY, "to", maxY)
print("Bounds Z:", minZ, "to", maxZ)

Notes

  • The stone() function returns a snapshot at the moment it is called. If you cut more facets, call stone() again to get updated data.
  • The vertices and faces arrays are read-only copies—modifying them will not affect the actual stone geometry.
  • Face indices are zero-based and reference positions in the vertices array.
  • All coordinates are in the standard ProFacet coordinate system where +Z is the crown (up) direction.