Results 1 to 8 of 8

Thread: Python access to node data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Evil_Alan's Avatar
    Join Date
    Feb 2018
    Location
    USA
    Posts
    7

    Python access to node data

    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?

  2. #2
    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...ith-example%29
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  3. #3
    Registered User Evil_Alan's Avatar
    Join Date
    Feb 2018
    Location
    USA
    Posts
    7
    Quote Originally Posted by Ryan Roye View Post
    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...ith-example%29
    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.

  4. #4
    Ryan,

    Do you have an example of writing and importing envelope files?
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  5. #5
    Quote Originally Posted by ernpchan View Post
    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.
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  6. #6
    Quote Originally Posted by Ryan Roye View Post
    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?
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  7. #7
    Quote Originally Posted by ernpchan View Post
    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
    
    '''
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  8. #8
    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.
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •