Jump to content

Accessing Properties of Specific Reference Sphere in Formulas


---
 Share

Recommended Posts

TL;DR - The code below can be used to directly access the properties of any reference sphere on the machine using serial numbers. It will even throw an error if it can't find the serial number provided. You don't need PCM to use it, so it can be used anywhere formulas are available, like Result Elements and theoretical features.

As with all executeCode() statements, use at your own risk!

// just replace the 123ABC with the serial number of the desired reference sphere
executeCode( "|rs_sn| rs_sn := '123ABC'. Zeiss.CMMOS.OMSphereNormal getAllSphereNormals detect: [:rs | rs serialNo = rs_sn] ifNone: [rs_sn error: 'No sphere found with the serial number ''', rs_sn, '''']." )

 

I also made a version that uses the "sphere number" instead of the serial number:

// just replace the 1234 with the "sphere number" of the desired reference sphere
executeCode( "|rs_num| rs_num := '1234'. Zeiss.CMMOS.OMSphereNormal getAllSphereNormals at: (rs_num, '.0') asSymbol ifAbsent: [rs_num error: 'No sphere found with the RS number ''', rs_num, '''']." )

 

Common uses from other forum posts include:

round( executeCode( ... ).ident )	//returns the "sphere number"
executeCode( ... ).serialNo		//returns the serial number
executeCode( ... ).spherePosition.x
executeCode( ... ).spherePosition.y
executeCode( ... ).spherePosition.z
executeCode( ... ).sphereRadius

 

Just wanted to share the fruits of my labor here for posterity. For context, I was developing a test study program to evaluate the accuracy loss when creating a stylus system with RDS-CAA enabled. Ideally, I'll make another post with my findings and comment later with a link to that post, but the relevant detail is that I was using a reference sphere (RS) as the comparison artifact. Because the program started by relocating the RS and requalifying the two test stylus systems, I wanted to be able to use the RS's most recent XYZ values for the comparisons. In my searching, I found two methods to access this information, but each had its own limitation:

  1. Using baseSystem().machine.machineControl.sphereNormalObject.spherePosition.x/y/z is clear and succinct, but it always refers to the RS that's currently "active".
  2. Iterating through the contents of executeCode("Zeiss.CMMOS.OMSphereNormal getAllSphereNormals").asArray gives you access to all the RS on the machine, but a) you need PCM to do loops (afaik), and b) you'll still have to get creative with storing the results if you want to be able to directly access a specific RS by its "sphere number" alone.

Taken together, I knew there had to be a way to do more inside the executeCode() statement to directly access specific spheres for a method that gives the best of both options. The solution came after reading through a Smalltalk language cheat sheet and determining that "getAllSphereNormals" is returning a Dictionary with sphere data objects as values and the "sphere number" as keys. The most difficult part was figuring out that the keys are strings as symbols, e.g., #'exampleKey', rather than a number or even just as a regular string. Once I was able to return RS values using hard coded keys, it was just a matter of learning the syntax of Smalltalk enough to use variables and the built-in functionality of Dictionaries. 

I hope this helps others out. I "wasted" several hours figuring this out, but I learned a lot and ultimately found the exact solution I wanted. Here's the website I used for the crash course on Smalltalk: Learn Smalltalk in Y Minutes

 

Smalltalk Language Cheatsheet.html

  • Like! 3
  • Thank you! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...