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 :
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