ScriptInfoData Struct Reference

#include <c4d_baselist.h>

Detailed Description

Broadcasted alongside the message MSG_MULTI_SCRIPTINFO to query scene elements for scripts they contain and might execute.

The message is usually broadcasted at a document level with C4DAtom::MultiMessage to collect information for a whole document:

ScriptInfoData infoData;
for (const ScriptInfoData::ScriptInfoItem& item: scriptInfoData.items)
DebugOutput(maxon::OUTPUT::DIAGNOSTIC, "Node: '@'", item.node ? item.node->GetName() : item.node);
Definition: c4d_basedocument.h:497
PyObject PyObject * item
Definition: dictobject.h:42
#define MSG_MULTI_SCRIPTINFO
Sent to nodes to gather information about the scripting content they host in their parameters....
Definition: c4d_baselist.h:561
@ BROADCAST
Broadcast the message, i.e. distribute it to all branches given by GeListNode::GetBranchInfo.
#define DebugOutput(flags, formatString,...)
Definition: debugdiagnostics.h:162
@ DIAGNOSTIC
Diagnostic output, shows up if this group of output is activated. This is also the default.
const char * doc
Definition: pyerrors.h:226
Describes a singular script parameter held by a node, e.g., the OPYTHON_CODE parameter of Opython.
Definition: c4d_baselist.h:1099
Broadcasted alongside the message MSG_MULTI_SCRIPTINFO to query scene elements for scripts they conta...
Definition: c4d_baselist.h:1090

When implementing a NodeData derived plugin hook which executes Python code, one must implement the message so that documents containing the plugin can be stopped from loading when the user does not trust the document:

Bool MyPythonObjectData::Message(GeListNode *node, Int32 type, void *data)
{
// ...
switch(type)
{
// ...
{
BaseList2D* const blist = static_cast<BaseList2D*>(node);
ScriptInfoData* const infoData = reinterpret_cast<ScriptInfoData*>(data);
if (!blist || !infoData)
return false;
// Setup an info item and define the parameter ID of the Python code in your plugin.
DescID paramId = ConstDescID(DescLevel(ID_MYPLUGIN_CODE));
const BaseContainer& bc = blist->GetDataInstanceRef();
// Fill in the node and parameter pointers.
item.node = blist;
item.pid = &paramId;
// Define the language and context. 3rd party plugins must use #SCRIPTINFO_CONTEXT::UNKNOWN.
// isDefault should express if the current code state is equal to the default value and
// isExecuted if the code will be executed when Cinema 4D invokes this node. For an object
// plugin this for example depends on the parameter #ID_BASEOBJECT_GENERATOR_FLAG.
item.isDefault = bc.GetString(ID_MYPLUGIN_CODE) == MY_DEFAULT_CODE;
// And finally append your script information. When your plugin holds multiple scripts,
// append one item for each of them.
iferr (infoData->items.Append(item))
return false;
break;
}
// ...
UNKNOWN
Used for unknown script types.
Definition: c4d_baselist.h:0
PYTHON
Used for Standard CPython syntax.
Definition: c4d_baselist.h:1
Definition: c4d_basecontainer.h:48
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:432
Bool GetBool(Int32 id, Bool preset=false) const
Definition: c4d_basecontainer.h:340
Definition: c4d_baselist.h:2376
const BaseContainer & GetDataInstanceRef() const
Definition: c4d_baselist.h:2517
Definition: lib_description.h:355
Represents a C4DAtom that resides in a 4D list.
Definition: c4d_baselist.h:1975
maxon::Bool Bool
Definition: ge_sys_math.h:51
maxon::Int32 Int32
Definition: ge_sys_math.h:56
#define iferr(...)
Definition: errorbase.h:388
#define ConstDescID(...)
Definition: lib_description.h:594
struct _node node
@ ID_BASEOBJECT_GENERATOR_FLAG
Definition: obase.h:18
PyObject ** type
Definition: pycore_pyerrors.h:34
Definition: node.h:10
Represents a level within a DescID.
Definition: lib_description.h:298
maxon::BaseArray< ScriptInfoItem > items
Stores the scripting element information provided by the queried nodes.
Definition: c4d_baselist.h:1112

Classes

struct  ScriptInfoItem
 

Public Member Functions

 ScriptInfoData ()
 

Public Attributes

maxon::BaseArray< ScriptInfoItemitems
 

Constructor & Destructor Documentation

◆ ScriptInfoData()

Member Data Documentation

◆ items

Stores the scripting element information provided by the queried nodes.