Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
<DEFANGED_script >Python and the PPG global variable?

<DEFANGED_script >Python and the PPG global variable?

2005-04-27       - By Aloys Baillet

 Back
Reply:     1     2     3     4     5  

Sorry Patrick, but I don't think it's possible...
What you can also do is to put all the code of the scripted operator in a
separate file, and call XSIFactory.CreateScriptedOpFromFile. But in this
case you have to know where is installed the file (what I usually do is to
take the current PluginItem and ask its FileName property to find out where
I am in the filesystem, then point at the scripted op file. The advantage of
this method is that you can add as many helper function in your code without
having to add them in the operator code with the inspect.getsourcefunction...
Cheers,

Aloys

On 4/28/05, Patrick Boucher <patrickb@(protected)> wrote:
>
> Jerry Gamache wrote:
> > The nifty func.toString() from jscript does not translate directly into
> str(func) in Python. You ended up calling OnInit as you were running the
> setup script and it is normal that PPG is not defined there.
> >
> > You have some options:
> >
> > 1- Pass all the logic inlined in a string:
> >
> > # Put all the PPG logic inside a triple quoted string.
> > # Can be difficult to debug since syntax errors will
> > # not be found until the PPG is opened.
> > oLayout.Logic = """
> >
> > def OnInit():
> > Application.LogMessage(str(dir(PPG)))
> >
> > def Cons_OnChanged():
> > Application.LogMessage(str(dir(PPG)))
> >
> > """
> >
> > 2- Grab the function text from an imported module:
> >
> > import inspect
> > import myPPGHandlers
> >
> > # Grab the code directly from the imported module:
> > # Easier to debug since syntax errors will get caught
> > # when importing the module, and easier to manage since
> > # everything is in a module.
> > oLayout.Logic = inspect.getsource(myPPGHandlers.OnInit) + \
> > inspect.getsource(myPPGHandlers.cons_OnChanged)
> >
> > I currently don't think you can get the source code of a function
> defined in the setup code since that code is very quickly compiled into
> bytecode and the actual source text is discarded. This means that the code
> text must reside in a file somewhere and the import/inspect combo is you
> solution here.
> >
> >
> >
> > ---
> > Unsubscribe? Mail Majordomo@(protected) with the following text in
> body:
> > unsubscribe xsi
> >
>
> When creating a custom scripted operator, is there any way to use the
> same kind of layout logic mechanism as a self-installable PPG?
>
> I'm usisng your #2 technique on a tip from one of my coworkers but I'd
> rather everything be callback based.
>
> --
> Patrick Boucher
> TD - Coder - Resident geek
> Buzz Image Group
> Tel 514.848.0579
> Fax 514.848.6371
>
> www.buzzimage.com <http://www.buzzimage.com>
> www.xsi-blog.com <http://www.xsi-blog.com>
> ---
> Unsubscribe? Mail Majordomo@(protected) with the following text in body:
> unsubscribe xsi
>



--
Aloys Baillet - Character TD @ Animal Logic

Sorry Patrick, but I don't think it's possible...<br>
What you can also do is to put all the code of the scripted operator in
a separate file, and call XSIFactory.CreateScriptedOpFromFile. But in
this case you have to know where is installed the file (what I usually
do is to take the current PluginItem and ask its FileName property to
find out where I am in the filesystem, then point at the scripted op
file. The advantage of this method is that you can add as many helper
function in your code without having to add them in the operator code
with the inspect.getsource function...<br>
Cheers,<br>
<br>
Aloys<br><br><div><span class="gmail_quote">On 4/28/05, <b class="gmail
_sendername">Patrick Boucher</b> &lt;<a href="mailto:patrickb@(protected)"
>patrickb@(protected)</a>&gt; wrote:</span><blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left: 1ex;">
Jerry Gamache wrote:<br>&gt;
The nifty func.toString() from jscript does not translate directly into
str(func) in Python. You ended up calling OnInit as you were running
the setup script and it is normal that PPG is not defined there.<br>&gt;<br>&gt
; You have some options:<br>&gt;<br>&gt; 1- Pass all the logic inlined in a
string:<br>&gt;<br>&gt; # Put all the PPG logic inside a triple quoted string.
<br>&gt; # Can be difficult to debug since syntax errors will<br>&gt; # not be
found until the PPG is opened.<br>&gt; oLayout.Logic = &quot;&quot;&quot;<br>
&gt;<br>&gt; def OnInit():<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Application.LogMessage(str(dir(PPG)))
<br>&gt;<br>&gt; def Cons_OnChanged():<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; Application.LogMessage(str(dir(PPG)))<br>&gt;<br>&gt; &quot;&quot;&quot;
<br>&gt;<br>&gt; 2- Grab the function text from an imported module:<br>&gt;<br>
&gt; import inspect
<br>&gt; import myPPGHandlers<br>&gt;<br>&gt; # Grab the code directly from the
imported module:<br>&gt; # Easier to debug since syntax errors will get caught
<br>&gt; # when importing the module, and easier to manage since
<br>&gt; # everything is in a module.<br>&gt; oLayout.Logic = inspect.getsource
(myPPGHandlers.OnInit) + \<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
inspect.getsource(myPPGHandlers.cons_OnChanged)<br>&gt;<br>&gt; I
currently don't think you can get the source code of a function defined
in the setup code since that code is very quickly compiled into
bytecode and the actual source text is discarded. This means that the
code text must reside in a file somewhere and the import/inspect combo
is you solution here.<br>&gt;<br>&gt;<br>&gt;<br>&gt; ---<br>&gt; Unsubscribe?
Mail <a href="mailto:Majordomo@(protected)">Majordomo@(protected)</a> with
the following text in body:<br>&gt; unsubscribe xsi<br>&gt;<br>
<br>When creating a custom scripted operator, is there any way to use the<br
>same kind of layout logic mechanism as a self-installable PPG?<br><br>I'm
usisng your #2 technique on a tip from one of my coworkers but I'd<br>
rather everything be callback based.<br><br>--<br>Patrick Boucher<br>TD - Coder
- Resident geek<br>Buzz Image Group<br>Tel 514.848.0579<br>Fax 514.848.6371<br>
<br><a href="http://www.buzzimage.com">www.buzzimage.com</a><br>
<a href="http://www.xsi-blog.com">www.xsi-blog.com</a><br>---<br>Unsubscribe?
Mail <a href="mailto:Majordomo@(protected)">Majordomo@(protected)</a> with
the following text in body:<br>unsubscribe xsi<br></blockquote></div>
<br><br><br>-- <br>Aloys Baillet - Character TD @ Animal Logic