Hello Christian,
Thanks for your question here!
First, in order to read the Object type of an object in the NSC Editor, you need to use the NPRO() numeric macro function:
As said in the Help, in order to read string values, you have to use the $buffer() function. So for example to extract the type of the first object, you need code 0, and the lines as in the example below:
type = NPRO(1,1,0,0)objectType$ = $buffer()print 'object type: ',print objectType$
GetNSCObjectData will not work from the ZPL macro, it is for the extensions, as you may check it from the header in the Help:
Then, once you have checked the object type, you may use the SETNSCPROPERTY keyword to change the material and the coating on the object. The proper syntax is as follows:
SETNSCPROPERTY surface, object, code, face, value
For the material you need code 4, and for the Coat/Scatter properties you can use codes 5...41 as discussed in the Help. You may read more about how to use the SETNSCPROPERTY keyword in the Help file at: The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > SETNSCPROPERTY (keywords)
For further reference, please check out the knowledgebase article about how to add coatings to non-sequential objects:https://support.zemax.com/hc/en-us/articles/1500005486641-How-to-add-coatings-and-scattering-functions-to-Non-Sequential-objects
Please make sure to use the UPDATE keyword after modifying the object parameters! You may read more about this in the Help at: The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > UPDATE
Finally, to define the length of the FOR loop, you can use the NOBJ() numerical function to extract the number of objects in the NSC Editor:
If you are in pure non-sequential mode please use 1 for the surface number input:
numberOfObjects = NOBJ(1)
If you have further questions, please let us know and we will be happy to help!
Best regards,
Csilla