﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ADoc%2FTools%2FDebugging%2FPyFromC</id>
	<title>Dev:Doc/Tools/Debugging/PyFromC - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ADoc%2FTools%2FDebugging%2FPyFromC"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/PyFromC&amp;action=history"/>
	<updated>2026-07-04T03:21:12Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/PyFromC&amp;diff=100083&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/PyFromC&amp;diff=100083&amp;oldid=prev"/>
		<updated>2018-06-28T19:39:05Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 19:39時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/PyFromC&amp;diff=100082&amp;oldid=prev</id>
		<title>wiki&gt;Ideasman42: /* Summery */</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/PyFromC&amp;diff=100082&amp;oldid=prev"/>
		<updated>2014-02-25T01:01:48Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Summery&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;''Note that this is a very specific debugging/testing facility, if you are new to debugging its probably not what your looking for.''&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
This function lets you set one line in your code which calls python to execute code, modifying C/C++ variables, so you can write and test code while blenders running - renders/animates/redraws.&lt;br /&gt;
&lt;br /&gt;
Python running in C is nothing new, but normally this is done with predefined API glue code which has strict entry points, where setting up a proper API would be prohibitively slow for quick tests in the middle of a C function.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
* Add a line into your code.&lt;br /&gt;
 PyC_RunQuicky(&amp;quot;script.py&amp;quot;, vars...)&lt;br /&gt;
* create a python script that edits '''values''', a list which stores each variable given.&lt;br /&gt;
* Run blender and modify the script leaving blender open, modifications to '''values''' are copied back into blender after each execution.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
Having C call python is just one function call.&lt;br /&gt;
&lt;br /&gt;
The first argument is the file to run, the second is the number of arguments, the rest are format &amp;amp; pointer pairs. This formatting is passed onto struct.pack/unpack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=c&amp;gt;&lt;br /&gt;
/* this is needed to avoid any python includes */&lt;br /&gt;
extern void PyC_RunQuicky(const char *filepath, int n, ...);&lt;br /&gt;
&lt;br /&gt;
static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, float *vec, int selstate, int special_color)&lt;br /&gt;
{&lt;br /&gt;
    float size;&lt;br /&gt;
&lt;br /&gt;
    /* run a python script to modify the values passed */&lt;br /&gt;
    PyC_RunQuicky(&amp;quot;/home/ideasman42/test.py&amp;quot;, 8,&lt;br /&gt;
        &amp;quot;3f&amp;quot;,vec, &amp;quot;16f&amp;quot;,rv3d-&amp;gt;persmat, &amp;quot;f&amp;quot;,&amp;amp;size, &amp;quot;f&amp;quot;,&amp;amp;rv3d-&amp;gt;pixsize);&lt;br /&gt;
    ...&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script can be very simple, just modify '''values''' in place.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# get the values set by PyC_RunQuicky&lt;br /&gt;
vec, perspmap, size, pixelsize = values&lt;br /&gt;
&lt;br /&gt;
# modify some value&lt;br /&gt;
mat = perspmap[0:4], perspmap[4:8], perspmap[8:12], perspmap[12:16]&lt;br /&gt;
size = mat[0][3]*vec[0] + mat[1][3]*vec[1] + mat[2][3]*vec[2] + mat[3][3]&lt;br /&gt;
&lt;br /&gt;
print(vec, size, pixelsize)&lt;br /&gt;
&lt;br /&gt;
# set the list so the changes are updated in blender.&lt;br /&gt;
values = vec, perspmap, size, pixelsize&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Summery ==&lt;br /&gt;
'''Pros'''&lt;br /&gt;
* immediate feedback.&lt;br /&gt;
* quick setup.&lt;br /&gt;
* no need to write api wrapper code.&lt;br /&gt;
* access to blender python modules like bgl and mathutils.&lt;br /&gt;
'''Cons'''&lt;br /&gt;
* not so useful when the fix involves changes in many places.&lt;br /&gt;
* not so useful for modifying structures or pointers.&lt;br /&gt;
* allows for bad practice - &amp;quot;trial &amp;amp; error, without understanding&amp;quot;.&lt;/div&gt;</summary>
		<author><name>wiki&gt;Ideasman42</name></author>
		
	</entry>
</feed>