I did included the c4d_resource.h and the error disappeared.
I was migrating by simply fixing the errors that appeared inside Xcode, until everything was clear.
But now, I started by duplicating a similar plugin from the sdk and pasting just the parts of the code that belong to my plugin.
Best posts made by rui_mac
The "solution" I came up with was this:
doc=op.GetDocument()
doc2=c4d.documents.IsolateObjects(doc,[op])
doc3=doc2.Polygonize(False)
and then go through all the objects of doc2, recursively.
Is this a correct way of doing things?
Latest posts made by rui_mac
@ferdinand, thank you for the answer and explanation. I will try to find a compromise.
In the meanwhile, one can always select the tag, lock the Attribute Manager and click the VertexMap tag to display the result. Cumbersome, but it works.
Well, it kind of works. When I adjust parameters in the plugin tag, sometimes the Attribute Manager reverts to show "2 Elements [VertexMap,ThePluginName]"
I even tried with your plugin and, by twirling the Data Source parameter open and, for example, turning the Invert option on, the Attribute Manager stops showing the plugin parameters, and starts showing "2 Elements [VertexMap,VertexMapMax]"
@ferdinand, thank you for the excellent advices.
I hope I can get home soon enough after work to clean up my code according to your advices and implement your solution.
Also, your advices will allow me to clean up some of my other plugins.
Thank you very much, once again.
@ferdinand, here is a version of my code with all the stuff that is not important for this problem, removed. Although, I fully commented everything I removed.
I hope it is enough to spot the problem.
import c4d
import os
import sys
import math
import random
from c4d import gui,plugins,bitmaps,documents,utils,Matrix,BaseContainer
from c4d import threading
PLUGIN_ID = 1037312
CHECK_ID = 1037275
PLUGIN_NAME ="VertexMapMix"
PLUGIN_VERSION = "1.1"
url_access = "vertexmapmix"
# define the IDs of the interface elements
VMM_ONOFF = 1000
VMM_VERTEXMAP = 1001
VMM_ATOMS = 1002
VMM_CREATEVERTEXTAG = 1003
VMM_SELECTVERTEXTAG = 1004
VMM_ATOM_ONOFF = 2001
VMM_ATOM_MIX = 2002
VMM_ATOM_INVERT = 2003
VMM_ATOM_SELECT = 2004
VMM_ATOM_NAME = 2005
VMM_ATOM_OPACITY = 2006
VMM_ATOM_BLUR = 2007
VMM_REMAPPING = 2020
VMM_ATOM_CURVE = 2021
VMM_SHOW = 2025
VMM_MIX_NORMAL = 0
VMM_MIX_MULT = 1
VMM_MIX_MIN = 2
VMM_MIX_MAX = 3
VMM_MIX_ADD = 4
VMM_MIX_SUB = 5
icon_edit = c4d.bitmaps.BaseBitmap()
# *******************************************************************************
class vertex_mm(plugins.TagData):
old_selection = 0
old_pressed = -1
old_show = 1
def Init(self,node):
# in here I initialize all the GUI elements
# ...
# and in here I create the hidden VertexMap tag
op = node.GetMain()
if not isinstance(op, c4d.PolygonObject): return True
tags = op.GetTags()
hidden_tag = None
for tag in tags:
if tag[c4d.ID_BASELIST_NAME] == "vmm_hidden":
hidden_tag = tag
break
if hidden_tag == None:
pnum=op.GetPointCount()
hidden_tag=c4d.VariableTag(c4d.Tvertexmap,pnum)
op.InsertTag(hidden_tag)
hidden_tag[c4d.ID_BASELIST_NAME]="vmm_hidden"
hidden_tag.ChangeNBit(c4d.NBIT_OHIDE,True)
return True
# *******************************************************************************
def Message(self,node,type,data):
if node==None: return True
# this code would turn the display of the VertexMap values on or off,
# depending on the state of a checkbok
if type==c4d.MSG_DESCRIPTION_VALIDATE:
state = node[VMM_SHOW]
if state != self.old_show:
self.old_show = state
op = node.GetObject()
if op.GetType() != 5100: return True
tags = op.GetTags()
hidden_tag = None
for tag in tags:
if tag[c4d.ID_BASELIST_NAME] == "vmm_hidden":
hidden_tag = tag
break
if hidden_tag == None:
pnum=op.GetPointCount()
hidden_tag=c4d.VariableTag(c4d.Tvertexmap,pnum)
op.InsertTag(hidden_tag)
hidden_tag[c4d.ID_BASELIST_NAME]="vmm_hidden"
hidden_tag.ChangeNBit(c4d.NBIT_OHIDE,True)
if state == 1:
hidden_tag.SetBit(c4d.BIT_ACTIVE)
op.SetBit(c4d.BIT_ACTIVE)
op.Message(c4d.MSG_UPDATE)
else:
hidden_tag.DelBit(c4d.BIT_ACTIVE)
return True
# *******************************************************************************
def Execute(self,tag,doc,op,bt,priority,flags):
# here I do all the stuff that the plugin is supposed to do
# at the end, in the list called w_array1, are all the values
# to store in the hidden VertexMap tag, for display
tags = op.GetTags()
hidden_tag = None
for tag in tags:
if tag[c4d.ID_BASELIST_NAME] == "vmm_hidden":
hidden_tag = tag
break
if hidden_tag != None:
hidden_tag.SetAllHighlevelData(w_array1)
vertex_mix.SetAllHighlevelData(w_array1)
# the "vertex_mix" is a visible VertexMap tag, where the values are also stored.
# IMPORTANT!!!
# if it would be possible to make the VertexMap shading appear, simply by using
# this visible VertexMap tag, I would be more than fine with this.
# The problem, so far, is that I have to click this visible tag to make the
# shading appear, and that makes all the parameters of my plugin Tag disapear
# from the Attribute Manager.
op.Message(c4d.MSG_UPDATE)
return c4d.EXECUTIONRESULT_OK
# *******************************************************************************
# registration of the tag
if __name__=="__main__":
# Register the Tag
icon = c4d.bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
icon.InitWith(os.path.join(dir, "res", "icon_vmm.tif"))
icon_edit.InitWith(os.path.join(dir, "res", "edit.tif"))
c4d.gui.RegisterIcon(1037349,icon_edit)
plugins.RegisterTagPlugin(id=PLUGIN_ID, str=PLUGIN_NAME, g=vertex_mm,
description="vertexmapmix", icon=icon,
info=c4d.TAG_EXPRESSION|c4d.TAG_VISIBLE|c4d.TAG_MULTIPLE)
print("["+PLUGIN_NAME+" Tag - v"+PLUGIN_VERSION+"] by Rui Batista: Loaded")
I was creating the hidden VertexMap in the Init method of my plugin tag.
But my main problem, like I described, was that activating the hidden VertexMap tag would show the VertexMap parameters in the Attribute Manager, instead of the parameters of my plugin tag.
When I tried to implement this, as soon as I do the tag.ChangeNBit(c4d.NBIT_OHIDE, True) thing, the Attribute Manager changes to show the attributes of the VertexMap tag, and the parameters of my plugin tag, that create the hidden VertexMap tag disapear.
I'm at work now, but I will recheck my code agaisnt yours, later.
Thank you so much.
The only "solution", so far, is to manually activate the plugin tag, lock the Attribute Manager, and then activate the VertexMap tag.
Not an ideal "solution" :-(
Just implemented it but the problem is that when I turn the hidden tag active, the Attribute Manager tells me that there are two objects selected (Multiple Objects) and the parameters of my plugin tag are no longer displayed.
Is there any way to keep both the hidden VertexMap tag and my plugin tag active, and display the parameters of my plugin tag in the Attribute Manager?
Thank you so much, @ferdinand .
The second option seems like the best one for me, if at all possible.
My plugin is already a tag.
So, is there any way to have the plugin selected, showing all the parameters in the Attributes Manager, and, at the same time, have a hidden VertexMap tag that shows the yellow-red gradient on the object where my plugin tag is active?
I asked this a few years ago (six years ago, actually) but I ask again, because there is a solution now (I hope).
Is there any way, in Python, to force the display in the editor of the strength of a Vertex Map, actually, showing what would be shown if a Vertex Map was active, but without having to click the Vertex Map itself?