﻿<?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%3A2.7%2FSource%2FChecklists%2FContextEntry</id>
	<title>Dev:2.7/Source/Checklists/ContextEntry - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.7%2FSource%2FChecklists%2FContextEntry"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.7/Source/Checklists/ContextEntry&amp;action=history"/>
	<updated>2026-04-29T05:25:58Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.7/Source/Checklists/ContextEntry&amp;diff=150801&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.7/Source/Checklists/ContextEntry&amp;diff=150801&amp;oldid=prev"/>
		<updated>2018-06-28T21:15:54Z</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:15時点における版&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:2.7/Source/Checklists/ContextEntry&amp;diff=150800&amp;oldid=prev</id>
		<title>2016年2月29日 (月) 22:54にwiki&gt;Aligorithによる</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.7/Source/Checklists/ContextEntry&amp;diff=150800&amp;oldid=prev"/>
		<updated>2016-02-29T22:54:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Adding a new Context entry =&lt;br /&gt;
This checklist documents how to add a new entry in the global &amp;quot;Context&amp;quot; object (i.e. via &amp;lt;code&amp;gt;bContext *C&amp;lt;/code&amp;gt; in C, and &amp;lt;code&amp;gt;bpy.context&amp;lt;/code&amp;gt; in Python). Examples of these properties include &amp;lt;code&amp;gt;bpy.context.active_object&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bpy.context.active_gpencil_layer&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bpy.context.tool_settings&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bpy.context.area&amp;lt;/code&amp;gt; and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist - Single Item ==&lt;br /&gt;
This assumes that we are adding a property &amp;lt;code&amp;gt;my_prop&amp;lt;/code&amp;gt; of type &amp;lt;code&amp;gt;PropType&amp;lt;/code&amp;gt; (commonly referred to as &amp;lt;code&amp;gt;pro&amp;lt;/code&amp;gt; in the code). See the next section/checklist for what to do if you want to add a set of thing instead.&lt;br /&gt;
&lt;br /&gt;
Furthermore, we assume that this property refers to some &amp;quot;data&amp;quot; (e.g. a datablock, or an entity like a bone/keyingset/driver/node/etc., or similiar) as opposed to something window-management (&amp;quot;wm&amp;quot;) related such as active area/region/etc.&lt;br /&gt;
&lt;br /&gt;
When properly defined, you should be able to do:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    #include &amp;quot;BKE_context.h&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
    void some_func(bContext *C, ...)&lt;br /&gt;
    {&lt;br /&gt;
        PropType *pro = CTX_data_my_prop(C);&lt;br /&gt;
        ... do something with &amp;quot;prop&amp;quot; ...&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== blenkernel ===&lt;br /&gt;
* '''BKE_context.h''' - Add one of the following lines somewhere near another conceptually similar one:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    PropType *CTX_data_my_prop(const bContext *C);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''context.c''' - Add a function corresponding to the one below (and in a similar location in the file, grouping-wise):&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    PropType *CTX_data_my_prop(const bContext *C)&lt;br /&gt;
    {&lt;br /&gt;
        return ctx_data_pointer_get(C, &amp;quot;my_prop&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== editors/screen/screen_context.c ===&lt;br /&gt;
* '''screen_context_dir[]''' - Add a string entry for your property&lt;br /&gt;
&lt;br /&gt;
* '''ed_screen_context()''' - Add an &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; block for setting your prop in Context. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    else if (CTX_data_equals(member, &amp;quot;my_prop&amp;quot;)) {&lt;br /&gt;
        PropType *pro = ...&lt;br /&gt;
        ... Do some magic to get the property, and to test that should be made available at this time (as appropriate) ...&lt;br /&gt;
        &lt;br /&gt;
        CTX_data_id_pointer_set(result, pro);&lt;br /&gt;
        return 1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== doc/python_api/sphinx_doc_gen.py ===&lt;br /&gt;
* '''context_type_map''' - Add an entry for &amp;lt;code&amp;gt;my_prop&amp;lt;/code&amp;gt;, following the examples for other properties. These are arranged in alphabetical order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Checklist - Collection/Set ==&lt;br /&gt;
We still need to add code to the same places as before. This assuming that the context entry is now called &amp;lt;code&amp;gt;my_things&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This collection can then be used via:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    CTX_DATA_BEGIN(C, PropType *, pro, my_things)&lt;br /&gt;
    {&lt;br /&gt;
        ... do something with pro ...&lt;br /&gt;
    }&lt;br /&gt;
    CTX_DATA_END;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== blenkernel ===&lt;br /&gt;
* '''BKE_context.h''' - Add the following line instead:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    int CTX_data_my_things(const bContext *C, ListBase *list);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''context.c''' - Add the following code instead:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    int CTX_data_my_things(const bContext *C, ListBase *list)&lt;br /&gt;
    {&lt;br /&gt;
        return ctx_data_collection_get(C, &amp;quot;my_things&amp;quot;, list);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== editors/screen/screen_context.c ===&lt;br /&gt;
* '''screen_context_dir[]''' - (Same as before) Add a string entry for your collection&lt;br /&gt;
&lt;br /&gt;
* '''ed_screen_context()''' - Add an &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; block for setting your prop in Context. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    else if (CTX_data_equals(member, &amp;quot;my_prop&amp;quot;)) {&lt;br /&gt;
        for (...) {&lt;br /&gt;
            PropType *pro = ...&lt;br /&gt;
            &lt;br /&gt;
            if (...)&lt;br /&gt;
                CTX_data_id_list_add(result, pro);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);&lt;br /&gt;
        return 1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== doc/python_api/sphinx_doc_gen.py ===&lt;br /&gt;
* '''context_type_map''' - Add an entry for &amp;lt;code&amp;gt;my_prop&amp;lt;/code&amp;gt;, following the examples for other properties. These are arranged in alphabetical order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Precautions ==&lt;br /&gt;
* When doing the &amp;lt;code&amp;gt;ed_screen_context()&amp;lt;/code&amp;gt; logic, it is not advised to try and use CTX_* stuff to get hold of pointers to data you need. Instead use the local vars declared at the start of that function instead.&lt;br /&gt;
** For more details, see the comments in the ''&amp;lt;code&amp;gt;gpencil_data&amp;lt;/code&amp;gt;'' case&lt;br /&gt;
&lt;br /&gt;
* Try to keep any logic needed here simple - especially if the property is likely to be looked up in &amp;lt;code&amp;gt;Operator.poll()&amp;lt;/code&amp;gt; callbacks. If necessary, consider revising or improving your data structures to make these lookups simpler.&lt;/div&gt;</summary>
		<author><name>wiki&gt;Aligorith</name></author>
		
	</entry>
</feed>