Results 1 to 9 of 9

Thread: How to edit surfaces in layout (with example)

  1. #1

    How to edit surfaces in layout (with example)



    I figured this is information people might want, so i'm providing a sample script with scene file. Modifying plugins and surface data must be performed through a combination of:

    1) Commands which produce a text file with plugin/surface data (Example: lwsdk.command("Surf_LoadText C:\\mytextfile.txt")
    2) Having the script edit (or replace) those text files through parsing
    3) Commands which load a text file onto a target plugin entry or surface (Example: lwsdk.command("Surf_SaveText C:\\mytextfile.txt")

    The RR_PBR_Surface_Setup.py contained within the zip file will look for files containing key words like "Diffuse" or "Metallic" and automatically set up the nodes on the selected surface. It will save a surface file to the same directory the plugin is run from. Note that this plugin works off of the location of the scene file loaded to find the images and assumes a standard folder structure.
    It serves as an example as to how you can avoid having to work in the node editor through scripting. Feel free to pick apart and modify this script to suit your needs.

    RR_PBR_Script_Example.zip
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Image4.jpg 
Views:	380 
Size:	52.0 KB 
ID:	146429  
    Attached Files Attached Files
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  2. #2
    Super Member JohnMarchant's Avatar
    Join Date
    Mar 2003
    Location
    Murcia, Spain
    Posts
    3,173
    Thanks very much Ryan.
    Dell XPS 15
    15.6-inch (3840 x 2160) 4K 282ppi IPS LCD
    Intel i7 7700HQ 2.8GHz
    Windows 10 64Bit
    NVidia GeForce GTX 1050
    1TB SDD
    32Gb Ram

    LightWave 2020

    Very nice Laptop

  3. #3

    Neat! 

    note, .py opens in Notepad++
    or open in regular Notepad if you are really-really hardcore.  
    LW vidz   DPont donate   LW Facebook   IKBooster   My vidz

  4. #4
    Frequenter
    Join Date
    Sep 2003
    Location
    Munich
    Posts
    507
    Cool. Thanks for sharing, Ryan! :-)
    ______________
    lorenz

  5. #5
    Registered User dlvphoto's Avatar
    Join Date
    Feb 2018
    Location
    Atlanta, GA
    Posts
    33
    This helps me tremendously in my attempts to write a linker between Quixel Bridge and LW. ***thank you***.

  6. #6
    Registered User Oldcode's Avatar
    Join Date
    Jan 2004
    Location
    Boston
    Posts
    474
    Ryan,

    Very cool!

    Is this the same basic idea of the old Surface file from 2015 and previous?

  7. #7
    No. Starting with LW 2018, the SDK for lightwave gained a few key commands that allows deeper access to data:

    - Enables the user to extract, parse, and write information regarding surfaces, including node connections, envelopes, etc. NOTE: These commands operate relative to the currently selected surface (or the first surface is none is selected). You can manipulate the surface selection through python.
    Surf_LoadText "filename" (filename must be in quotes)
    Surf_SaveText "filename"

    - Enables the user to extract, parse, and write information regarding motion modifiers, item shapes, geometry modifiers, etc.
    SaveServerDataByItemID <itemid> <class> <index> <optional_format> "filename"
    LoadServerDataByItemID <itemid> <class> <index> <optional_format> "filename"

    So, essentially you extract a text file which contains all the information about a surface or plugin, make changes to that data, then re-apply it. Granted, this is very similar to just parsing the scene file itself, the major exception to this is the fact that you can inject changes into the scene *without* needing the user to reload the scene entirely.
    Last edited by Ryan Roye; 01-06-2020 at 08:21 AM.
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  8. #8
    Registered User Evil_Alan's Avatar
    Join Date
    Feb 2018
    Location
    USA
    Posts
    7
    Nice!



    Also, I decided to test it out...
    https://github.com/TheRoyalDudeness/...ster/Lightwave


  9. #9
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,970
    Quote Originally Posted by Ryan Roye View Post
    - Enables the user to extract, parse, and write information regarding motion modifiers, item shapes, geometry modifiers, etc.
    SaveServerDataByItemID <itemid> <class> <index> <optional_format> "filename"
    LoadServerDataByItemID <itemid> <class> <index> <optional_format> "filename"
    The main issue with these APIs is that Newtek devs still need to publish the "official dictionaries" (as #defines/consts, enums, or whatever) for the various built-in servers. While spelunking existing scenes can get you data for some of these, the problem is that it's unclear how the classes & indices are tied to different versions of feature APIs/systems. Without some sort of official, versioned dictionary/manifest for how the classes and indices values associate with servers, relying on experimental observations is risky. Likewise, without understanding what feature/SDK version assignments apply to which classes/indices, currently there's no easy way for third-party code to detect whether (when, really) those LW server relationships change.

    It's nice that they exposed it, but it's still kind of "half-done" w.r.t. LW native servers, and they need to "finish it up." I kind of get the impression they hurried it out so key third party devs could use with their servers (since third-party devs control those relationships for their servers, they're responsible for maintaining and publishing that info for their plugin servers' classes/indices).

    From the sounds of it, they did something similar with attributes, exposing the APIs for Viktor to use on his stuff because he needed them (perhaps other third-party devs as well), but not yet exposing/publishing the enumerations and version associations for how LW native entities define their attribute relationships.
    Last edited by jwiede; 06-08-2020 at 04:16 PM.
    John W.
    LW2015.3UB/2019.1.5 on MacPro(12C/24T/10.13.6),64GB RAM, NV 980ti

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
  •