Can you have a loop within a loop in hscript?

   6104   7   2
User Avatar
Member
6 posts
Joined: 11月 2006
オフライン
New to Hscript but I have been running a simple script which crashes houdini its simply

echo hello
set i = 0
while ( $i < 10 )
set i = `$i+1`
set j = 0
while( $j < 3)
#echo `vertex(“/obj/gerrycurl/geo1/grid1”,$i,0,“P”,$j)`
set j = `$j+1`
echo $j
end
echo $i
end

I can find a workaround without the second while loop but surely hscript can handle a loop within a loop?!
———————————
www.gerardkeating.com
User Avatar
Member
2199 posts
Joined: 7月 2005
オンライン
There's a much easier way to do this, if all you want is the vertex positions,
1. add an attributecreate sop#
2. set it to vertex type - 3 floats
3. In the value field type $TX $TY and $TZ
4. Open a spreadsheet - RMB and look at the vertex attributes

hope that helps

As to your script it's weird i tried this


set i =0
while ($i < 3)
set j = 0
while ($j < 3)
echo $i $j
set j = `$j + 1`
end
set i = `$i + 1`
end


And it worked fine

I think you are missing a space in the second while loop before the open bracket.

But it shouldn't freeze houdini, I'll post a bug report for you.
The trick is finding just the right hammer for every screw
User Avatar
Member
6 posts
Joined: 11月 2006
オフライン
Oh it must have been a space or something because that is working fine. As for the spreadsheet idea, I need a script to be able to read the positions of the vertices.
Anyway thanks.
———————————
www.gerardkeating.com
User Avatar
Member
8111 posts
Joined: 7月 2005
オフライン
Why not just use a Geometry CHOP and save it as a .clip file?
User Avatar
Member
2199 posts
Joined: 7月 2005
オンライン
What exactly are you trying to achieve in the end? It may well be possible to do it without a script. Its very rare to need one in houdini for any geometry operation.
The trick is finding just the right hammer for every screw
User Avatar
Member
6 posts
Joined: 11月 2006
オフライン
I'm actually doing a furinterpolation system using renderman procedural runprogram. To start of I create a geo node with a rib procedural for every face on a polygonal model passing in the vertex positions for the corners of the polygonal primitive and interpolating at render time using my own program. Needs alot more work like making the paths realtive but here's the script so far. And yes I know the new houdini will have a fur node.

opcd /obj/gerrycurl/
echo -n “Vertex Listing”
set funrintetropname = au_fur_inter_proc
oprm -f $funrintetropname
set netname=furinternet
nbrm -f $netname
nbadd $netname
set vertexPos=vertexPos

opcf
foreach i (`primlist(“/obj/gerrycurl/geo1”,“all_faces”)`) #1
set v = 0 #each primitive is a curve
while ($v < 3) #2
set primNormal$v=`prim(“/obj/gerrycurl/geo1/model”,$i,“N”,$v)`
set j = 0 #for x,y,z
while ($j < 3) #3
set $vertexPos$v$j = `vertex(“/obj/gerrycurl/geo1/model”, $i,$v,“P”, $j)`
echo `vertex(“/obj/gerrycurl/geo1/model”, $i,$v,“P”, $j)`

echo ${vertexPos$v$j}
echo *
set j = `$j + 1`
end #3
echo
set v = `$v + 1`
end #2
opadd -n geo $funrintetropname$i
oplocate -x 0 -y $i $funrintetropname$i
opparm $funrintetropname$i rishader ( ‘`chs(“../rishader2”)`’ ) detail ( procbound ) detail_ribproc ( '“RunProgram” ')
nbop $netname add $funrintetropname$i
echo
echo *********
set i = `$i + 1`
end #1

———————————
www.gerardkeating.com
User Avatar
Member
2199 posts
Joined: 7月 2005
オンライン
Well in fact the existing Houdini has one too.
Does pretty much exactly what you want I think.

http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=6069&highlight=fur+otl [sidefx.com]
The trick is finding just the right hammer for every screw
User Avatar
Member
6 posts
Joined: 11月 2006
オフライン
ops:
Thanks
———————————
www.gerardkeating.com
  • Quick Links