[Sidefx-houdini-list] Run Script doesn't like Python???

Graham Thompson captainhammy at gmail.com
Wed Mar 24 10:03:09 EDT 2010


CDATA means character data.  It basically allows you to wrap a bunch
of text that will be interpreted as characters and ignore any
structure that might be confused with part of the file.  For example
if your code used < or > to compare values and you didn't use CDATA to
enclose it, it might think that those symbols are in fact
opening/closing tags for an element, which they aren't.

As for indenting, the script code is basically just read out and ran.
If it's not indented properly it will of course error.  It's
especially noticeable in .shelf files that create tools.  If you don't
have your code indented based on the file as opposed to the
surrounding tags you get code that looks weird when viewing it through
the Edit Shelf Tool dialog.  Best to just keep it indented wrt the
file.

Houdini is pretty picky with what tags you can pass to it.  It
basically only likes the ones that are outlined in MainMenuMaster.  If
you try and add other tags or attribute data to existing ones it will
most likely fail and print a bunch of errors.  I tried to add some
extra data to my .shelf files but Houdini didn't like this.  Pretty
much all there is to modifying the menus is shown in that file.


2010/3/24 Pablo Giménez <pablogipi at gmail.com>:
> 2010/3/23 Graham Thompson <captainhammy at gmail.com>
>
>> The ID is basically just some internal name/event.  In most cases the
>> event triggers an internal Houdini command.  You also use the ids to
>> map keyboard shortcuts to.
>>
>> If you look in $HH/MainMenuMaster you'll see the "docs" for all this
>> stuff.  It shows you an example of running an external script as
>> opposed to running code.
>>
>>      <scriptItem id="h.my_python_script">
>>        <label>My Python Script</label>
>>        <scriptPath>$HOME/script_file.py</scriptPath>
>>        <scriptArgs>arg_one arg_two arg_three</scriptArgs>
>>      </scriptItem>
>>
>
> It worked, thanks.
> One thing about your first version in your previous email.
> What is the meanind of !CDATA, why we have to use it?
> Also I have noticed that when you put python code in the <scriptCode> tag
> you have to indent your code as if the xml  file would be a python file, I
> mean you can't indent yout code relative to the <scriptCode> tag. which
> breaks the indentation of the xml file.
> Is there any place with the docs about  what XML tags would be understand in
> Houdini? I haven't seen any docs about it yet.
> thx
>
>
>>
>>
>>
>> 2010/3/23 Pablo Giménez <pablogipi at gmail.com>:
>> > Cool it worked!
>> > One more thing, I have seen that every entry has an id.
>> > In your code snippet you put the python script directly in the XML file.
>> > Is there any way I can assign a python script to this id, I mean, the
>> > standar entries in the menu just have an id, so I guess there is some
>> kind
>> > of combention about how to write a python script for an id entry from the
>> > menu, at least these standar entries are calling to comething isn't it?
>> > thx
>> >
>> >
>> > 2010/3/23 Graham Thompson <captainhammy at gmail.com>
>> >
>> >> It's just like most other config things you can have in Houdini: you
>> >> can have multiples.  Just copy the one in $HH and remove all the
>> >> entries or create a new one and just put your own entries in it and
>> >> stick it somewhere in the HOUDINI_PATH and you'll be good.
>> >>
>> >> 2010/3/23 Pablo Giménez <pablogipi at gmail.com>:
>> >> > Thanks Graham for the info.
>> >> > Is there any way to have your own MainMenuCommon that just add your
>> >> custom
>> >> > entries.
>> >> > I guess you are modifying the MainMenuCommon file in $HH or making a
>> copy
>> >> to
>> >> > your home to override the one from the install location.
>> >> > I don't want to override the whole file, just have a file with a bunch
>> of
>> >> > XML that add my own entries to the existing menu in Houdini.
>> >> > For instance in Maya I can use MEL to add entries to the main menu
>> >> created
>> >> > by the mel script shipped with the package.
>> >> > I want to do something similar with Houdini.
>> >> > thanks.
>> >> >
>> >> > 2010/3/22 Graham Thompson <captainhammy at gmail.com>
>> >> >
>> >> >> I ended up writing my own simple one and throwing it into
>> >> MainMenuCommon.
>> >> >>
>> >> >>      <scriptItem id="runpythonscript">
>> >> >>         <label>Run Python Script</label>
>> >> >> <modifyItem><insertAfter>h.source</insertAfter></modifyItem>
>> >> >> <scriptCode><![CDATA[filepath = hou.ui.selectFile(title="Select
>> Python
>> >> >> script to run", pattern="*.py")
>> >> >> if len(filepath) is not 0:
>> >> >>     fullpath = hou.expandString(filepath)
>> >> >>     execfile(fullpath)]]></scriptCode>
>> >> >>       </scriptItem>
>> >> >>
>> >> >> 2010/3/22 Pablo Giménez <pablogipi at gmail.com>
>> >> >> >
>> >> >> > Hi.
>> >> >> > I am trying to source some python script using the File menu entry
>> >> "Run
>> >> >> > Script .."
>> >> >> > Seems it only works with HScript, no chance for Python scripts
>> created
>> >> >> using
>> >> >> > the hou.Node.asCode() method.
>> >> >> > I can load these scripts using the python function execute() from a
>> >> >> python
>> >> >> > shell.
>> >> >> > Using version 10.0.312
>> >> >> > Thanks
>> >> >> >
>> >> >> > --
>> >> >> > Un saludo
>> >> >> > Best Regards
>> >> >> > Pablo Giménez
>> >> >> > _______________________________________________
>> >> >> > Sidefx-houdini-list mailing list
>> >> >> > Sidefx-houdini-list at sidefx.com
>> >> >> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>> >> >> _______________________________________________
>> >> >> Sidefx-houdini-list mailing list
>> >> >> Sidefx-houdini-list at sidefx.com
>> >> >> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Un saludo
>> >> > Best Regards
>> >> > Pablo Giménez
>> >> > _______________________________________________
>> >> > Sidefx-houdini-list mailing list
>> >> > Sidefx-houdini-list at sidefx.com
>> >> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>> >> >
>> >> _______________________________________________
>> >> Sidefx-houdini-list mailing list
>> >> Sidefx-houdini-list at sidefx.com
>> >> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>> >>
>> >
>> >
>> >
>> > --
>> > Un saludo
>> > Best Regards
>> > Pablo Giménez
>> > _______________________________________________
>> > Sidefx-houdini-list mailing list
>> > Sidefx-houdini-list at sidefx.com
>> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>> >
>> _______________________________________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>
>
>
>
> --
> Un saludo
> Best Regards
> Pablo Giménez
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>



More information about the Sidefx-houdini-list mailing list