Set item shape in lscript?


Well-known member
Yes there is, but it's not for the weak of heart.
1) Apply the "CustomObjHandler" "LW_ItemShape" to the null.
2) Get the data fields required by using itemshapedata();
3) Attach to the comring
4) Encode an empty data block using comringencode
5) Send a comringmsg to the plugin requesting to send it's current data. (msg code 100)
6) Decode the data.
7) Fill the array with your data.
8) Encode your data
9) Send your comringmsg to set the data. (msg code 200)
10) Detach from the comring.

I found it easier to encapsulate all of the above into a single UDF, so in your main loop, you simply have
result = addItemShapeToObject(ObjectID, paramArray);

instead of 200 lines of code in the middle of your script.

I have a lscript out there that redoes the Add Item Shape menu that's not compiled. Most of the code involved deals with setting the item shape, the rest deals with the UI. go here and tear it apart and see if you can figure it out. I'd post it here, but I might get in trouble since the data structure for LW_ItemShape handler is private to NewTek, and no longer open to the public. IMHO, that's kind of dumb. There's a couple of old lscipts that broke that have the basic code there as will.

go here -> to get the zip containing the script, It's I'll try to answer any questions I can.


New member
Jiminy Christmas! That comring stuff is no joke! I think i understand more or less what is going on there, and I very much appreciate you sharing that with me! For the time being I think I might try to avoid spinning off into that tangent, since item shapes are not absolutely vital to what I am working on at the moment, but would merely be nice to have. Thanks!


Well-known member
Also, keep in mind that you may need to trap different versions of Lightwave in your script; the contents of the array returned by itemshapedata() differs between 2019.1.5 and 2020.; there is one less item in 2020.

Also, what that field does has also changed.

The first 24 fields remain the same.

Prior to LW2020:
Field 25 contained a duplicate of the null's label text.
Field 26 was a string field, and was not used.
Field 27 was a numeric field, set to 0
Field 28 was a string field, and was not used.
Field 29 was a string field, and contained the name of the object a dashed line was drawn to.
Field 30 was a numeric field, containing a value indicating how the null label was positioned.

In LW2020:
Field 25 contains the name of the null's item shape. It will not be applied unless it is present here.
Field 26 is a numeric field, set to 0.
Field 27 is a string field, and is not used (set to "").
Field 28 is a string field, and contains the name of the item a dashed line is drawn to.
Field 29 is a numeric field, containing a value indicating how the null label was positioned.

Hope this helps someone.
Last edited:


Well-known member
After finding out there was another way to add itemshapes (in Python), I decided to see it worked in lScript.

It did.

This code snippet adds a null, and then sets it's item shape.

*edit* While everything else works, for some reason the LineTo part refuses to work in LScript. I also corrected the code for that part.
Which is odd, because the Python version works fine...

@script generic

    IS_Z = 2;
    IS_BOX = 2;
    addNullShape(IS_BOX, 1.0, IS_Z, false, false, nil);

addNullShape: shape, scale, axis, filled = false, xray=false, drawto=nil
    var s0 = @"False","True"@;
    var ls = @"Standard","Box", "Ball","Pyramid","Diamond","Tetra","Ring","Grid","None"@;
    f1 = s0[1+filled];
    f2 = s0[1+xray];
    ss = "Generic_AddItemShape Replace=\"True\" ";
    ss += "Shape=\""+ls[shape]+"\" Axis=\""+axis+"\" Scale=\""+scale+"\" ";
    ss += "Filled=\""+f1+"\" XRay=\""+f2+"\" ";
    if (!drawto.isNil()) ss += "LineTo=\""+hex("\"";
Last edited:
wandering, would it be possible for it to recall last used settings ?
by the way, made a vid, was a bit tired when making it, so not much energy...



Well-known member
I'll admit that there is a way...
You can save the settings for the selected plugin to a temp file, and read them back in. Much simpler to do than mucking about with the comring.

I grabbed the generic_additemshape usage from a python plugin, and that was the method the author of that used to read the current settings of the plugin. Dunno if that would work in lscript.

The two scripts I use ItemShape for are for setting up nulls & itemshapes, not editing them, so it's a moot point anyway...
Top Bottom