Results 1 to 6 of 6

Thread: Loading an image map?

  1. #1
    Lightwave junkie stevecullum's Avatar
    Join Date
    Jun 2005
    Location
    Reading UK
    Posts
    3,131

    Loading an image map?

    Does anyone know how to load an image map into the image editor with python?
    I'm trying create a simple modelling script, and would like to apply some textures to it.

    Thanks
    i7 X3930/32GB/Quadro 4000

  2. #2
    Code:
    ## Given a string ("p") containing a file path to an image, the following
    ## attempts to load that image into the Image Editor. It then
    ## returns the name of that image and the image ID.
    
    def loadImage(p):
        IM = lwsdk.LWImageList()
        id = IM.load(p)
        name = IM.name(id)
        return name, id
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  3. #3
    Lightwave junkie stevecullum's Avatar
    Join Date
    Jun 2005
    Location
    Reading UK
    Posts
    3,131
    Awesome - thanks Ernie! Will give this a try tomorrow.
    i7 X3930/32GB/Quadro 4000

  4. #4
    Celshader would really be the one to thank. I just passed along what I found.
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  5. #5
    Lightwave junkie stevecullum's Avatar
    Join Date
    Jun 2005
    Location
    Reading UK
    Posts
    3,131
    In that case 'Thanks Celshader!'

    If I can put together anything that works and is useful, from the information I've been given here and elsewhere, I'll be sure to share it.
    i7 X3930/32GB/Quadro 4000

  6. #6
    Lightwave junkie stevecullum's Avatar
    Join Date
    Jun 2005
    Location
    Reading UK
    Posts
    3,131
    Got a bit stuck again with this. The code snippet worked fine for loading a texture (although I need to find a better path reference than an explicit one - problem for later). Now what I've been trying to figure out is how to set that image in the surface. The functions I have are:

    def loadImage(self,p):
    IM = lwsdk.LWImageList()
    id = IM.load(p)
    name = IM.name(id)
    return name, id

    def setTex (self):
    statefunc = lwsdk.LWStateQueryFuncs()
    objname = statefunc.object()
    surf_func = lwsdk.LWSurfaceFuncs()
    surf = surf_func.byObject(objname)
    texfunc = lwsdk.LWTextureFuncs()
    #print(surf)
    texture = surf_func.getTex(surf[0],lwsdk.SURF_COLR)
    texfunc.layerAdd(texture,lwsdk.TLT_IMAGE)
    #print(texture)

    However my setTex one crashes modeller, because the getTex method is returning 'None' as an ID. I assume this is because is trying to read an active 'T' button in the surface editor? And of course I currently don't have one of those. I looked at the SDK for LWTextureFuncs and I can see there is a 'create' method. But that seems to be if you were trying to use a texture directly within the plugin, where as I want to create one in the main surface editor. Any ideas?

    Thanks
    i7 X3930/32GB/Quadro 4000

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
  •