View Full Version : LWSurfaceFuncs() - help needed..

02-05-2014, 08:46 AM
I've add these lines of code to my plugin. According to the documents, the 'first()' method it returns the ID of the first surface. The surface editor contains three surfaces, but when I run the code I get 'None' come back.

surfunc = lwsdk.LWSurfaceFuncs()
a = surfunc.first()
print (a)

I'm probably using it in the wrong way, so does anyone know what I should be doing??! What I want to do ultimately is remove any surfaces I created during the command sequence process. I've used them to help with selections.


02-05-2014, 12:36 PM
Try this to get surface names


surf_funcs = lwsdk.LWSurfaceFuncs()
surface = surf_funcs.first()

while surface:
surfname = surf_funcs.name(surface)
print surfname

02-05-2014, 03:32 PM
'a' is surface id not name.

02-05-2014, 04:35 PM
Thanks for the code snip Iain. Will try that.

Sensei, I thought 'a', would give me a number, so print (a) would show 0001 or similar. But as mentioned, probably not using the function correctly.

02-06-2014, 02:07 AM
If I've made sense if the sdk I think I understand why my code came back with none. The data type for the id is 'void' and points to a memory location of a value rather than an actual value. So in Iain's example the name() method can use the value that the memory location is pointing at.

Or should I start from page 1 of the manual again? :D

02-06-2014, 09:49 AM
how do you delete unwanted forum posts? :bangwall:

02-06-2014, 12:17 PM
This snippet of code is from my change surface script and the docs show that name() function returns the string of the surface based on the id, which is retrieved by the first() function. The while was part of my loop to go through the various surface, there is a next() in the loop so that it cycles through all the surface ids. My scripts have been uploaded onto another thread if you need to see the full code.




02-06-2014, 12:47 PM
Thanks for the link Iain - will dissect with interest :)