Mat Preset to Change ONLY Colors on a Blender Node?



  • @karina at first glance, your link took me to a different thread, but I registered, found the thread I thought was being linked to, and posted a reply there anyway. I'll repost what I said there for visibility here, since cross-platform differences need to be highlighted.

    [What I said there in response to using subprocess.call():] [[GRRR, indenting won't preserve blank newlines or any formatting]

    I've had some experience with trying to emulate runPythonScript calls within a Poser file parser. My results for macOS indicate:
    .
    #scriptError = subprocess.call( [ script ] ) # Permission error
    #module = import( script ) # Import by filename not supported
    .
    so I ended up using:
    .
    module = imp.load_source( scriptName, script )
    .
    which seems to execute python scripts correctly, without the permission or not supported errors of the two previous methods I tried.

    I'd really like to see the pop-up manual on library click working! The xml data, if people bother to A) fill it in, and B) users make it visible, can be very helpful too, but a full manual for a product being only a click away, without having to leave Poser, would be a Godsend!



  • @anomalaus
    I just posted a lengthy reply over there, please try whether that version works.

    The general principle has proven as valid.
    It will be in my new freebie set "Mirror Mirror" and it's working fine right now in Windows.
    K
    0_1537171581200_Mirror Mirror Manual.png



  • @karina when I'd remembered to change the ":TheSetName:TheManualFolder:" to ":My New Freebie:Manual:" in Manual.cm2, which matched the location of where I'd placed the .cm2 and .png, thus getting rid of the:
    0_1537175506119_Screen Shot 2018-09-17 at 7.05.45 pm.png
    due to it not finding the Manual.py file [forehead slap]
    I get nothing.

    I was initially sure that this was because subprocess.call() relies on the OS to decide how to handle the file, so .pdf gets opened by some Adobe product and .html will get opened by the default internet browser. However, imp.load_source() being purely Python internal (import), is designed for loading python scripts, so the OS would never get asked what to do with the file. Python would simply parse it and fail to find anything it can execute (being html) and thus do nothing.

    This was my misunderstanding of what you would do with the subprocess.call(). You're not trying to execute another python script, which the macOS version (at least) of Poser Python has protections against, you're just trying to get the OS to open a file. So, back to why nothing is working for me.

    Double click the library icon. Poser's foot-tapping cursor is engaged, so it looks like it's running the script. I still get nothing.

    But then, I'm not doing any checking of the return value to find out if or why the imp.load_source() or subprocess.call() might have failed. Trying an os.system('open {}'.format(fullpath)) gives nothing either, so I tried a subprocess.call(['open',fullpath]). Same story, but, again and still, I'd not checked what the return values might have been silently trying to tell me, so I tried a print subprocess.check_call(['open',fullpath]) and it returns 1 (an error) and says:

        print subprocess.check_call(["open", fullPath])
      File "/Applications/Poser 11/Poser.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 511, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['open', u'/Volumes/HiggsBosonHD/Poser Content/Poser 11 Content/Downloads/Runtime/Data/! Aleks Props/My New Freebie/Manual\\Manual.html']' returned non-zero exit status 1
    

    So now I can see that the path assembly is broken for posix paths. After the accustomed forehead slaps, it's obvious that rather than :

    fileName = "Manual.html"
    backSlash = "\\"
    scriptPath = os.path.dirname(poser.ScriptLocation())
    fullPath =  scriptPath + backSlash + fileName
    

    we need:

    fileName = "Manual.html"
    scriptPath = os.path.dirname(poser.ScriptLocation())
    fullPath =  os.path.join(scriptPath,fileName)
    

    which will account for any os style of path separators, without having to manually handle them and remember which works what way.

    Now, my Hello World.html gets opened in Firefox, as I would expect, so the final script can actually do away with a specific posix test, and just do:

    import poser, os
    fileName = "Manual.html"
    scriptPath = os.path.dirname(poser.ScriptLocation())
    fullPath =  os.path.join(scriptPath,fileName)
    if os.name == "nt":
    	os.startfile(fullPath)
    else:
    	import subprocess
    	subprocess.call(["open", fullPath])
    


  • This post is deleted!


  • There's still something fishy going on.

    import poser, os
    fileName = "Manual.html"
    scriptPath = os.path.dirname(poser.ScriptLocation())
    fullPath =  os.path.join(scriptPath,fileName)
    print scriptPath
    print fullPath
    if os.name == "nt":
    	os.startfile(fullPath)
    else:
    	import subprocess
    	subprocess.call(["open", fullPath])
    

    When I execute this code (notice the "print" commands for checking paths) I get:

    E:\SASHA-16 LIBRARIES\SASHA-16 v.05-08-17\runtime\Data\! Aleks Props\Mirror Mirror\Manual
    E:\SASHA-16 LIBRARIES\SASHA-16 v.05-08-17\runtime\Data\! Aleks Props\Mirror Mirror\Manual\Manual.html
    Traceback (most recent call last):
      File "E:\SASHA-16 LIBRARIES\SASHA-16 v.05-08-17\runtime\Data\! Aleks Props\Mirror Mirror\Manual\Mirror Mirror Manual.py", line 8, in <module>
        os.startfile(fullPath)
    WindowsError: [Error 2] The system cannot find the file specified: u'E:\\SASHA-16 LIBRARIES\\SASHA-16 v.05-08-17\\runtime\\Data\\! Aleks Props\\Mirror Mirror\\Manual\\Manual.html'
    

    As you can see the paths are retrieved and joined correctly.
    Then look at the "path" in the error message:
    There's a strange "u" in front of the path, and all backslashes are duplicated...
    This is Windows XP 64bit, PP2014.

    Weird.
    K



  • @karina

    Belay my last post !!1!
    I had the html file name wrong ("Manual.html" instead of "MirrorMirrorManual.html")
    ( --> Definitely too many Mirrors in this thing XD )

    Now it works like a breeze.
    Problem solved!
    :)

    Thank you and all others for the help!
    This is the second best thing since the invention of sliced bread:
    Have a help file right at your fingertips, in the Poser Library!

    K

    P.S.:
    I still prefer my help files written as html:
    One of the biggest advantages (and why I stick to the html format) is the option to link.
    A link can branch to a paragraph in the same help page, open another help page, or even a URL in the www (like, for linking back to a forum, or a download site, or whatever.
    Think of the possibilities!
    K



  • @karina said in Mat Preset to Change ONLY Colors on a Blender Node?:

    I still prefer my help files written as html:
    One of the biggest advantages (and why I stick to the html format) is the option to link.
    A link can branch to a paragraph in the same help page, open another help page, or even a URL in the www (like, for linking back to a forum, or a download site, or whatever.
    Think of the possibilities!

    That definitely makes sense, and I have several products that use html format for the help docs (including your super helpful manual for SASHA-16). I also have the web design skills to make an inter-linked html manual for offline use. In fact, since I have several of my own domains, I could even put most of the help docs online so that they could easily be updated (to live up to my username!!)

    However, I personally prefer to have all help docs in PDF format, and here's why: so I can highlight passages and take notes directly on them (using Preview's annotation tools--Preview is the macOS default PDF app). I even saved several chapters of your SASHA-16 manual as PDFs for that very reason.

    So that's why I've been inclined to provide help docs that need screenshots (i.e., not just text) as PDFs with my freebies. But if more users would prefer help docs in html format, I'd do that instead. Actually, I suspect most users would probably prefer to be able to open help docs from within Poser's library, whatever format those help docs are in, so I'm willing to provide those docs in whatever format is most easily opened by your Python script!



  • @karina PS: I can only get to your SASHA-16 forum about once for every 10 times I try to. The other times I get this error message:

    0_1537403001662_Safari-Error-KarinasForums.png

    Just wanted to let you know why I haven't followed up on anything you might've posted in the WIP color change script thread!



  • Sorry for your problems with my site, but "forumprofi.de" was the only site I found which was free, let me choose my forum style, and also allow uploading of attachments other than just pictures (like Poser .pz files and archives, which was paramount for me!)

    It also could be configured to "English" language so you can use it without having to learn Russian/Ukrainian :D
    (and don't think that signing up for a free forum is just vanilla with a Ukrainian IP, and many even deny the useage of TOR to obfuscate my real IP)

    Nevermind, back to the script:

    I'll post it this weekend at ShareCG, so watch their new stuff (POSER category)

    There will be two runtimes in the download:

    • one for you (and other content developers) containing all neccessary files and manuals you need to set up the textures.
    • one to include in your product (for your customers), containing only the basic files and a basic manual how to use it.

    My idea is that you include the "Set Colour" gadget in your product "as is", and provide a link back to the "Set Colour" gadget's page at ShareCG so that your customers can grab any updates to the script on their own.

    NOTE:
    The "Set Colour" gadget and all files that come with it will be "public domain", so you can use it without any restrictions, even if included in commercial product!

    If you have questions, just ask.

    Karina

    *Footnote 1:
    I didn't test all file types



  • Oups!

    Looks like tonight I'm having problems:
    I can't upload to ShareCG because they keep telling me"there were errors with the upload" or some such.

    So I'm afraid you have to go to SASHA's site again:
    http://sasha-16.forumprofi.de/showthread.php?tid=93&pid=635#pid635

    That's all I can offer you for now until I get the upload at ShareCG sorted out!

    Hope it helps a little?

    Karina



  • Additional Promo Image posted as a separate post due to the ridiculous "Edit Post" limitations:
    0_1537656532000_Promo.jpg
    http://sasha-16.forumprofi.de/showthread.php?tid=93&pid=635#pid635



  • OK, ShareCG had some server hickups yesterday, but today it was fixed:

    https://sharecg.com/v/92298/view/11/Poser/Karinas-Batch-Colour-Gadget-MR

    Many thanks again to all who contributed in the making of this tool, especially to @perpetualrevision for having had the initial idea!

    Karina



  • @karina Awesome! Thanks! <3