Skip to main content
Solved

ZPL "GET" Commands for the LDE in NS Mode

  • December 31, 2022
  • 4 replies
  • 174 views

Michaelkm8
Ultraviolet

Hello,

          Is there a way to query the LDE in NS mode to get the column ints, doubles, or strings?  Additionally, query the column name of the row number?

 

[Mod note: moved to more appropriate forum for ZPL-related discussions.] 

Best answer by MichaelH

Hi Keith,

The $COMMENT() only works for sequential surfaces in the LDE; it does not work for non-sequential objects in the NSC.  To get the non-sequential comment, you need to use a combination of NPRO() and $BUFFER().  Assuming you're in pure non-sequential mode (where the NSC Surface = 1), the code to get an object's comment is:

obj = 1
temp = NPRO(1, obj, 1, 0)
nsc_comment$ = $BUFFER()
PRINT nsc_comment$

 

View original
Did this topic help you find an answer to your question?

4 replies

Michaelkm8
Ultraviolet
  • Author
  • Ultraviolet
  • 30 replies
  • December 31, 2022

Found it.  I was trying to use it to name detectors, but didn’t realize the “i” parameter was the surface number

$COMMENT(i)

Where “i” is the surface number.  My detectors were at the bottom of the LDE so I just had to add a constant to get the correct surface in a for loop

$COMMENT(i+27)

Still not working though, but this is how you “get” comment line.


Michaelkm8
Ultraviolet
  • Author
  • Ultraviolet
  • 30 replies
  • January 1, 2023
path$ = $PATHNAME() + "\"
lensFilename$ = $FILENAME()
lengthFilename = SLEN(lensFilename$)
shortenFilename$ = $LEFTSTRING(lensFilename$, lengthFilename-3)
cfgFilename$ = path$ + shortenFilename$ + "CFG"


! Calculate number of detectors in the system
numObj = NOBJ(1)

FOR obj = 1, numObj, 1
	FORMAT 1 INT
	surf = 27 + obj
	PRINT surf
	NM$ = $COMMENT(surf)

	A$ = path$ + NM$ + ".BMP"
	! B$ = path$ + "DetData_" + $STR(obj) + ".TXT"
	type = NPRO(1, obj, 0, 0)
	type$ = $BUFFER()
	! Check if the object type is a detector. If yes, continue
	IF (type$ $== "NSC_DETE")
		! Update the settings with the detector number
		MODIFYSETTINGS cfgFilename$, DVW_DETECTOR, obj
		! With the new settings, open a window and take an image of what is there
		OPENANALYSISWINDOW DVR
		winVal = WINN()
		EXPORTBMP winVal, A$
		CLOSEWINDOW winVal
		! Additionally, save the detector data as a text file
		! GETTEXTFILE B$, DVR
	ENDIF
NEXT

I am using the code from one of the macros that are pre-built in Zemax, but just trying to get the name of the detector image file changed.  However, the COMMENT line does not return anything.  I feel like this should not be this hard, but I can't figure out what Zemax is doing.  Can someone point me in the right direction?  The PRINT statement generates this.

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 342 replies
  • Answer
  • January 3, 2023

Hi Keith,

The $COMMENT() only works for sequential surfaces in the LDE; it does not work for non-sequential objects in the NSC.  To get the non-sequential comment, you need to use a combination of NPRO() and $BUFFER().  Assuming you're in pure non-sequential mode (where the NSC Surface = 1), the code to get an object's comment is:

obj = 1
temp = NPRO(1, obj, 1, 0)
nsc_comment$ = $BUFFER()
PRINT nsc_comment$

 


Michaelkm8
Ultraviolet
  • Author
  • Ultraviolet
  • 30 replies
  • January 9, 2023

Thank you!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings