Set Envelope points by Nyquist command

Hi,
please can you tell me how to set envelope point on cursor position (or selection range) via Nyquist command? The same way like I would set this with Envelope tool.
I tested multiple effects, but those apply amplification directly on the clip. They do not add envelope breakpoints (non-destructive).

Note: Only one way what I discovered is Scriptable I > Set Envelope. But the problem is, that I cannot set time based on cursor position or based on selection. I must set absolute time from beginning of track.

Thank you!

Nyquist cannot directly access Audacity envelopes. It can however send Scripting commands with “AUD-DO”. See: https://alphamanual.audacityteam.org/man/Nyquist-Macros

Note that an important limitation of Nyquist Macros is that they may either modify the project from Nyquist, OR modify the project from scripting commands, but not both within the same plug-in. If you need to do both, then you will need to create two plug-ins; one that does the scripting stuff, and the other to do the Nyquist stuff.

To create a control point, value 0.5, at the start of the current selection / cursor position:

;version 4
;type tool

(setf time 0)   ;time of label relative to start of the selection
(setf val 0.5)  ;envelop point value

(let ((start (get '*selection* 'start)))
  (setf command (format nil
                        "SetEnvelope: Time=~s Value=~s"
                        (+ start time)
                        val))
  (aud-do command))

Thank you very much!
It is working.