On Mon, 29 Jun 2026 at 12:50, bert shivaan <
bert.s...@gmail.com> wrote:
>
> Are you positive you are allowed to add the .1 to the script name? I assume you can since it appears to have tried to run it. Just checking the silly things.
Yes, as of openpnp 2.6 your script event files can be named
NozzleTip.BeforeUnload.ANYTHING.YOU.WANT.IN.HERE.js, and it will run
every matching script it finds. This is great for modularity and
cohesion; if you have two different reasons to catch the same
scripting event, then each feature can be in a separate script file.
> task(function() {
The "task" function is for running the action in the machine thread.
You dont need that.
> load(scripting.getScriptsDirectory().toString() + '/Events/NozzleTip.BeforeUnload.1.js');
Your line beginning "load" was copied from the examples directory. In
that example it was referencing the Utility.js script, here you
changed it to reference your own script. Utility.js is what provides
the task() function, so we dont need any of thise.
>> var location = nozzle.location;
>> location = location.add(new Location(LengthUnit.Millimeters, 270, 100, 0, 0));
Here you are trying to move the machine to a location (270,100)
**relative to its current location**
I strongly suspect that you want (270,100) as an absolution location. Right?
This is entirely untested, and I am not too familiar with writing
openpn scripts in js. But I think you need something like this:
var imports = new JavaImporter(org.openpnp.model, org.openpnp.util);
with (imports) {
var nozzle = machine.defaultHead.defaultNozzle
var location = new Location(LengthUnit.Millimeters, 270, 100, 0, 0);
nozzle.moveTo(location);
}