Navigation

    • Register
    • Login
    • Search
    1. Home
    2. rui_mac
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by rui_mac

    RE: Force VertexMap display

    @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.

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    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]"

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    @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.

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    @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")
    
    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    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.

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    @ferdinand,

    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.

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    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" 😞

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    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?

    posted in Cinema 4D SDK •
    RE: Force VertexMap display

    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?

    posted in Cinema 4D SDK •
    Force VertexMap display

    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?

    posted in Cinema 4D SDK •
    RE: How to detect click on a item in InExclude list?

    @m_adam

    Thank you very much. It is a nuisance not to be able to get the selection now.
    But it is better late than ever 🙂

    So, for new, it is completely impossible, as in... there is no workaround?
    Is there any other way to have a gizmo that allows the user to drag tags, show them on a list, be able to drag them up and down, and detect if there is a click on one of them?

    posted in Cinema 4D SDK •
    RE: Sometimes, IRR stops working when my plugin is placed on a scene.

    Since I know exactly what methods access/check/change the self.xxxx variables, it is a risk I'm willing to take 😉
    As for the solution, I removed the c4d.EventAdd() and at the GetContour method I was simply calling the function that was creating the spline. Now I perform a few checks for "dirtyness" and only after they show that something is dirty, I call the function to produce the spline.

    posted in Cinema 4D SDK •
    RE: How to detect click on a item in InExclude list?

    From what I gathered, the c4d.BaseList2D that is returned by

    op = inexclude_list.ObjectFromIndex(doc,i)
    

    is the object itself (a polygonal object, or a tag, or a material, depending on what types of objects the InExclude list accepts).
    So, I need a way to access the data of the list, to be able to determine which item is selected (was clicked on).
    And that is really complicated, it seems.

    posted in Cinema 4D SDK •
    RE: How to detect click on a item in InExclude list?

    I can GetData from each element of the InExclude list, as it returns a c4d.BaseList2D object.
    But, even so, I can't find out if it is selected or not.
    I tried checking the bits of the c4d.BaseList2D and I always get 0 (zero).

    posted in Cinema 4D SDK •
    RE: Sometimes, IRR stops working when my plugin is placed on a scene.

    It is working fine now 😄
    Thank you so much.

    posted in Cinema 4D SDK •
    RE: Sometimes, IRR stops working when my plugin is placed on a scene.

    I will look into the example.
    However, if I do have to check old values for changes, what is the best way? Those variables inside the class (the 'self' ones) are any used inside the CheckDirty.

    posted in Cinema 4D SDK •
    RE: Sometimes, IRR stops working when my plugin is placed on a scene.

    Yes, I'm using GetContour. And I'm just adjusting the "dirtyness" of the object, with this:

    	def CheckDirty(self, op, doc):
    
    		v1 = op[FR_STARTPOINT]
    		v2 = op[FR_ENDPOINT]
    		v3 = op.GetDown()
    		d1 = d2 = d3 = d4 = d5 = False
    
    		# d5 signals that the playhead has moved and the animation is to be taken into account
    		frame = doc.GetTime().GetFrame(doc.GetFps())
    		if self.old_frame != frame:
    			self.old_frame = frame
    			d5 = op[FR_TIME_CHANGE] == 1
    
    		# d1 signals that the starting point was changed
    		if v1 is not None:
    			d1 = v1.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty1a or v1.GetDirty(c4d.DIRTY_MATRIX) > self.dirty1b
    			if d1:
    				self.dirty1a = v1.GetDirty(c4d.DIRTYFLAGS_DATA)
    				self.dirty1b = v1.GetDirty(c4d.DIRTY_MATRIX)
    
    		# d2 signals that the end point was changed
    		if v2 is not None:
    			d2 = v2.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty2a or v2.GetDirty(c4d.DIRTY_MATRIX) > self.dirty2b
    			if d2:
    				self.dirty2a = v2.GetDirty(c4d.DIRTYFLAGS_DATA)
    				self.dirty2b = v2.GetDirty(c4d.DIRTY_MATRIX)
    
    		# d3 signals that a child was added to the object and there are no starting and ending points
    		if v1 is None and v2 is None and v3 is not None:
    			d3 = v3.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty3a or v3.GetDirty(c4d.DIRTY_MATRIX) > self.dirty3b or op.GetDirty(c4d.DIRTY_CHILDREN) > self.dirty_child
    			if d3:
    				self.dirty3a = v3.GetDirty(c4d.DIRTYFLAGS_DATA)
    				self.dirty3b = v3.GetDirty(c4d.DIRTY_MATRIX)
    				self.dirty_child = op.GetDirty(c4d.DIRTY_CHILDREN)
    
    		# check if the added child is a spline
    			d3 = d3 and ((v3.GetInfo() & c4d.OBJECT_ISSPLINE) != 0)
    
    		# compare the previous state of having a child or not with the new state.
    		has_child_now = v3 is not None
    		if has_child_now != self.has_child:
    			self.has_child = has_child_now
    
    		# if any of the conditions is True, set the object as Dirty
    		if d1 or d2 or d3 or d4 or d5:
    			op.SetDirty(c4d.DIRTYFLAGS_DATA)
    			c4d.EventAdd()
    
    posted in Cinema 4D SDK •
    RE: How to detect click on a item in InExclude list?

    When I try to get the data from the InExclude with something like

    the_data = my_inex.GetData()
    

    I get an error saying...

    AttributeError: 'c4d.InExcludeData' object has no attribute 'GetData'

    posted in Cinema 4D SDK •
    RE: Sometimes, IRR stops working when my plugin is placed on a scene.

    Here is a demonstration of the problem with the IRR, using my plugin:

    Download movie

    posted in Cinema 4D SDK •
    RE: How to detect click on a item in InExclude list?

    Thank, you Maxime.
    I'm not using e GeDialog. I'm creating the interface with a res file, like I stated in the text above.
    The description of the res file, for the InExclude is as follows:

    IN_EXCLUDE VMM_ATOMS
    {

    NUM_FLAGS 1;
    INIT_STATE 0;
    
    IMAGE_01_ON 1037349;
    IMAGE_01_OFF 1037349;
    
    SEND_SELCHNGMSG 1;
    
    ACCEPT {5682;}
    }
    

    However, it seems not to be working. What could I be doing wrong?

    posted in Cinema 4D SDK •