View Full Version : Get ServerRecord / ServerTagInfo for each plugin?

12-23-2014, 04:57 AM
I'd like to access individual server / plugin metadata.

This gets a list of plugin names.

__author__ = 'nick'

import lwsdk

# NOTE: scraped from "http://static.lightwave3d.com/sdk/2015/html/classes.html"
plugin_class_list = ["AnimLoaderHandler", "AnimSaverHandler", "AnimUV", "CameraHandler", "ChannelHandler", "ColorPicker", "CommandSequence", "CustomObjHandler", "DisplacementHandler", "Display3D", "EnvironmentHandler", "ExtRendererHandler", "FileRequester", "FrameBufferHandler", "Global", "HumanInterfaceHIDHandler", "HumanInterfaceManagerHandler", "ImageFilterHandler", "ImageLoader", "ImageSaver", "InstancerHandler", "ItemMotionHandler", "LayoutGeneric", "LayoutTool", "LightHandler", "MasterHandler", "MeshDataEdit", "MeshEditTool", "NodeHandler", "ObjectLoader", "ObjReplacementHandler", "PixelFilterHandler", "PolygonHandler", "ProceduralTextureHandler", "SceneConverter", "ShaderHandler", "VolumetricHandler"]

server_info = lwsdk.LWServerInfo()
plugin_list = {}

for plugin_class_name in plugin_class_list :
print "plundering plugin names of class", plugin_class_name

# Collect plugin name by class
plugin_list[plugin_class_name] = server_info.list(plugin_class_name)

print plugin_list[plugin_class_name]

# TODO how to get server ServerTagInfo for each element of plugin_list?

It generates something like ... ('AbsoluteMeasure', 'ActiveConnector', 'AddLuxigon', 'AddPowergon', 'Add_Center_Point', 'AdjustPolyMap', 'Align_Points_to_Axis', 'Align_to_Last_Point_X', 'Align_to_Last_Point_Y', 'Align_to_Last_Point_Z', 'ApplyMORF', 'AssignPivot', 'AssignPivot2', 'BandSaw', 'Bkg-To-MORF', 'BoneWeights', 'BorderSlice', 'BorderSliceQuad', 'BoundingBox', 'Bridge', ... and so on.

Now I want to get at each of these server's records.

12-23-2014, 03:30 PM
ServerInfo has just two functions: path() and list() that you're using.

The only thing I can think about is using C/C++ GetProcAddress( module, name );
And then read structure..

12-25-2014, 12:38 AM
Thanks for the reply!

I'm on Mac, and I want to apply this technique also to scripts. I'd wanted to improve discoverability of plugins using a native plugin, either script or C.

I poked at a plugin using NM, OTOOL, and looked at the C SDK files. While these approaches would not work for scripts, only for binary plugins, I still could not figure out how to get the ServerDesc symbol from the compiled binary.

From there I could build a database of metadata with well-known plugin names, e.g. "BandSaw", and have the DB supply keywords from the documentation to help find and document the application's functionality. Find the section in the docs, and save it to the DB...you get the idea.

I could still request an API from LW3DG but I imagine it would not be in line with their product vision / be seen as a waste of dev resources.

While it's a bit of a bummer there's no public API to examine other modules / plugins in LightWave it's good to at least be able to put my idea away and move onto the next.

12-25-2014, 01:30 AM
dlopen() is equivalent of LoadLibrary()
dlsym() is equivalent of GetProcAddress()


12-25-2014, 09:09 PM
Would one expect the well-known "ServerDesc" symbol (a global of type ServerRecord[]) be listed in the binary of the plugin, readable via 'strings' ( https://en.wikipedia.org/wiki/Strings_(Unix) ), for a release binary plugin? I don't see "ServerDesc" mentioned in any of my LW (release) plugins.

Also, is it well-known? I mean, are LightWave plugins by convention object files which contain a 'ServerRecord ServerDesc[]' global (plus a "static int Activate(...)" function)?

I've not tried dlsym() yet just the short-cut strings utility...perhaps embedded in the plugins there are obfuscated C string inaccessible to "strings"..?

EDIT: The binutils package http://stackoverflow.com/questions/3286675/readelf-like-tool-for-mac-os-x may have a tool to help me inspect from commandline.

EDIT 2: dwarfdump...

12-25-2014, 09:11 PM
Look at LWSDK\source\servmain.c

ModuleDescriptor _mod_descrip =

You have to look up for _mod_descrip

12-25-2014, 09:16 PM
Oh, so servmain.c is a part of each plugin ... Gotcha. I do see that via 'nm' - thank you!

(EDIT I had thought it was a shortened form of _mod_description which Google had me convinced was more of a canonical symbol.)

01-01-2015, 07:13 PM
Matt made plugin searching LScript plugins: http://www.pixsim.co.uk/lightwave_lscripts.html (thanks to http://forums.newtek.com/showthread.php?131626-Apple-like-Spotlight-search-for-ALL-functions-in-Layout-amp-Modeler-(ADD-THIS-TO-11-5)&p=1280961&viewfull=1#post1280961)

It scans CFG files for each application Layout, and Modeler. Going to try it in a sec.