Jump to content


Variable checking.


  • Please log in to reply
8 replies to this topic

#1 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 11 November 2011 - 10:04 AM

Hi,
For a tool, I am trying to check if a specified variable is correct or not? Is there an expression to ruturn this check?

ex: $MAPU will return "ok", $MAPG (if it does not exist) should return "error"

Any ideas? Thanks.
Live life in chunks!

#2 AdamJ

AdamJ

    Initiate

  • Members
  • PipPip
  • 108 posts
  • Joined: 15-April 03
  • Location:Toronto, Canada

Posted 11 November 2011 - 11:38 AM

hscript..
echo `isvariable ("EXISTS")` returns 1
echo `isvariable ("NOTEXIST")` returns 0

hou.variable in python but doesn't look like it's implemented yet

#3 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 14 November 2011 - 06:52 AM

View PostAdamJ, on 11 November 2011 - 11:38 AM, said:

hscript..
echo `isvariable ("EXISTS")` returns 1
echo `isvariable ("NOTEXIST")` returns 0

hou.variable in python but doesn't look like it's implemented yet

Thanks!
But I could not get it working:

echo `ishvariable("MAPU")` will return 0 ?
Any ideas?
Live life in chunks!

#4 AdamJ

AdamJ

    Initiate

  • Members
  • PipPip
  • 108 posts
  • Joined: 15-April 03
  • Location:Toronto, Canada

Posted 14 November 2011 - 07:14 AM

I think you get an 'h' in there.. but from 'MAPU' I think you're looking for a way to check if there's an attribute rather than a session variable.. have a look at

haspointattrib
hasvertexattrib

echo `haspointattrib("../OUT","uv")`  returns 1 if uvs exist


View PostSymbolic, on 14 November 2011 - 06:52 AM, said:

Thanks!
But I could not get it working:

echo `ishvariable("MAPU")` will return 0 ?
Any ideas?

Edited by AdamJ, 14 November 2011 - 07:15 AM.


#5 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 14 November 2011 - 08:04 AM

View PostAdamJ, on 14 November 2011 - 07:14 AM, said:

I think you get an 'h' in there.. but from 'MAPU' I think you're looking for a way to check if there's an attribute rather than a session variable.. have a look at

haspointattrib
hasvertexattrib

echo `haspointattrib("../OUT","uv")`  returns 1 if uvs exist

Hello AdamJ,
Sorry for the multiple posts. I need to explain this in a better way.

The problem is this:

I have two string inputs on my OTL

(1) Attribute to use:
(2) Component:

So if the user goes "foo" in section (1), then he may specify "FOO1" as the first component in section (2).
I can check both of those conditions, I check if the attribute "foo" exists, then I guarantee that it is mapped and "FOO1, FOO2, FOO3" are valid.

If "foo" does not exist, I flag and error.

* * *

However, lets have a look in a more complex situation as bellow, (Here I need an extra way of variable checking)

So if the user goes "uv" in section (1), then he may specify "MAPU" as the component or "UV1" for the first component

If he miss types MAPU as MAPG for example, the process will fail.

So as you see, I need to check the native Houdini variables towards this. The "h" in there was for that, "ishvariable", is supposed to check the native Houdini variables (I guess?).

Any ideas?
Thanks for the help.
Live life in chunks!

#6 AdamJ

AdamJ

    Initiate

  • Members
  • PipPip
  • 108 posts
  • Joined: 15-April 03
  • Location:Toronto, Canada

Posted 14 November 2011 - 09:34 AM

ishvariable will check only the variables that are declared in houdini (show up in Edit->Aliases and Variables window). isvariable is just a superset, it will check in houdini or os onse.

For checking/remapping strings have a look at 'strmatch'.. btw if if you add '-k' you can search for command/expressions that contain the keyword you're looking for. So if you want to find expressions that have something to do with strings you can do 'exhelp -k string'.

#7 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 14 November 2011 - 09:57 AM

View PostAdamJ, on 14 November 2011 - 09:34 AM, said:

ishvariable will check only the variables that are declared in houdini (show up in Edit->Aliases and Variables window). isvariable is just a superset, it will check in houdini or os onse.

For checking/remapping strings have a look at 'strmatch'.. btw if if you add '-k' you can search for command/expressions that contain the keyword you're looking for. So if you want to find expressions that have something to do with strings you can do 'exhelp -k string'.

Thanks AdamJ,
However I still do not know how to check if $MAPG is a wrong, well I can do that with some string by string checking. But it would have been nice to be able to check if a string is one of Houdini's own declared variables, like $CR, $PT, $MAPU etc.

Thanks.
Live life in chunks!

#8 AdamJ

AdamJ

    Initiate

  • Members
  • PipPip
  • 108 posts
  • Joined: 15-April 03
  • Location:Toronto, Canada

Posted 14 November 2011 - 11:40 AM

you could check user input against parm list ..

point_parm_list = hou.node('/obj/geo2/point1').parms()

..
nx
ny
nz
douvw
mapu
mapv
mapw
domass
..

#9 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 15 November 2011 - 03:53 AM

Hello! Thank you very much!
Yep, this is waht I am going to do, lookup to a set of strings.

Cheers.
Live life in chunks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users