......but I'm having such a problem finding anything in the SDK docs about this.
How do you simply load an object into layout using Python?
Working on something and this is my last stumbling block.
Thanks
TheMightySpud
......but I'm having such a problem finding anything in the SDK docs about this.
How do you simply load an object into layout using Python?
Working on something and this is my last stumbling block.
Thanks
TheMightySpud
I'm no Python expert, but I would say you want to use a LightWave command through Python. Check the SDK docs for Loading and the Command List...
B
Ben Vost - NewTek LightWave 3D development
LightWave 3D Trial Edition![]()
AMD Threadripper 1950X, Windows 10 Pro 64-bit, 32GB RAM, nVidia GeForce GTX 1050Ti (4GB and 768 CUDA cores) and GTX 1080 (8GB and 2560 CUDA cores) driver version 430.86
AMD FX8350 4.2 GHz, Windows 7 SP1 Home Premium 64-bit, 16GB RAM, nVidia GeForce GTX 1050Ti (416.34, 4GB and 768 CUDA cores)
Dell Server, Windows 10 Pro, Intel Xeon E3-1220 @3.10 GHz, 8 GB RAM, Quadro K620
Laptop with Intel i7, nVidia Quadro 2000Mw/ 2GB (377.83 and 192 CUDA cores), Windows 10 Professional 64-bit, 8GB RAM
Mac Mini 2.26 GHz Core 2 Duo, 4 GB RAM, 10.10.3
This is petty much my problem, I'm finding the docs to be absolute garbage, I've been through numerous times and can't see anything to do with loading an object. :-/
in the SDK html "commands" folder, layout.html
->Object,
LoadObject sfilename
Also in Layout/Utilities/ a "Save Cmd List" button will save a file with all available commands.
There are several sample python scripts in Generic folder,
for examples of Command synthax.
Denis.
I've been looking at the LoadObject command but can't for the life of me figure it out. Might be just tired. Giving up for today.
In support/scripts/Python/Layout/Generic
there's a Add_Null/py script, good template for beginning,
see how the AddNulll command is handled.
Denis.
there's also a Proxi with PRIS (see the online Lightwave Python doc)
lwsdk.pris.layout.cs.loadobject(filename)
lscript has also a proxy, this is even simpler, except the double backslash,
@warnings
@name "Load Object"
generic
{
LoadObject("D:\\3D\\LWContent\\Objects\\Box.lwo");
}
Denis.
It appears that you have to go through the following steps:
(This is taken from the 'add_scene_comment.py' example.)Code:import lwsdk def process (self, ga) name = "myfilename.lwo" result = ga.evaluate(ga.data, "LoadObject %s" % name)
or something similar.
you could also use the (much maligned) PRIS, which has a proxy for the LoadObject command...
Code:lwsdk.pris.layout.cs.loadobject(filename)
--------
My Scripts for Lightwave
Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.
This is now driving me insane. I've tried both of the solutions provided by Kryslin, but still not doing anything. I'm not getting any errors, but the scripts don't load in the object.
I'm probably doing something really silly wrong.
Here's the 'non-pris' version of the script.
Can anybody see where I'm going wrong? :-/Code:#! /usr/bin/env python # -*- Mode: Python -*- # -*- coding: ascii -*- """ This is a LightWave Generic plug-in that adds a new Null object and positions it at <0, 1, 0>. """ import sys import lwsdk class Load_Object(lwsdk.IGeneric): def __init__(self, context): super(Load_Object, self).__init__() def process (self, ga): name = "F:\StaticModels\Objects\Aset_qkduW_ZTool.lwo" result = ga.evaluate(ga.data, "LoadObject %s" % name) return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Load_Object", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "Load Object", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_LoadObject", Load_Object) : ServerTagInfo }
Thanks
TheMightySpud
I think you need at least the declaration of the __lwver__
Denis.
Also the double backslash because it's a special character.
Denis.
...And finally, the def process should not be indented to def _Init.
Denis.
Hi,
I don't know if this is the solution, but I think your indentation is wrong.
The script does nothing visible... because the "process is declared as a sub-func of __init__
I think it should look like:
Take a deeper look at your filename. in win-based Environments the \ is represented as \\
I hope this helps you any further
Regards,
Kanuso
Last edited by KANUSO; 10-25-2019 at 05:49 AM.
Bookmarks