How to make paint nozzle?

Typically: "How do I... ", "How can I... " questions
fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: How to make paint nozzle?

Post by fferri »

elizakh wrote: 15 Jul 2021, 23:17 So I've deleted all the functions relative to the dialog of the paint nozzle and in sysCall_init() I specify the paint item (i.e: mode=sim.drawing_lines). However, the dialog stills appearing when I click the dummy "PaintNozzle" and the paint item only changes If I change It in the dialog, but I want to do it that via script. Seems like Coppelia ignores when I specify the paint item by code and I don't know how can I fix it.
To disable the dialog you can simply add:

Code: Select all

showDlg=function() end
updateUi=function() end
at the very end of the customization script

elizakh
Posts: 29
Joined: 20 Feb 2021, 13:27

Re: How to make paint nozzle?

Post by elizakh »

Thank you, I disabled the dialog, but when I made some changes in the variables "itemSize" or "mode" It don't change until I save the scene, close the scene, and open again the same scene. So I don't know why it doesn't change without close and open again the scene. I've the latest version of CoppeliaSim for Mac, maybe It can be a bug?

Thanks !

Cheers

elizakh
Posts: 29
Joined: 20 Feb 2021, 13:27

Re: How to make paint nozzle?

Post by elizakh »

I fixed it changing the customization script to child script.

Cheers!

elizakh
Posts: 29
Joined: 20 Feb 2021, 13:27

Re: How to make paint nozzle?

Post by elizakh »

Hi again,

I'm trying to change the jetAngle via MATLAB. For that I call this function and I send the values of the jetAngle from MATLAB :

Code: Select all

function cambiarboquilla(jetAngle,jetRange) 
 jetHandle=sim.getObjectHandle("PaintNozzleJetVolume")
local n=sim.getObjectName(jetHandle)
        local p=sim.getObjectParent(jetHandle)
        local m=sim.getObjectMatrix(jetHandle,-1)
        sim.removeObject(jetHandle)
        jetHandle=sim.createProximitySensor(sim.proximitysensor_ray_subtype,sim.objectspecialproperty_detectable_all,1+512,{3,3,2,2,1,1,0,0},{0,jetRange,0,0,0,0,0,0,0,jetAngle*math.pi/180,0,0,0,0,0})
        sim.setObjectProperty(jetHandle,sim.objectproperty_selectable|sim.objectproperty_selectmodelbaseinstead|sim.objectproperty_dontshowasinsidemodel)
        sim.setObjectName(jetHandle,n)
        sim.setObjectParent(jetHandle,p,true)
        sim.setObjectMatrix(jetHandle,-1,m)
   
end
But I've a problem, everytime that the simulation runs and stops, the object PaintNozzleJetVolume disappears because I use :

Code: Select all

    sim.removeObject(jetHandle)
in the same way that is programmed in the default code of the PaintNozzle item.
But If I remove that command, the code gives the next error:

18: Illegal object name. (in function 'sim.setObjectName')


So I don't know how can I do for change at each simulation the value of JetAngle without deleting the item.

Thank you very much in advance

Cheers

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: How to make paint nozzle?

Post by fferri »

elizakh wrote: 21 Jul 2021, 10:54 18: Illegal object name. (in function 'sim.setObjectName')
That may happen when some object already exists with that name.

Post Reply