PDA

View Full Version : Removing Servers



xchrisx
02-12-2013, 01:10 PM
After reading some of the new 11.5 docs I am a bit confused on how to properly handle servers (Textured Enviro, Master, Motion, etc). In Lscript it was fairly simple to remove servers via the Scene().server command. However trying to find an equivalent in Python seems to be a bit harder to find. I believe to access the names of the servers I would have to do something utilizing the pcore.LWServerInfo() command however I cant figure out how to specify the type of server in order to generate a list, let alone remove them. Does anyone have any insight on this? Thanks in advance.

What I am trying to achieve in python:

masters = Scene().server("MasterHandler");
if(masters != nil)
{
for (i=1; i <= size(masters); i++)
{
RemoveServer("MasterHandler", 1);
}
}

From the docs:
class pcore.LWServerInfo(*args)
list(char class) → ids[]
Returns a sequence of strings that represent the identities of all servers registered under the provided class id. The names returned are as they are known to the application, not the "user" names that the server may specify.

artstorm
02-12-2013, 10:24 PM
I did some messing around with adding/removing master handlers from Python. Relying on lwsdk.LWItemInfo() and lwsdk.command().
Check out this code and see if it makes sense,
https://github.com/artstorm/render-presets/blob/master/js_render_presets_button.py#L30

Sensei
02-12-2013, 10:57 PM
ServerInfo in LWSDK is:



LWServerInfo *srvinfo;
srvinfo = global( LWSERVERINFO_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWServerInfo.

typedef struct st_LWServerInfo {
const char* (*path) (const char *, const char *);
const char** (*list) (const char *);
} LWServerInfo;



path = path( class, name )
Returns a full path value to the plug-in module identified by the class and name. The path value is formatted for the current platform. A built-in module is indicated by an empty string (""). If the values do not match any plug-in modules defined in the database, a NULL value is returned.

list = list( class )
Returns a list of strings that represent the identities of all servers registered under the provided class id. The names returned are as they are known to the application, not the "user" names that the server may specify.

The list is terminated by a NULL entry, and the pointer value returned is valid until the next call is made to the function with the same class id.

This is for learning what plugins are currently installed by "Add PlugIns".
It's not for learning what are current scene handlers added.

xchrisx
02-13-2013, 12:39 AM
Thank you both for the replies, it is so much easier to understand seeing it in context.

Artstorm: Thanks for the example code I am picking it apart to make sure I fully understand it. It looks fairly straight forward and I will have to do some reading on a few of the commands.

Sensei: I dont quite follow the C SDK as I don't have any background in C :(. But thanks for the heads up on the Add Plugins vs the current scene handlers. That is definitely good to know.

Sensei
02-13-2013, 12:43 AM
const char * is address of string.
const char ** is array of strings.