Jump to content
Sign in to follow this  
forbidden14

Run anaconda env and use settings file generated in PDG

Recommended Posts

Hey All, 

   I'm trying to customize a python settings.json file with int, float, bool, and sting values set up on a Null control with parameter sliders.   I've read in the initial file I want to modify with a Json file, and have matched all the tags with the slider controls.   I'm then collecting the tags into an array called query and trying to replace the original values in the .json with the slider control values.  This is what I have so far (python novice), but I feel like there is a more solid way to do this.   I know I'm not actually storing any files or values, I'm just printing to console for now


import hou 
parentstr = '/obj/geo1/null1'

query = work_item.stringAttribArray("query")
vars = {}
for q in query:
    parmstr = parentstr + "/" + q
    transval = hou.parm(parmstr).eval()
    vars[q] = transval
    if isinstance(vars[q], str):
        strv ='"'+q+'"'+':'+'"'+vars[q]+'"'
        print(strv)
    else:
        strv = '"'+q+'"'+":"+str(vars[q])
        print(strv)

 

There's also one section "animation_prompts" that goes one level deeper and would need some sort of formatting love where I need to indent and put in a few other lines.  

632f61cc295f6_Screenshot2022-09-24155915.thumb.png.7f6fac6f672ab9368d36cb19a3653357.png

632f62bad9cec_Screenshot2022-09-24160348.thumb.png.b8c1ff2bd52a495fc5d9826ae94f5a3b.png

Thanks in advance! 

-Dana 

Edited by forbidden14

Share this post


Link to post
Share on other sites

I've also got another question regarding anaconda envs in python:  

I've hacked my way through the previous part, now I'm trying to load the output "test.txt" file to run as a settings file in PDG.

I've loaded my environment successfully, as I've output the values to work_item attributes.  Now my issue is how do I run an external script in this PDG environment?  I've tried copy pasting the .py file into python script and setting my environments custom python Bin and working directory, but it seems to get held on import cv2 (I've installed in env), even though I've just imported torch successfully.  I've also tried to run a command in a python processor window, which cooks fine, but nothing happens.   

Anybody have any tips for this environment swap?

Thanks in advance!

6331202b99e4b_Screenshot2022-09-25233718.thumb.png.df7207254f95f6d4de7054ea5eb0fca1.png6331203153b88_Screenshot2022-09-25234346.thumb.png.7a369afe04c89753e708d80f41ac1cd3.png

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×