Kryslin's lScripts

Kryslin

Active member
Things I have discovered about coding in Python:
-You will discover new and horrific ways to crash Lightwave... at least 6 times before lunch on the first day.
-You will discover new and creative ways to curse as you struggle with a number of issues in the python SDK.
-You will spend a third of your time putting in and taking out print statements so you can tell where you plugin is crashing.
-You will spend another third of your time looking for ways to code things.
-You will spend time that you're not coding digging out the hidden secrets of the Python SDK. And there is a lot of them.
-And when you finally get a project converted to Python, you'll have a very good night's sleep, until you start on the next project. :)

I'm currently working on the last two modeling tools - Style Combing, and SubD corners.
Style combing has got everything up to a working UI, but no actual combing.
SubD corners will be easy in comparison.

Then comes the layout scripts... Symm. Bone Weight Assignment and Build Null Object.
Ah, I love the smell of fresh new levels of hell...

- - - Updated - - -

Things I have discovered about coding in Python:
-You will discover new and horrific ways to crash Lightwave... at least 6 times before lunch on the first day.
-You will discover new and creative ways to curse as you struggle with a number of issues in the python SDK.
-You will spend a third of your time putting in and taking out print statements so you can tell where you plugin is crashing.
-You will spend another third of your time looking for ways to code things.
-You will spend time that you're not coding digging out the hidden secrets of the Python SDK. And there is a lot of them.
-And when you finally get a project converted to Python, you'll have a very good night's sleep, until you start on the next project. :)

I'm currently working on the last two modeling tools - Style Combing, and SubD corners.
Style combing has got everything up to a working UI, but no actual combing.
SubD corners will be easy in comparison.

Then comes the layout scripts... Symm. Bone Weight Assignment and Build Null Object.
Ah, I love the smell of fresh new levels of hell...
 

Kryslin

Active member
Every little bit does, thank you.

Update on updates...
I now have a version of style comb that doesn't crash modeler straight to desktop (and doesn't crash under normal usage), and actually does something vaguely resembling the original! That's an improvement over where I was Last time, since I was crashing straight to the desktop. a lot of print statements, carefully inserted return lwsdk.AFUNC_OK's, and break statements. and I got something working. Now. it's a matter of refining the algorithm so that I get the same results (or nearly the same) as the Lscript...

You get spoiled working in lscript, since there is far more consistency in what gets returned by functions. You can do far more with python, but things get convoluted fast.
 

Kryslin

Active member
Style Comb for Python has passed the unit test phase, and has passed the tests on my test article shapes.

I'll be digging up the melody mesh and seeing what results come out.

This has the following features:
- Fiber length, fiber curling, and sleekness are all controllable by weight maps
- You can use parts and surfaces for what gets combed, plus you can use a point selection for what to comb away from as well.
- It's much faster than the LScript version. On my test article object, about 3x faster.
- It shouldn't be too hard to convert over to Python 3 when required, as it was written with that in mind.

Frustrations encountered:
-Indentations. One misplaced indentation, +/-, and you can not only crash llightwave, you can crash Windows.
-Included modules for making the transition from LScript to Python easier... don't.
-Lack of documentation : the lwsdk.Vector class, the lwsdk.EDPoint/Edge/PolygonInfo classes, the lwsdk.Panels/Panel/Control classes are ALL undocumented in the Python SDK. They are all kinda necessary to writing modeler plugins.

End result:
I'm not looking forward to doing my Build Null Object and Symmetric Weight Assigner scripts.
 

Kryslin

Active member
There will be an update rolling out on Saturday; I have all my released modeler scripts converted to Python. ~yay!~

Now, I'm learning (the hard way) about modal panels in layout. Symm. Weight Assignment is coming along nicely; The UI is done, the correct callbacks get called, and I've found out just how useful the user_data block on the panel can be - you can use it to store data you need to pass between callbacks. Also, for some reason, you lose instance variables on panels opened with the lwsdk.PANF_NOBUTT flag; essentially the script executes and completes, leaving the panel open. Everything has to be doen via callbacks, and anything you need to do when you close the panel has to be handled in the close callback. However, loss of globals and instance variables makes it kind of hard to do things like use recall and store for parameters...
 

There will be an update rolling out on Saturday; I have all my released modeler scripts converted to Python. ~yay!~

impressive!
 

Kryslin

Active member
The website has been updated. I'll get the entire collection zipped up when the last two scripts for layout are converted.

Build Null Objects will be a monster, because of the com ring. Symmetric Weight Assignment is being difficult in the UI department, while the code to handle everything is relatively simple.
 

fuzzytop

Member
Looking forward to When everything’s complete … I hope to have a project to use your new scripts on later this Fall.

Right now grinding away on VFX … non-CG stuff…
 

Kryslin

Active member
Okay...

Slowly slogging forward; I've got store/recall working on a modal script, so Symmetric Weight Assignment is moving forward again (A generic access script with no OK/Cancel buttons).

Also, thanks to some applied reverse engineering skills, I can now apply item shapes to nulls without mucking around with the comring. I even know how to modify existing setups. So, BuildNullObjects3 is moving forward, meaning I'm coding the most crowded UI I've made on something, and trying to find ways to streamline it.
 

Kryslin

Active member
BuildNullObject3 has been converted to Python, and everything appears to work.

Last one on the list is Symm. Weight Assignment, and it's half done.
 

Kryslin

Active member
...And symmetric weight assigner is done.

What's it do? given a set of tags for left and right bones & weights, it assigns bones with the left/right tag to weights with a left/right tag.
It moves up and down the hierarchy, assigns the weights to the bones, advances to the next or previous unassigned bones,and assigns weights and advances to the next bone.
And... No OK/Cancel button. :) When you're done, simply click on the [X] (close window) icon, and it saves your tag settings.

UI like that are a pain to write and work with, but I learned a lot. I'll update the archives with the layout tools in a bit.

I think I have a few more of the curve tools to write, and a .cfg file for menus to do as well...
 

Kryslin

Active member
Python does run much faster; Style Comb in lscript take 4-5 minutes to process the Melody character mesh from Daz3D, which is about 60K polygons. Under Python, about 20 seconds. My code could stand to be optimized, a lot.

There are also some things you can do - like get the weight map that is assigned to a bone, or easily delete a vertex map - that you can't do in lscript at all. With both python and lscript, you can still crash lightwave to the desktop, though.

There are some problems; certain classes are not documented in the SDK; you learn how to make a UI by dissecting the code of some of the included scripts, or use a UI builder to do most of the heavy lifting. Good luck doing anything with the built in vector math class; no documentation there either. I've found several instances of spotty documentation, lack of return values, system variables that are wrong, etc. (I have reported such as I find them.)

Kind of a mixed bag.
 

Kryslin

Active member
I was looking through the C SDK, looking for something (I know I had seen something that would convert a set of Axis vectors into H,P,B angles), when I came across something;

the LScript deprecation doesn't affect just LScript; Any C/C++ plugin that uses the LScript system to generate it's interface will need a rewrite as well (like the LSUR.C example in the SDK)
 

Kryslin

Active member
I was playing around with Kanuso's excellent python UI editor for the last couple of days, and figured I'd drop the results of this here...

View attachment RhiggitSkeleton.zip

A few notes:
-This is the UI Only. It does nothing but look pretty. The hooks are all there, though...
-This is not any indication that Rhiggit is moving to Python. I did this as a proof of concept.
-I am not going to go through the process of reverse engineering Rhiggit 2. I don't have the time.
-This isn't indicative of a future version of Rhiggit, unless Mr. Monins decides to make it so.
-I do have most of the bits and pieces to make a functional plugin; I have several working modules of little things, like adding item shapes, setting motion options, etc., but nothing is tied together. This will not happen, unless RH says go for it.
-This was tested in LW2018.0.7, 2019.1.5
-This is very much a WIP. For instance, the preferences tab and library tab are fairly sparse, while the Face tab is PACKED.
-I'll take suggestions for what should go on the library and preferences panel.
-This is not, in anyway, something official. I'm just showing what can be done.
 

Kryslin

Active member
I'll get it fixed. Between writing, physical therapy, and being sick (Not Covid, I picked up peri-orbital cellulitis somewhere...) I should be able to update the link. Thank you for the head's up.
 
Top Bottom