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
| Property | Type | Description |
|---|---|---|
facetCount | Number | Total number of facets on the stone |
tablePercentage | Number | Table width as percentage of stone width |
depthPercentage | Number | Total depth as percentage of width |
crownHeight | Number | Crown height as percentage of total depth |
pavilionDepth | Number | Pavilion depth as percentage of total depth |
girdleThickness | Number | Average girdle thickness as percentage of width |
compactness | Number | Volume filling of footprint envelope |
lengthWidthRatio | Number | Ratio of longest to shortest horizontal dimension |
isGirdleEven | Boolean | Whether all girdle facets are uniform |
isGirdleOK | Boolean | Checks overall integrity, corners, and angles |
vertexCount | Number | Number of vertices in the polyhedron |
name | String | Name of the gemstone design |
refractiveIndex | Number | Material refractive index |
Raw Geometry
| Property | Type | Description |
|---|---|---|
vertices | Array of Points | All vertex positions as Point(x, y, z) |
faces | Array of Arrays | Each 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, callstone()again to get updated data. - The
verticesandfacesarrays are read-only copies—modifying them will not affect the actual stone geometry. - Face indices are zero-based and reference positions in the
verticesarray. - All coordinates are in the standard ProFacet coordinate system where +Z is the crown (up) direction.