PDA

View Full Version : read only members



jylam
03-13-2003, 07:28 AM
Hi,
I'm new to lscripting, and I've a problem, as you might guess :)

My problem is simple, how can I change the name of a mesh, as layout says me it is a readonly member of mesh structure.

I get my mesh from a scene, with something like this :

scene = Scene();
obj = scene.getSelect(MESH);
mesh = Mesh(obj[1].name);

mesh.name = string("new_name");

this last line fails ...

If someone has an idea, thanks a lot

Lynx3d
03-13-2003, 10:07 AM
Hehe, well doesn't read-only imply that it's not meant to be modified, or even impossible to modify?

If you can't do it in Layout (and you can't change object names in Layout) chances are small you can do it with Scripts...

ToolmakerSteve
03-13-2003, 12:45 PM
"If you can't do it in Layout..."

That suggests an idea - try doing it in Modeler.

jylam
03-13-2003, 01:47 PM
hey we actually CAN change name of null objects in layout, so maybe there's a way we can do it by lscripts ...

Anyway, is there a way to add options on the lws file ?
I explain :

Plugin DisplacementHandler 1 LW_LScript
Script D:\CODE\LIGHTWAVE\PARTICLE.LS
EndPlugin


It is my lscript on the lws file.
How can I add options to that ? I mean, I tried the fx_wind lscript, it appears like that :

Plugin CustomObjHandler 1 FX_Wind
format 1
windflag 0 1 1 0 0 0
w0 0 1 0 0
ts 1 1 1 0 0.5
tv 1 0 0
EndPlugin

Lynx3d
03-13-2003, 04:50 PM
Hm, you have a point there, you can rename nulls :D
If you can do it with LScript it's most likely an own function (method? whatever it's called), it's not really common that you can overwrite data provided by LW directly.

Maybe join the LScript mailing list, Bob knows for sure...
with the SDK you can just use Layouts rename command, but i couldn't find something like that in the LScript doku, however LScript is developing all the time...just had a major update with 7.5b i think.

faulknermano
03-15-2003, 10:22 AM
the only way to 'rename' a mesh is to execute a SaveObject() command on it. the default behavior of layout in this case is that it saves an object with the new name and replaces it in the current scene, effectively 'renaming' it. you can, if you dare, delete the old name right from within lscript as well.

regarding adding options:

i'm not sure what you mean. if you wish to add optiosn your OWN script (NOT to a lightwave plugin), then you use the load() and save() functions. load() will run everytime you load the scene, and save() will execute when you save objects or save scenes. look at the lscript user guide for more info.

if you want to change options of a given lightwave plugin (like ParticleFX), you MUST know what you're doing. but it's very hard, either way. you have to parse the every line looking for the right 'keywords'.

first, open the scene file as read-only. second, open a temp file for writing. read the scene file line by line, and then dump the info to the temp file. if you encounter a line you wish to change, change it and then dump the modified line into the temp. then close the temp file and the scene file.

when everything is done, you have the option of deleting the scene file (not recommended due to risk of data loss, but it's up to you) and then renaming the temp file to the scene file's original name.