Hi,<br><br>Sorry for extra spamming, but I seem to have fixed all of the appending issues. Patch has been updated accordingly.<br><br>Regards,<br>Joshua<br><br><div><span class="gmail_quote">On 5/19/07, <b class="gmail_sendername">
Joshua Leung</b> &lt;<a href="mailto:aligorith@gmail.com">aligorith@gmail.com</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;">
Hi,<br><br>I&#39;ve been working on this as well, using joeedh&#39;s initial patch (from a few days ago) as a base to work from. I had originally thought that joeedh had stopped working on this, so I picked up the code.<br>

<br>What is presented in my version is a slightly cleaned up buttons layout, and also a different approach to the custom-buttons/settings thing. The python script is responsible for defining/getting/setting&nbsp; the settings by using a 
Draw.pupblock. That way, all of the clunky globals,etc. can be kept out of the bPythonConstraint sdna struct.<br><br>I haven&#39;t checked on the state of library linking in this yet. <br><br>Patch and sample script(s) available from:
<br><a href="http://aligorith.googlepages.com/pyconstraints2" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://aligorith.googlepages.com/pyconstraints2</a><br><br>Regards,<br><span class="sg">
Joshua</span><div><span class="e" id="q_112a2996f299262d_2"><br><br><div><span class="gmail_quote">On 5/19/07, <b class="gmail_sendername">joe
</b> &lt;<a href="mailto:joeedh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">joeedh@gmail.com</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;">
[Moving thread to bf-committers btw]
<br><br>Ok I added the code necessary for library linking, however it&#39;s not<br>working.&nbsp;&nbsp;I can&#39;t seem to figure out what&#39;s wrong; I call expand_doit<br>in all the right places and everything.&nbsp;&nbsp;When I lib link the armature,
<br>the armature doesn&#39;t seem to have the constraint applied.&nbsp;&nbsp;When I<br>proxy-afy the armature, it *does* then get the constraint applied, and<br>all seems to work.&nbsp;&nbsp;However, when I save and reload, the pyconstraint
<br>
script reference is set to NULL.<br><br>Its especially weird, because the pyconstraint Text buffer *is* being<br>lib-linked in; I can see it in the text editor menu.<br><br>Updated patch at <a href="http://joeedh.googlepages.com/pyconstraint.patch" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://joeedh.googlepages.com/pyconstraint.patch</a><br><br>On 5/18/07, joe &lt;<a href="mailto:joeedh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">joeedh@gmail.com</a>&gt; wrote:<br>
&gt; I&#39;d have to ask Ton.&nbsp;&nbsp;At the moment I don&#39;t think it&#39;d work. It should
<br>&gt; be possible to code it so it works, I think, but I&#39;m not completely<br>&gt; familiar with how to do this.&nbsp;&nbsp;I&#39;m not sure if anyone has ever needed<br>&gt; to library link Text buffers before, so I don&#39;t know if it works very
<br>&gt; well :/&nbsp;&nbsp;Of course you wouldn&#39;t append the text buffers manually, the<br>&gt; constraints inside the armature *should* do it for you.<br>&gt;<br>&gt; I&#39;ll have a look at the library linking code and see if I can understand it.
<br>&gt;<br>&gt; Joe<br>&gt;<br>&gt; On 5/18/07, Claudio malefico Andaur &lt;<a href="mailto:malefico@manosdigitales.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">malefico@manosdigitales.com
</a>&gt; wrote:<br>&gt; &gt; Would this work in proxy armatures ? I mean, linking a rig using
<br>&gt; &gt; pyconstraints into a new scene (blend file), and making a proxy of it<br>&gt; &gt; would still have the same pyconstraint functionality working ?<br>&gt; &gt;<br>&gt; &gt; Regards and thanks in advance<br>&gt; &gt;
<br>&gt; &gt; malefico<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; joe wrote:<br>&gt; &gt; &gt; [sent this twice, as the first one I sent to<br>&gt; &gt; &gt; <a href="mailto:bf-python@projects.blender.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
bf-python@projects.blender.org
</a>, and I thing that&#39;s the wrong address]<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Patch link:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; <a href="http://joeedh.googlepages.com/pyconstraint.patch" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://joeedh.googlepages.com/pyconstraint.patch
</a><br>&gt; &gt; &gt;<br>&gt; &gt; &gt; This patch implements python-defined constraints.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Pyconstraints are python text buffers that begin with #BPYCONSTRAINT.<br>&gt; &gt; &gt; No loading of
<br>&gt; &gt; &gt; external pyconstraints is supported (deliberately), the idea being<br>&gt; &gt; &gt; that forcing people to<br>&gt; &gt; &gt; include the constraints in the .blend is the best way to avoid<br>&gt; &gt; &gt; compatibility issues.
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Pyconstraints must define 2 functions: doConstraint(inmatrix,<br>&gt; &gt; &gt; targetmatrix, idproperty) and<br>&gt; &gt; &gt; doDraw(x, y, idproperty).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; For doConstraint, inmatrix is the owning object/posebone&#39;s world-space
<br>&gt; &gt; &gt; matrix, and<br>&gt; &gt; &gt; targetmatrix is the world-space matrix of the target object/posebone.<br>&gt; &gt; &gt; doConstraint must<br>&gt; &gt; &gt;&nbsp;&nbsp;return a 4x4 Mathutils.Matrix() object, representing the new matrix
<br>&gt; &gt; &gt; of the owning<br>&gt; &gt; &gt; object/posebone (in world space).&nbsp;&nbsp;Note that inmatrix and targetmatrix<br>&gt; &gt; &gt; are copies, so<br>&gt; &gt; &gt; modifying them won&#39;t affect anything.<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; doDraw is used to define the UI of the constraint.&nbsp;&nbsp;At the moment this<br>&gt; &gt; &gt; UI is placed in a<br>&gt; &gt; &gt; popup block, due to limitations of the interface code.&nbsp;&nbsp;doDraw works<br>&gt; &gt; &gt; exactly the same way
<br>&gt; &gt; &gt;&nbsp;&nbsp;as if it were called with Draw.UIBlock(doDraw) (except that doDraw is<br>&gt; &gt; &gt; passed the x and y<br>&gt; &gt; &gt; coordinates to start at), and has the same rules/limitations.<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; Note that pyconstraints are handled in much the same way as normal<br>&gt; &gt; &gt; script with UIs; e.g.,<br>&gt; &gt; &gt;&nbsp;&nbsp;their global namespace dictionary is kept alive unless an error happens.<br>

&gt; &gt; &gt;<br>&gt; &gt; &gt; Several issues with scoping in the Draw module came up while I was<br>&gt; &gt; &gt; working on this,<br>&gt; &gt; &gt; which I solved.&nbsp;&nbsp;The most annoying one is no local copy of button<br>

&gt; &gt; &gt; tooltips were made (in<br>&gt; &gt; &gt;&nbsp;&nbsp;violation of the python design guidelines, btw) which meant if you<br>&gt; &gt; &gt; didn&#39;t use a global string<br>&gt; &gt; &gt;&nbsp;&nbsp;variable for a tooltip, you could get garbarge or even a crash.&nbsp;&nbsp;Also
<br>&gt; &gt; &gt; not putting the result of<br>&gt; &gt; &gt;&nbsp;&nbsp;Draw.String() in a global variable would cause garbage or a crash.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; This issue turns out to be part of a bigger problem, where blender&#39;s
<br>&gt; &gt; &gt; UI would internally hold<br>&gt; &gt; &gt;&nbsp;&nbsp;references to python objects without somehow increasing their<br>&gt; &gt; &gt; reference count.&nbsp;&nbsp;To solve<br>&gt; &gt; &gt; this, I modified the Draw.c code where each script area and each
<br>&gt; &gt; &gt; pyconstraint instance<br>&gt; &gt; &gt; internally cache Button objects in a python list.&nbsp;&nbsp;This solves the<br>&gt; &gt; &gt; problem of having to place<br>&gt; &gt; &gt;&nbsp;&nbsp;each button in a global variable, and also allowed solving the
<br>&gt; &gt; &gt; tooltip problem by copying<br>&gt; &gt; &gt; the tooltip from the python string to a 256-long char array in Button<br>&gt; &gt; &gt; (using strncpy of<br>&gt; &gt; &gt; course).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; This allows for the following code form for pyconstraints:
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; def doDraw(x, y, idprop):<br>&gt; &gt; &gt;&nbsp;&nbsp; def callback(id, val):<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; if id == 0:<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print val<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; idprop[&#39;bleh&#39;] = val
<br>&gt; &gt; &gt;&nbsp;&nbsp; if idprop.has_key(&#39;bleh&#39;)==0: idprop[&#39;bleh&#39;] = &quot;&quot;<br>&gt; &gt; &gt;&nbsp;&nbsp; Draw.String(&quot;Bleh:&quot;, 0, x, y, 100, 22, idprop[&#39;bleh&#39;], 32, &quot;tooltip&quot;)<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; . . .which as you can see is very clear and compact.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; One other small change I did was to extend Campbell&#39;s UIBlock code<br>&gt; &gt; &gt; changes to also work with pyconstraints (which only required adding
<br>&gt; &gt; &gt; one small function, Set_UIBlock(), to Draw.c).<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Due to time limitations and prior commitments with bmesh, I will not<br>&gt; &gt; &gt; have any more time till after summer for large changes to this patch.
<br>&gt; &gt; &gt; If approved and committed, I can do maintenance work on it, fix bugs,<br>&gt; &gt; &gt; etc, but spending days rewriting it just because someone objects to<br>&gt; &gt; &gt; part of the design is definitely out. :)
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Joe<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; _______________________________________________<br>&gt; &gt; &gt; Bf-python mailing list<br>

&gt; &gt; &gt; <a href="mailto:Bf-python@blender.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Bf-python@blender.org</a><br>&gt; &gt; &gt; <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://lists.blender.org/mailman/listinfo/bf-python</a><br>&gt; &gt; &gt;
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>
&gt; &gt; Bf-python mailing list
<br>&gt; &gt; <a href="mailto:Bf-python@blender.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Bf-python@blender.org</a><br>&gt; &gt; <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://lists.blender.org/mailman/listinfo/bf-python</a><br>&gt; &gt;
<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt;<br><br><br><br><br>_______________________________________________<br>Bf-committers mailing list<br><a href="mailto:Bf-committers@blender.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Bf-committers@blender.org
</a><br><a href="http://lists.blender.org/mailman/listinfo/bf-committers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.blender.org/mailman/listinfo/bf-committers</a><br><br>
<br><br><br></blockquote></div><br>
</span></div></blockquote></div><br>


!DSPAM:18,464e815336371513515811!