﻿<?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=%E5%88%A9%E7%94%A8%E8%80%85%3ANBurn%2FSetting_up_Python_Debugger_with_Blender</id>
	<title>利用者:NBurn/Setting up Python Debugger with Blender - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3ANBurn%2FSetting_up_Python_Debugger_with_Blender"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:NBurn/Setting_up_Python_Debugger_with_Blender&amp;action=history"/>
	<updated>2026-08-29T17:22:24Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:NBurn/Setting_up_Python_Debugger_with_Blender&amp;diff=153089&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:NBurn/Setting_up_Python_Debugger_with_Blender&amp;diff=153089&amp;oldid=prev"/>
		<updated>2018-06-28T21:22:21Z</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日 (木) 21:22時点における版&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=%E5%88%A9%E7%94%A8%E8%80%85:NBurn/Setting_up_Python_Debugger_with_Blender&amp;diff=153088&amp;oldid=prev</id>
		<title>wiki&gt;NBurn: /* Rough Draft */</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:NBurn/Setting_up_Python_Debugger_with_Blender&amp;diff=153088&amp;oldid=prev"/>
		<updated>2018-05-22T09:51:13Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Rough Draft&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Rough Draft==&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''General overview of remote debugging:'''&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with remote debugging, the general idea is you want your debugger and &lt;br /&gt;
your &amp;quot;remote&amp;quot; application (Blender in this case) to be accessing the same code at the same time with the debugger acting as a &amp;quot;code guide&amp;quot;, determining when each piece of code is executed.&lt;br /&gt;
&lt;br /&gt;
The actual debugging process looks something like this: &lt;br /&gt;
&lt;br /&gt;
* First the code is loaded into the debugger&lt;br /&gt;
* Next the debugging server is started&lt;br /&gt;
* Then the &amp;quot;remote&amp;quot; application is launched and it runs the exact same code the server is hosting&lt;br /&gt;
* Finally (if there's no problems) the &amp;quot;remote&amp;quot; application should pause at the breakpoint and wait for the debug server to continue the code execution&lt;br /&gt;
&lt;br /&gt;
Note that &amp;quot;remote application&amp;quot; does not necessarily mean a program running on a different computer, it can be another application on the same computer as the debug server.&lt;br /&gt;
&lt;br /&gt;
To tell Blender to use a remote debugger, edit the Python code it will be running so it contains a link to the Python debugger the server uses at the beginning of the code, followed by a &amp;quot;breakpoint&amp;quot; where the code execution will be paused.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Eclipse debugging workflow''' (after setup is finished):&lt;br /&gt;
# Load code you want to debug in Eclipse&lt;br /&gt;
# Launch the Pydev debug server in Eclipse ''(Pydev &amp;gt; Start Debug Server)''&lt;br /&gt;
# Open Blender&lt;br /&gt;
# Open the same code from the debugger in Blender's Text Editor&lt;br /&gt;
# Run the code you just opened in Blender's Text Editor (''Run Script'')&lt;br /&gt;
# Wait for the Eclipse debug server to connect to Blender&lt;br /&gt;
# Debug...&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''PyCharm debugging workflow''' (after setup is finished):&lt;br /&gt;
# Load code you want to debug in PyCharm&lt;br /&gt;
# Launch PyCharm's debug server ''(Waiting for process connection...)''&lt;br /&gt;
# Open Blender&lt;br /&gt;
# Open the same code from the debugger in Blender's Text Editor&lt;br /&gt;
# Launch Blender debugger addon ''(Connect to remote PyCharm debugger)''&lt;br /&gt;
# Wait for PyCharm debugger to attach to Blender (''Connected to pydev debugger'')&lt;br /&gt;
# Run code you want to debug from Blender's Text Editor (''Run Script'')&lt;br /&gt;
# Debug...&lt;br /&gt;
&lt;br /&gt;
still feels like a step or two is missing...&lt;br /&gt;
&lt;br /&gt;
need to figure out proper setup so there's no &amp;quot;file.py can't be found in project&amp;quot; error&lt;br /&gt;
&lt;br /&gt;
etc&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Overriding VIEW_3D'''&lt;br /&gt;
&lt;br /&gt;
Code for overriding addon defined operators that are 3D View (view3d) dependent. This may be useful as a workaround for code that would otherwise fail when launched from outside the 3D View (like code being debugged that was rewritten to launch from Blender's Text Editor):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
def AssembleOverrideContextForView3dOps():&lt;br /&gt;
### IMPROVE: Find way to avoid doing four levels of traversals at&lt;br /&gt;
# every request!!&lt;br /&gt;
    for oWindow in bpy.context.window_manager.windows:&lt;br /&gt;
    # Iterates through the Blender GUI's windows, screens, areas, and regions&lt;br /&gt;
    # to find the View3D space and its associated window.  Populates an&lt;br /&gt;
    # 'oContextOverride context' that can be used with a bpy.ops  operator&lt;br /&gt;
    # that would normally need to be used from within a View3D context (like&lt;br /&gt;
    # most addon code that runs off of View3D panels).&lt;br /&gt;
    # Tip: If your operator fails, the log will show an&lt;br /&gt;
    # &amp;quot;PyContext: 'xyz' not found&amp;quot; error. To fix, stuff 'xyz' into the&lt;br /&gt;
    # override context and try again!&lt;br /&gt;
        oScreen = oWindow.screen&lt;br /&gt;
        for oArea in oScreen.areas:&lt;br /&gt;
            if oArea.type == 'VIEW_3D':&lt;br /&gt;
            ###LEARN: Frequently, bpy.ops operators are called from View3d's&lt;br /&gt;
            # toolbox or property panel.  By finding that window/screen/area&lt;br /&gt;
            # we can fool operators in thinking they were called from&lt;br /&gt;
            # the View3D!&lt;br /&gt;
                for oRegion in oArea.regions:&lt;br /&gt;
                    ###LEARN: View3D has several 'windows' like 'HEADER'&lt;br /&gt;
                    # and 'WINDOW'.  Most bpy.ops require 'WINDOW'&lt;br /&gt;
                    if oRegion.type == 'WINDOW':&lt;br /&gt;
                    #=== Now that we've (finally!) found the damn View3D,&lt;br /&gt;
                    # stuff all that into a dictionary bpy.ops operators can&lt;br /&gt;
                    # accept to specify their context.  I stuffed extra info&lt;br /&gt;
                    # in there like selected objects, active objects, etc as&lt;br /&gt;
                    # most operators require them.  (If anything is missing&lt;br /&gt;
                    # operator will fail and log a 'PyContext: error on the&lt;br /&gt;
                    # log with what is missing in context override) ===&lt;br /&gt;
                        oContextOverride = {'window': oWindow, \&lt;br /&gt;
                        'screen': oScreen, 'area': oArea, 'region': oRegion, \&lt;br /&gt;
                        'scene': bpy.context.scene, \&lt;br /&gt;
                        'edit_object': bpy.context.edit_object, \&lt;br /&gt;
                        'active_object': bpy.context.active_object, \&lt;br /&gt;
                        'selected_objects': bpy.context.selected_objects, \&lt;br /&gt;
                        'blend_data': bpy.data}   &lt;br /&gt;
                        # Stuff the override context with very common requests&lt;br /&gt;
                        # by operators.  MORE COULD BE NEEDED!&lt;br /&gt;
                        print(&amp;quot;-AssembleOverrideContextForView3dOps() &amp;quot; + \&lt;br /&gt;
                        &amp;quot;created override context: &amp;quot;, oContextOverride)&lt;br /&gt;
                        return oContextOverride&lt;br /&gt;
    raise Exception(&amp;quot;ERROR: AssembleOverrideContextForView3dOps() could &amp;quot; + \&lt;br /&gt;
    &amp;quot;not find a VIEW_3D with WINDOW region to create override context to &amp;quot; + \&lt;br /&gt;
    &amp;quot;enable View3D operators.  Operator cannot function.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Example usage&lt;br /&gt;
oContextOverride = AssembleOverrideContextForView3dOps()&lt;br /&gt;
bpy.ops.view3d.my_addon_idname(oContextOverride, 'INVOKE_DEFAULT')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code is a slightly modified version of the example in this thread:&amp;lt;br&amp;gt;&lt;br /&gt;
https://www.blender.org/forum/viewtopic.php?t=27834&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Todo:'''&lt;br /&gt;
* Add more info on PyCharm and Eclipse / PyDev setup&lt;br /&gt;
* Add Visual Studio / PTVS debug setup&lt;br /&gt;
* Add specific setup details for the big 3 (Linux / Mac / Windows)&lt;br /&gt;
* More cleanup on &amp;quot;Overriding view3d&amp;quot; code sample&lt;/div&gt;</summary>
		<author><name>wiki&gt;NBurn</name></author>
		
	</entry>
</feed>