NSC Polygon Object: where is prism_array.zpl macro?

  • 10 June 2020
  • 2 replies
  • 95 views

Userlevel 3
Badge

I found a NSC polygon object 'prism_array.pob' that does ALMOST what I want (put a linear array of microprisms on a 'slab' of material), but I would like to generate (micro-)prisms having different angles, spacing, scale, and different thickness 'slabs.'


Editing the .POB file shows that it starts as follows with the comment that it was created by a ZPL macro 'prism_array.zpl':


'! This polygon object was created by the prism_array.zpl macro

!

V 1  82.50000000  50.00000000  0

V 2  82.50000000 -50.00000000  0

V 3 -82.50000000 -50.00000000  0

V 4 -82.50000000  50.00000000  0

R 1 2 3 4 0 0

V 5  82.50000000  50.00000000  10.00000000 ...'


But I can't find the prism_array.zpl macro to edit it, see what can be varied, or to use it to generate new prism array .POBs.


Can anybody provide a copy of prism_array.zpl, or point me to where to find it?  I have the latest OpticStudio release 20.2 (Professional, perpetual), and can't find it in the Macros folder (or among the same list in the program).


-- Greg


2 replies

Userlevel 3
Badge

Thank you, Allie!


I'll try them both out.


-- Greg

Userlevel 6
Badge +2

Hi Greg,


The original prism_array.zpl was written by Mark Nicholson in 2005. I have not tested it extensively, but I found it will run without error in 20.2. It is attached at the bottom of this post. 


More recently, a colleague of mine tried to replicate the functionality. I think you may find his approach interesting, so I am pasting his sample macro below. This will create an array of prisms, but will only code the front face. The others will need to be added by you!


Let me know if you have any other questions about this!


Best,


Allie


 


# Initialization

number_of_prisms = 10

vertex_number = 1

origin_x = 0

origin_y = 0

origin_z = 0

side_length = 2

height      = side_length/2*SQRT(3)

x_separation = 5

# Output POB file definition

FILE_NAME$ = $OBJECTPATH() + '\Polygon Objects\Prism_Array_DNg.POB'

OUTPUT FILE_NAME$

# Loop over the prisms

FOR ii, 0, number_of_prisms-1, 1

    # Prism front face

    position_x = origin_x+ii*x_separation

    

    FORMAT 3 INT

    PRINT 'V ', vertex_number,

    FORMAT 2.6

    PRINT ' ', position_x, ' ', origin_y, ' ', origin_z

    vertex_number = vertex_number + 1

    

    FORMAT 3 INT

    PRINT 'V ', vertex_number,

    FORMAT 2.6

    PRINT ' ', position_x+side_length, ' ', origin_y, ' ', origin_z

    vertex_number = vertex_number + 1

    

    FORMAT 3 INT

    PRINT 'V ', vertex_number,

    FORMAT 2.6

    PRINT ' ', position_x+side_length/2, ' ', origin_y+height, ' ', origin_z

    vertex_number = vertex_number + 1

    

    FORMAT 3 INT

    PRINT 'T ', vertex_number-3, ' ', vertex_number-2, ' ', vertex_number-1, ' 0 1'

    

    # Prism side faces

    # ...etc.

    

    # Prism back face

    # ...etc.

NEXT

Reply