Results 1 to 4 of 4

Thread: Single-shot Python script to set content directory and custom paths in Layout

  1. #1
    Red Mage Celshader's Avatar
    Join Date
    Feb 2003
    Location
    Burbank, California
    Posts
    1,817

    Single-shot Python script to set content directory and custom paths in Layout

    An artist asked if it was possible to use LWPython to set both the content directory and custom paths in Layout and Modeler. I am not yet sure about Modeler, but I have a single-shot script that sets custom paths in Layout.

    In this script, LWPython sets the Layout content directory to "C:\Temp\Content", the default Objects directory to "Meshes," and the default Images directory to "Plates."

    Code:
    import lwsdk, os
    
    ## this version places all of the variables up here for easier editing.
    contentDir = "C:\\Temp\\Content"
    objectsDir = os.path.join(contentDir, "Meshes")
    imagesDir = os.path.join(contentDir, "Plates")
    
    ## single-shot formatting:
    ga = lwsdk.GenericAccess()
    
    ## turn off "Use custom paths" to "clean out" the old custom directories
    ga.evaluate("UseCustomPaths 0")
    
    ## change the Content Directory.
    ga.evaluate("ContentDirectory " + contentDir)
    
    ## turn on "Use custom paths" to enable fresh, new custom directories
    ga.evaluate("UseCustomPaths 1")
    
    ## change only those directories that you like. The rest will remain at LW defaults.
    ga.evaluate("ContentTypeDirectory Objects " + objectsDir)
    ga.evaluate("ContentTypeDirectory Images " + imagesDir)
    
    ## tell the user what you've done.
    title = "Done."
    message = "Changed content directory to: " + contentDir
    mf = lwsdk.LWMessageFuncs()
    mf.info( title, message )
    Jen's 3D -- LightWave stuff.
    Jen's 2D -- my comic book.

    Python is my smashing board. LightWave is my S.M.A.K.

  2. #2
    Super Member nickdigital's Avatar
    Join Date
    Nov 2006
    Location
    Burbank, California USA
    Posts
    4,576
    Very cool!

    My opinions and comments do not represent those of my employer.
    Profile piece
    2010 Reel
    'The X's' Reel

  3. #3
    Kamehameha Chameleon BigHache's Avatar
    Join Date
    Sep 2006
    Location
    Future Past Life
    Posts
    1,899
    Thanks Jen.

  4. #4
    Jen did you ever figure out a way to do this in modeler? I have been banging my head against it as of late.

    thanks

    also for anyone that uses Generation, This will connect to generation and get the open project and change your content directory to it. I'm trying to do the same for modeler but haven't figured out the correct command, maybe even put it as a startup command so as you startup, it will see if generation is running and just set it for you. of course change to match your file structure, and tab in the if statement.

    import lwsdk, os
    import sys
    sys.path.append('c:\\Python27\\Lib\\site-packages')

    import PeyeonScript as eyeon

    gen = eyeon.scriptapp("Generation")
    if gen != None:
    proj = gen.ProjectGet()
    projectName = proj.Path
    contentDir = projectName + "LW\\"
    lwsdk.command("ContentDirectory " + contentDir)
    Last edited by wellsichris; 02-21-2014 at 04:02 PM.
    illuminatedtools.com My great light probe Library.

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
  •