Python access to node data

Evil_Alan

New member
Is it possible?
With a bsdf node material setup I can create and connect all the nodes easily enough, but how would I access Bg Color, Image, Preview, Invert Alpha, Invert Color, Pixel Blending, etc from an Image node?
 

Ryan Roye

Animator
this command:

Surf_SaveText <path>

saves out surface data into a text file which is the only way i'm aware of that you can do this in python. You will then need to parse the data within that text file and make alterations to the flags/fields you want. It isn't quite convenient but its doable.

See my example script in this forum thread if you haven't already, it may help. https://forums.newtek.com/showthread.php/161309-How-to-edit-surfaces-in-layout-(with-example)
 

Ryan Roye

Animator
Ryan,

Do you have an example of writing and importing envelope files?

In the context of surfacing, I do not but the process is exactly the same as anything else as it involves collecting chunks of text, parsing through it, and making decisions on what to do with that data. This is less about Lightwave scripting and more about understanding how to parse through and manipulate text in Python.

With envelope files, you will need to know what envelope you wish to apply and how to access that envelope.
 

ernpchan

Active member
In the context of surfacing, I do not but the process is exactly the same as anything else as it involves collecting chunks of text, parsing through it, and making decisions on what to do with that data. This is less about Lightwave scripting and more about understanding how to parse through and manipulate text in Python.

With envelope files, you will need to know what envelope you wish to apply and how to access that envelope.

Ok so with envelopes it isn't as simple as the SaveMotion and LoadMotion commands in the sdk? I actually have to parse the lws file?
 

Ryan Roye

Animator
Ok so with envelopes it isn't as simple as the SaveMotion and LoadMotion commands in the sdk? I actually have to parse the lws file?

You can access envelope data without any parsing in the LW SDK... but if there is a simple way to take a readily available envelope file and just apply it like the user would through the interface, i'm not sure a direct function exists.

Still, I don't think this is an overly complicated application through parsing. Typically, I determine how the data is actually split, such as by commas, spaces, or otherwise, then use the split function.

Code:
NewData = []
MyList = [
"1 2 3", 
"4 5 6", 
"7 8 9"
]

for x in range(0, len(MyList)):
	NewData.append(MyList[x].split(" "))

print NewData[0] # Gets XYZ coordinates of first entry
print NewData[0][0] # Gets X coordinate of first entry
print NewData[1] # Gets XYZ coordinates of second entry
print NewData[1][0] # Gets X coordinate of second entry

'''
OUTPUT:

['1', '2', '3']
1
['4', '5', '6']
4

'''
 

ernpchan

Active member
Yeah I can do that, was just hoping there was a more direct method. We can do it with motion files. I'll submit a feature request.
 

Evil_Alan

New member
this command:

Surf_SaveText <path>

saves out surface data into a text file which is the only way i'm aware of that you can do this in python. You will then need to parse the data within that text file and make alterations to the flags/fields you want. It isn't quite convenient but its doable.

See my example script in this forum thread if you haven't already, it may help. https://forums.newtek.com/showthread.php/161309-How-to-edit-surfaces-in-layout-(with-example)

It works great!
Actually, once you get the hang of it, it's easier than trying to setup surfaces any other way with Python.
I'll post stuff in your thread; I think it makes more sense.
 
Top Bottom