  | | | Python and connecting Scripted ops | Python and connecting Scripted ops 2005-05-18 - By Andy Buecker
Back The dispFix did the trick.
Many thanks for the help!
-A
Aloys Baillet wrote:
> Hi Andy, > > It seems to be a dynamic dispatch problem... > You might try Jerry's trick: > > XSI sometimes return objects with an incorrectly set (as per PythonWin > standards) multi-dispatch interface. > > The way to work around that is to re-wrap the object in a dynamic > dispatch. This allows you to skip the Application.GetValue: > > def dispFix( badDispatch ): > import win32com.client.dynamic > # Re-Wraps a bad dispatch into a working one: > return win32com.client.dynamic > .Dispatch(badDispatch) > > # Let's see if this works: > Application.CreatePrim("Sphere", "MeshSurface", "", "") > Application.ApplyHairOp ("sphere", "") > oHair = > Application.GetValue("hair").ActivePrimitive.ConstructionHistory.Find( "HairGenOp") > try: > > Application.LogMessage(oHair.Parameters['EmitterMeshSubdlevel'].Value) > except: > Application.LogMessage("Incorrect dispatch pointer") > oHair = dispFix(oHair) > Application.LogMessage(oHair.Parameters['EmitterMeshSubdlevel'].Value) > > # or, as a single long line: > > dispFix(Application.GetValue("hair") > .ActivePrimitive.ConstructionHistory > .Find("HairGenOp") > ).Parameters['EmitterMeshSubdlevel'].Value = 1 > > If that really really annoys you and you don't want to dispFix at all, > there is a way to make sure everything works, but you need to modify a > Python file to always return dynamic dispatches: > > Change %PYTHONPATH%\Lib\site-packages\win32com\client\__init__.py > > Look for the function called __WrapDispatch > > And comment all lines except the last one that begins with "return > dynamic.Dispatch ( ... " > > Of course it is always a good idea to backup files you are about to > modify. > > > Cheers! > > Aloys > > > On 5/19/05, *Andy Buecker* <abuecker@(protected) > <mailto:abuecker@(protected)>> wrote: > > I can't seem to 'connect' my scripted operator using python. I > get the following error telling me that the class doesn't support > the "Connect" attribute. The docs tell me this class supoorts > this attribute. Anyone know how to make this work? > > Thanks! > > -A > > #AttributeError: '<win32com.gen_py.Softimage|XSI Object Model > Library v1.5.CustomOperator instance at 0x1421616812>' object has > no attribute 'Connect' > > > > > > -- > Aloys Baillet - Character TD @ Animal Logic
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> The dispFix did the trick.<br> <br> Many thanks for the help!<br> <br> -A<br> <br> Aloys Baillet wrote: <blockquote cite="middbd779ba05051818384a068e4@(protected)" type="cite">Hi Andy,<br> <br> It seems to be a dynamic dispatch problem...<br> You might try Jerry's trick:<br> <br> XSI sometimes return objects with an incorrectly set (as per PythonWin standards) multi-<span id="st" name="st" class="st0">dispatch</span> interface.<br> <br> The way to work around that is to re-wrap the object in a <span id="st" name="st" class="st0">dynamic</span> <span id="st" name="st" class="st0">dispatch</span>. This allows you to skip the Application.GetValue:<br> <br> def dispFix( badDispatch ):<br> import win32com.client.<span id="st" name="st" class ="st0">dynamic</span><br> # Re-Wraps a bad <span id="st" name="st" class="st0" >dispatch</span> into a working one:<br> return win32com.client.<span id="st" name="st" class ="st0">dynamic</span> <div id="mb_6">.<span id="st" name="st" class="st0">Dispatch</span> (badDispatch)<br> <br> # Let's see if this works:<br> Application.CreatePrim("Sphere", "MeshSurface", "", "")<br> Application.ApplyHairOp ("sphere", "")<br> oHair = Application.GetValue("hair").ActivePrimitive.ConstructionHistory.Find( "HairGenOp")<br> try:<br> Application.LogMessage(oHair.Parameters['EmitterMeshSubdlevel'].Value) <br> except:<br> Application.LogMessage("Incorrect <span id="st" name ="st" class="st0">dispatch</span> pointer")<br> oHair = dispFix(oHair)<br> Application.LogMessage(oHair.Parameters['EmitterMeshSubdlevel'].Value) <br> <br> # or, as a single long line:<br> <br> dispFix(Application.GetValue("hair")<br> .ActivePrimitive.ConstructionHistory<br> .Find("HairGenOp")<br> ).Parameters['EmitterMeshSubdlevel'].Value = 1 <br> <br> If that really really annoys you and you don't want to dispFix at all, there is a way to make sure everything works, but you need to modify a <span id="st" name="st" class="st0">Python</span> file to always return <span id="st" name="st" class="st0">dynamic</span> dispatches:<br> <br> Change %PYTHONPATH%\Lib\site-packages\win32com\client\__init__.py <br> <br> Look for the function called __WrapDispatch<br> <br> And comment all lines except the last one that begins with "return <span id="st" name="st" class="st0">dynamic</span>.<span id="st" name="st" class="st0">Dispatch </span>( ... "<br> <br> Of course it is always a good idea to backup files you are about to modify.<br> <br> <br> Cheers!<br> <br> Aloys<br> </div> <br> <br> <div><span class="gmail_quote">On 5/19/05, <b class="gmail_sendername">Andy Buecker</b> <<a href="mailto:abuecker@(protected)">abuecker@(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;"> <div style="font-family: -moz-fixed; font-size: 13px;" lang="x-western">I can't seem to 'connect' my scripted operator using python. I get the following error telling me that the class doesn't support the "Connect" attribute. The docs tell me this class supoorts this attribute. Anyone know how to make this work? <br> <br> Thanks! <br> <br> -A <br> <br> #AttributeError: '<win32com.gen_py.Softimage|XSI Object Model Library v1.5.CustomOperator instance at 0x1421616812>' object has no attribute 'Connect' <br> <br> <br> </div> </blockquote> </div> <br> <br> <br> -- <br> Aloys Baillet - Character TD @ Animal Logic </blockquote> </body> </html>
|
|
 |