I've got the following script to add markers in the layout.
Calling the function srCreateLayMarker() would keep it active until i click on the layout, and it goes away. How can i make this function stay active until an escape key is pressed?
procedure(srCreateLayMarker( @optional (pt nil) (cv geGetEditCellView()) )let((mid lbl_txt lbl )
unless(cv && cv~>cellViewType=="maskLayout" error("A layout cellview must be open to create the marker at current location") )
unless(ptpt=hiGetPoint(hiGetCurrentWindow()) )sprintf(lbl_txt "%L %L" car(pt) cadr(pt))
mid=dbCreateMarker(cv "marker" "srCreateLayMarker" list(pt) )
lbl= dbCreateLabel(cv list("y0" "drawing" ) pt lbl_txt "centerLeft" "R0" "roman" 0.1)lbl~>parent=mid);let);proc
hiSetBindKey("Layout" "F10" "srCreateLayMarker()")
I don't really understand what you mean with "Calling the function srCreateLayMarker() would keep it active".I tried your code - as long as the mouse pointer is in a layout window and I click F10 (the bindkey...) it works perfectly well for me. Calling the function manually from the CIW throws an error because hiGetPoint(hiGetCurrentWindow()) returns nil when the mouse pointer is not in the layout window. This leads subsequently to an error in dbCreateMarker(..) then.So as I said I don't exactly understand your question but if you change the unless() statement to
unless(pt pt = hiGetPoint(hiGetCurrentWindow()) || (0:0))
...you will be able to call the function either though the bindkey or manually from the CIW.
I suspect that what is really wanted here is to use enterPoints() and then have the code be triggered on each point that is added until escape is pressed. That's going to be the easiest solution. There are a number of other similar posts on the forums - search for "enterPoints" or "enter function" for more details. Or look in the documentation for enterPoints.