  | | | <DEFANGED_script >Python and the PPG global variable? | <DEFANGED_script >Python and the PPG global variable? 2005-04-28 - By Aloys Baillet
Back I didn't tried this one, looks good! Thanks Jerry!
On 4/28/05, Jerry Gamache <jerryg@(protected)> wrote: > > inspect.getsource( module.function ) returns the source code for a single > function, but if all the functions in a module are of interest to your PPG > you might want to try: > > layout.Logic = inspect.getsource( myPPGModule ) > > To get all the code from myPPGModule.py in one single call. > > -- --Original Message-- -- > From: owner-xsi@(protected) [mailto:owner-xsi@(protected)]On Behalf > Of Patrick Boucher > Posted At: Wednesday, April 27, 2005 10:32 PM > Posted To: xsi > Conversation: <DEFANGED_script>Python and the PPG global variable? > Subject: Re: <DEFANGED_script>Python and the PPG global variable? > > Aloys Baillet wrote: > > 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.getsource function... > > Cheers, > > > > Aloys > > That's what I'm doing as well.... > > in my custom command: > myOpFile = os.path.join(myCmd.OriginPath, 'myOpFile.py') > op = XSIFactory.CreateScriptedOpFromFile('MyOp', myOpFile, 'Python') > layout = op.PPGLayout > layout.Language = "Python" > layout.Logic = inspect.getsource(foo) + inspect.getsource(bar) > > I was just hoping there was a sexier/more practical way to do so. > > If there's customOperator.Code and customOperator.FileName might be nice > to have PPGLayout.Logic and PPGLayout.LogicFileName. One could assign > the same file or different files to each to have all CustomOp code > outside the scene. One could also imagine a world where if the > PPGLayout.Logic is empty the system falls back to looking at > customOperator.Code for the UI event handlers... > > Thanks for the help! > > -- > 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 > > --- > Unsubscribe? Mail Majordomo@(protected) with the following text in body: > unsubscribe xsi >
-- Aloys Baillet - Character TD @ Animal Logic
I didn't tried this one, looks good!<br> Thanks Jerry!<br><br><div><span class="gmail_quote">On 4/28/05, <b class="gmail _sendername">Jerry Gamache</b> <<a href="mailto:jerryg@(protected)">jerryg @(protected)</a>> wrote:</span><blockquote class="gmail_quote" style= "border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding -left: 1ex;"> inspect.getsource( module.function ) returns the source code for a single function, but if all the functions in a module are of interest to your PPG you might want to try:<br><br>layout.Logic = inspect.getsource( myPPGModule )<br><br>To get all the code from myPPGModule.py in one single call.<br><br>-- --Original Message-- --<br>From: <a href="mailto:owner-xsi@(protected)">owner-xsi @(protected) </a> [mailto:<a href="mailto:owner-xsi@(protected)">owner-xsi@(protected)< /a>]On Behalf<br>Of Patrick Boucher<br>Posted At: Wednesday, April 27, 2005 10 :32 PM<br>Posted To: xsi<br>Conversation: <DEFANGED_script>Python and the PPG global variable? <br>Subject: Re: <DEFANGED_script>Python and the PPG global variable?<br> <br>Aloys Baillet wrote:<br>> 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 <br>> a separate file, and call XSIFactory.CreateScriptedOpFromFile. But in <br>> this case you have to know where is installed the file (what I usually <br>> do is to take the current PluginItem and ask its FileName property to <br>> find out where I am in the filesystem, then point at the scripted op <br>> file. The advantage of this method is that you can add as many helper <br>> function in your code without having to add them in the operator code <br>> with the inspect.getsource function...<br>> Cheers,<br>><br>> Aloys<br><br>That's what I'm doing as well....<br><br>in my custom command:<br >myOpFile = os.path.join(myCmd.OriginPath, 'myOpFile.py')<br>op = XSIFactory.CreateScriptedOpFromFile('MyOp', myOpFile, 'Python')<br>layout = op .PPGLayout<br>layout.Language = "Python"<br>layout.Logic = inspect .getsource(foo) + inspect.getsource(bar)<br><br>I was just hoping there was a sexier/more practical way to do so. <br><br>If there's customOperator.Code and customOperator.FileName might be nice<br>to have PPGLayout.Logic and PPGLayout.LogicFileName. One could assign <br>the same file or different files to each to have all CustomOp code <br>outside the scene. One could also imagine a world where if the<br>PPGLayout .Logic is empty the system falls back to looking at<br>customOperator.Code for the UI event handlers...<br><br>Thanks for the help!<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><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
|
|
 |