Hi there,
Is there a way to derive hotl-like information about an operator inside an OTL?
i.e, to get the label of an operatortype in some otl, something like:
Director -> hotl -e Object/test_asset myotl.otl
Test Asset
Director ->
In a sense, like the “optypinfo” expression that works on operator-types in external otls.
Is this currently possible? If not, any nice workarounds and a possible RFE?
Thanks,
Jason
hotl in hscript?
5948 8 0- jason_iversen
- Member
- 12486 posts
- Joined: July 2005
- Offline
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
Hi Jason,
I second that RFE. Actually; it would be nice to have a full set of query/manipulation tools for otl files. Something like the “ot…” expression functions, but for the actual otl files.
In the meantime, you can do the usual hack and use hotl through a system() call. So, you can start with:
textport-> echo `system('hotl filename.otl')`
(I'm assuming you want this from inside houdini)
If you just want a list of the operator labels, and nothing else, then use "hotl -B filename.otl“.
To actually get something like optypeinfo, you'd need to do a little parsing but, again, you can resort to piping the result of the ”hotl filename.otl" call to your favourite scripting language. For example; to just get the value of each field and ommit the field's labe (since the number/type of fields is fixed)l, you could:
textport-> set filter = “awk -F \”:\“ ‘{ if(NR>1) {gsub(/^\\ */,\”\“,\$2); print \$2;} }’”
textport-> echo `system('hotl filename.otl | $filter')`
That's using awk, but you can choose your own favourite poison
And finally, wrap the whole thing up as a custom expression function as usual…
If you need more detailed inspection than what hotl gives you, you'll have to write a little shell script to expand the otl, perform the query, and clean up after itself. Not hard, but definitely a pain.
Yup. This kind of thing should be available as a shell tool. If for no other reason, it would give us a stable API to a format that is *bound* to keep changing for some time (meaning we'd need to update our hacky workarounds for each version…<sigh>).
RFE! RFE!
I second that RFE. Actually; it would be nice to have a full set of query/manipulation tools for otl files. Something like the “ot…” expression functions, but for the actual otl files.
In the meantime, you can do the usual hack and use hotl through a system() call. So, you can start with:
textport-> echo `system('hotl filename.otl')`
(I'm assuming you want this from inside houdini)
If you just want a list of the operator labels, and nothing else, then use "hotl -B filename.otl“.
To actually get something like optypeinfo, you'd need to do a little parsing but, again, you can resort to piping the result of the ”hotl filename.otl" call to your favourite scripting language. For example; to just get the value of each field and ommit the field's labe (since the number/type of fields is fixed)l, you could:
textport-> set filter = “awk -F \”:\“ ‘{ if(NR>1) {gsub(/^\\ */,\”\“,\$2); print \$2;} }’”
textport-> echo `system('hotl filename.otl | $filter')`
That's using awk, but you can choose your own favourite poison
And finally, wrap the whole thing up as a custom expression function as usual…
If you need more detailed inspection than what hotl gives you, you'll have to write a little shell script to expand the otl, perform the query, and clean up after itself. Not hard, but definitely a pain.
Yup. This kind of thing should be available as a shell tool. If for no other reason, it would give us a stable API to a format that is *bound* to keep changing for some time (meaning we'd need to update our hacky workarounds for each version…<sigh>).
RFE! RFE!
- jason_iversen
- Member
- 12486 posts
- Joined: July 2005
- Offline
Great Mario, thanks!
Sigh, I was hoping I'd missed something in the ot* commands, but I think you're right and I'm going to have to parse up the output of “hotl”. I'm always trying to avoid system() calls because they always pop up a shell window in Windows and cause epileptic reactions. :wink:
Thanks for the code snippet too, I'll bastardize that for my nefarious purposes.
Cheers,
Jason
Sigh, I was hoping I'd missed something in the ot* commands, but I think you're right and I'm going to have to parse up the output of “hotl”. I'm always trying to avoid system() calls because they always pop up a shell window in Windows and cause epileptic reactions. :wink:
Thanks for the code snippet too, I'll bastardize that for my nefarious purposes.
Cheers,
Jason
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- jason_iversen
- Member
- 12486 posts
- Joined: July 2005
- Offline
Here is what I used eventually. Ugly, but it did the job.
–hotlinfo.pl PERL script
#!/usr/local/bin/perl
# assumes usage:
# hotlinfo operatorname info otl
# e.g. hotlinfo mysop Label myotl.otl
#
if(!defined($ARGV)) {
print STDERR “ usage: hotlinfo operatorname info otl\n e.g. hotlinfo mysop Label myotl.otl\n”;
exit 1;
}
$curop=“”;
my %nodes;
$match=0;
open(HOTL,"hotl $ARGV |“) or die;
while(defined($line=<HOTL>)){
chomp($line);
if (length($line)){
($token,$value)=split(”: *",$line);
$match=1 if($token=~/Operator/ && $value=~/$ARGV/);
$match=0 if($token=~/Operator/ && $value!~/$ARGV/);
print $value if($match && $token=~/$ARGV/);
}
}
close(HOTL);
edit: bugfixed
–hotlinfo.pl PERL script
#!/usr/local/bin/perl
# assumes usage:
# hotlinfo operatorname info otl
# e.g. hotlinfo mysop Label myotl.otl
#
if(!defined($ARGV)) {
print STDERR “ usage: hotlinfo operatorname info otl\n e.g. hotlinfo mysop Label myotl.otl\n”;
exit 1;
}
$curop=“”;
my %nodes;
$match=0;
open(HOTL,"hotl $ARGV |“) or die;
while(defined($line=<HOTL>)){
chomp($line);
if (length($line)){
($token,$value)=split(”: *",$line);
$match=1 if($token=~/Operator/ && $value=~/$ARGV/);
$match=0 if($token=~/Operator/ && $value!~/$ARGV/);
print $value if($match && $token=~/$ARGV/);
}
}
close(HOTL);
edit: bugfixed
Edited by - March 16, 2004 15:15:44
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- wolfwood
- Member
- 4262 posts
- Joined: July 2005
- Offline
Since you came up with a work around…i'll give you the “in houdini” answer now.
otls will give you the same thing.
otls [otl_path} will give you a list of all the types inside of an otl
otls table/type will give you all the extra info you need.
/ch/ch1 -> otls PHoudini_Projects/cubedood/houdini/otls/timeMachine.otl Object/timeMachine
Operator: timeMachine
Label: Time Machine
Path: oplibObject/timeMachine?Object/timeMachine
Icon: opdefObject/timeMachine?Icon
Table: Object
Extra:
Inputs: 0 to 1
Subnet: true
Empty: false
Modified: Sun Sep 28 10:51:13 2003
foreach table_type (`run(“otls /tmp/my_Stuff.otl”)`)
otls /tmp/my_Stuff.otl $table_type
end
jim.
otls will give you the same thing.
otls [otl_path} will give you a list of all the types inside of an otl
otls table/type will give you all the extra info you need.
/ch/ch1 -> otls PHoudini_Projects/cubedood/houdini/otls/timeMachine.otl Object/timeMachine
Operator: timeMachine
Label: Time Machine
Path: oplibObject/timeMachine?Object/timeMachine
Icon: opdefObject/timeMachine?Icon
Table: Object
Extra:
Inputs: 0 to 1
Subnet: true
Empty: false
Modified: Sun Sep 28 10:51:13 2003
foreach table_type (`run(“otls /tmp/my_Stuff.otl”)`)
otls /tmp/my_Stuff.otl $table_type
end
jim.
Edited by - March 14, 2004 20:38:12
if(coffees<2,round(float),float)
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
- jason_iversen
- Member
- 12486 posts
- Joined: July 2005
- Offline
Ah yeah,
Thanks Jim.. Now to get some of those fields extractablized (nu-english). That would make an RFE still, wouldn't it?
String processing with arg() and match(), here we come.
Cheers!
Jason
Thanks Jim.. Now to get some of those fields extractablized (nu-english). That would make an RFE still, wouldn't it?
String processing with arg() and match(), here we come.
Cheers!
Jason
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- mtucker
- Staff
- 4443 posts
- Joined: July 2005
- Offline
- jason_iversen
- Member
- 12486 posts
- Joined: July 2005
- Offline
Ah, thanks Mark!
Those functions will be very useful.
Those functions will be very useful.
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
-
- Quick Links