PDA

View Full Version : Plugin "Scan Folder" and Python scripts?



jeric_synergy
05-14-2014, 06:56 PM
I just went to use Quick_Clone.py which is in the path

E:\Program Files\NewTek\LightWave11.6.3\support\plugins\scrip ts\Python\Layout\Generic\Quick_Clone.py

IOW, my normal plugin path. Layout said "not found", so I re-scanned the folder, and it STILL doesn't find it.

Does the folder SCANNING function not work for Python scripts? :alien:

(Obviously, I'll ADD the script manually, but I'd like to know.) :chicken:

jeric_synergy
05-14-2014, 07:08 PM
the plot thickens....

The actual error is "Cannot load external plugin file: blah blah blah...". This is the NATIVE plugin. However, Celshader's version of Python QuickClone works dandy.

So, could someone PLEASE test the LW3dG python Script "Quick_Clone.py" to check its functionality?

ernpchan
05-14-2014, 07:10 PM
There might be a problem with the contents of the py file which define if it's a proper LW script.

Tranimatronic
05-14-2014, 07:22 PM
I will take a look when I get to my home machine, but there appears to be a space in the filename which may kill it.
Of course it may be a typo, but thought I would point it out ;)
scrip" "ts :
"pport\plugins\scrip ts\Python\La"

jeric_synergy
05-14-2014, 07:57 PM
There might be a problem with the contents of the py file which define if it's a proper LW script.
That's a problem, since it's a LW3dG script!

Tranimatronic, that space was an artifact of cutting and pasting, doesn't actually exist. Good eye, though.

jeric_synergy
05-15-2014, 09:36 AM
More observations:


"Quick_Clone.py" DOES run from the Python button in Layout, but does NOT run from a button added to the UI which directly invokes it.

But Celshader's "QuickClone.py" (no underscore) runs from a button fine.

I have no idea what the implications are here. :stumped:

ernpchan
05-15-2014, 09:44 AM
Are there discrepancies in the server tag lines?

jeric_synergy
05-15-2014, 11:11 AM
Me no knowee what this "server tag lines" am you speak of.

Anybody else use this plugin? Jen's version is super convenient: "insta-clone" would be a good description of it.

Anyway, shouldn't using "Python" (the button) be the same as making a button on the UI that directly invokes the script? Or does "Python" and the UI use, ummmmm, different 'servers'???

https://fogbugz.newtek.com/default.asp?70427_cffoc5qtmip32198

Tranimatronic
05-15-2014, 11:39 AM
...sorry. Was going to look last night. Instead sleep got in the way. Will TRY to remember tonight

jeric_synergy
05-15-2014, 12:28 PM
No worries: it's been fogbuzzed, it may just be MY system (see the g.d. HUB thread....) and it ain't gonna get fixed overnight anyway.

It's pretty peculiar/puzzling, what with the added info/behaviour above. SHOULD work: doesn't.

Especially puzzling in that it's an LW3dG script. :(

jeric_synergy
05-15-2014, 12:36 PM
Are there discrepancies in the server tag lines?
:sigh: Man, I'd sure like to USE lightwave instead of writing bug reports ALL THE TIME.

At least when I was a beta-tester I got a tiny bit of compensation.

I don't read Python but: here's the Python code for THE ONE THAT WORKS:




import lwsdk

__author__ = "Jennifer Hachigian"
__copyright__ = "Copyright (C) 2012 Jennifer Hachigian"
__version__ = "1.0"
__maintainer__ = "Not Me"
__email__ = "[email protected]"
__status__ = "Production"
__lwver__ = "11"

class QuickClone(lwsdk.IGeneric):
def __init__(self, context):
super(QuickClone, self).__init__()

# LWGeneric -------------------------------------------
def process(self, ga):
lwsdk.command("Clone 1")
return lwsdk.AFUNC_OK



ServerTagInfo = [
( "Python QuickClone", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "QuickClone", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]

ServerRecord = { lwsdk.GenericFactory("LW_QuickClone", QuickClone) : ServerTagInfo }


And here's the one that doesn't work:




#! /usr/bin/env python
# -*- Mode: Python -*-
# -*- coding: ascii -*-

"""

Creates a single clone of the selected item.

usage: assign this script to a hotkey for a faster cloning/moving workflow in Layout.

tip: this script uses the single-shot formatting introduced with LightWave 11.5.
See "anatomy.html" in the SDK's lwpython documentation for more information.

tip: this script executes the Clone command. For a list of more commands, see the
"commands.html" file in the SDK.

"""

import lwsdk

__author__ = "Jennifer Hachigian"
__date__ = "Aug 29 2013"
__copyright__ = "Copyright (C) 2013 NewTek, Inc."
__version__ = "1.0"
__maintainer__ = "Jennifer Hachigian"
__email__ = "[email protected]"
__status__ = "Utility"
__lwver__ = "11"

lwsdk.command("Clone 1")

ernpchan
05-15-2014, 12:51 PM
Yeah, there's no ServerTag info in the one that doesn't work...so while you can run it as a one-off python command, it won't get added as a proper button. LW doesn't see it as a plugin that can be added to the environment. That's what the ServerTag stuff does. If you watch BigHache's python vids he explains this.

So it's not so much that the scripts are broken, one is just not formatted to be added as an actual button.

I don't believe lscript had this problem. With python we're going to get more control but at the cost of ease of coding imho.

jeric_synergy
05-15-2014, 01:06 PM
Thanks for looking into that ernpchan. So, everything in the brackets is the server tag? (It certainly looks that way.) Will just plopping that bit in make it, ummm, "buttonable"?

I'm a little disappointed in Jennifer-- she wrote them both, so why is the one included in the official distro so lame?

ernpchan
05-15-2014, 01:13 PM
This is what's needed to make it a proper button/plugin entry.


ServerTagInfo = [
( "Python QuickClone", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "QuickClone", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]

ServerRecord = { lwsdk.GenericFactory("LW_QuickClone", QuickClone) : ServerTagInfo }

But it's not just a matter of copy pasting this exact text. The names have to be relevant to your python code. If you pick through the code you'll see which text in the ServerTag is the same as what's in the Class code.

The first example has everything wrapped into a Class. The 2nd example is just executing a command. I believe you need to wrap your code into a Class to properly use the ServerTag.

I'm still trying to get my brain wrapped around python so I might be wrong but that's my understanding of it.

I can't speak for celshader. Part of it may be as an example of what's possible. The python implementation is still relatively new so it may just be the byproduct of the discovery process.

jeric_synergy
05-15-2014, 05:49 PM
This issue got attention from Deuce Bennett and Jennifer Hachigian (Celshader). She was using something called the "single shot" format, which may explain both the difference in code and why one worked and the other didn't.

In the course of full characterization of the issue, I nuked my LW11EXT-64.cfg file, and that seemed to correct whatever was wrong. Since I've been doing full scans of plugins frequently, apparently plugin scans alone will not correct an error in that config file.

At this point (I've learned to be cautious) it seems that this issue is addressed, --although once again I'm baffled how much trouble a bad config file can cause.