PDA

View Full Version : ProjectionImage()



nickdigital
07-08-2011, 03:06 PM
Does ProjectionImage() work? It's listed in the Layout Commands but I'm getting an "unable to locate function reference" error.

I also notice that it's not listed on Dodgy's site.

evenflcw
07-08-2011, 04:17 PM
You can execute all layout commands via CommandInput(). I advice to always use it as then you have 1) all documented sdk commands at your disposal, 2) more up-to-date and complete documentation (maybe briefer), 3) Less weird **** (for example the ItemVisibility is all messed up in lscript because someone thought 1-based indexing would be easier to deal with than 0-based. It isn't. It requires more work from NT and puts lscript and sdk out of synch needlessly. 0-based FTW!), 4) makes transition to or switching between sdk and lscript easier. ETC etc. It's always the better option imho.

There was one thing I was worried about though... the command takes an id. Not all Object Agents in lscript have a defined id data member (interface controls lack them) and it's not stated anywhere that the ids are the same as when using sdk (where they are likely memory addresses). Lucky for you it seems the images have them and it's the same value. (Item ids are also same, so likely if the member exists it is the same as sdk).

So this works. (Have a spotlight selected).

generic
{
image = Image(); //first image
if(image) {
CommandInput("ProjectionImage "+hex(image.id));
}
else {
warn("No image loaded!");
}
}

nickdigital
07-08-2011, 04:22 PM
Thanks again.

When you say "SDK" are you talking about Dodgy's reference and the LScript reference guide? Or is this a different resource?

evenflcw
07-08-2011, 04:29 PM
With SDK I mean what the plugin (C/C++) coders use. You'll find 3 html documents in the SDK docs with all (most of?) the commands.

http://www.newtek.com/lightwave/developers.php

You might also have a copy in your LW install directory.

nickdigital
07-08-2011, 04:30 PM
Thx
Yep, I d/led it yesterday. More stuff to read...fun.

nickdigital
07-08-2011, 04:44 PM
According to the lscript ref ctlimageitems returns an Object Agent.

In your example you have an image variable that gets the Image() object. From there you do a hex and add .id to it in the CommandSequence part. If I do the hex and .id part to the cltimageitems variable I get an error.

What am I missing between my code and your example?

evenflcw
07-08-2011, 04:52 PM
The ctlimageitems variable or the .value data member of it?
Do post code if you got it.


generic
{
reqbegin("<Requester Title>");
c0 = ctlimageitems("Imagez", nil);
return if !reqpost();
image = c0.value;
reqend();



if(image) {
CommandInput("ProjectionImage "+hex(image.id));
}
else {
warn("No image loaded!");
}
}

nickdigital
07-08-2011, 05:53 PM
I got it to work. I guess I need the if/else check?

Is there a big difference between getvalue and .value?

evenflcw
07-08-2011, 08:03 PM
There shouldn't be any difference. But one is a function and the other a data member (from what we see atleast). I have had instances, again related to listboxes, where one did not deliver as expected, but the other did. I think this was about setting rather than getting though. .value feels more direct to me. I think it was also the one that worked out the best. But don't quote me on that.

The ProjectionImage command did crash when I supplied it an invalid id (1;0). So yes, I think you should definitely check that you have a valid image object before using it. If using a non-modal panel the selection of the image might precede an unexpected deletion of the same image, invalidating the id before you run ProjectionImage. But to each his own. Validation can be a matter of coding style.

nickdigital
07-08-2011, 09:01 PM
The ProjectionImage command did crash when I supplied it an invalid id (1;0). So yes, I think you should definitely check that you have a valid image object before using it. If using a non-modal panel the selection of the image might precede an unexpected deletion of the same image, invalidating the id before you run ProjectionImage. But to each his own. Validation can be a matter of coding style.

Ok, I am using a floating window for my UI. Thanks for the explanation, more noodl-y coding stuff that I have to keep in mind.