Thank you ferdidand,
Sorry for not giving more contextual code...
Yeah "potential ports" is what I would be interested in. Thanks for confirming that there is nothing in the API that would help me though!
Thank you ferdidand,
Sorry for not giving more contextual code...
Yeah "potential ports" is what I would be interested in. Thanks for confirming that there is nothing in the API that would help me though!
Hello dear people,
After hours of trying, hoping, searching and crying I post again.
I want to read out the complete description of a GvNode. Reading out parameters and sub-channels I got to work like this.
desc = node.GetDescription(c4d.DESCFLAGS_DESC_NONE) #c4d.Description
for bc, paramid, groupid in desc:
#the ID of a parameter
name = bc[c4d.DESC_IDENT]
subd = c4d.Description()
if subd.LoadDescription(paramid[0].dtype):
for bcB, paramidB, groupidB in subd:
#the ID of a sub-channel
subname = bcB[c4d.DESC_IDENT]
through this I also can get some ports. For example I can get GV_POINT_INPUT_OBJECT and GV_POINT_INPUT_POINT. (maybe because they are static? but on the other hand GV_POINT_OUTPUT_POINT is as well).
But other ports I do not get. It seems to me I should get them, since they are in the description res file.
Does anybody have an idea how to get all the IDs for all avalible ports (exposed and unexposed)? It needs to be programmatically too.
Cheers,
David
Damn. After poking around and trying stuff for some time I found the answer right after posting this.
You can right click on the parameter, choose "Userinterface" > "Show Subchannels". This will show that the paramter has some subparameters. Don't know what this is about. But dragging this into the attribute manager does work.
Hi there,
I am trying to read out parameteres from a redshift material. I can drag parameters from the graph view attribute window to the python console which shows me the desciption ids and after hitting enter on the keyboard their values. (Getting the desc IDs by code is no problem as well, this is not the point)
For example I can drag the diffuse color if a "RS Material" node into the console which shows
>>> RSMaterial[c4d.REDSHIFT_SHADER_MATERIAL_DIFFUSE_COLOR]
and the vector value of the color after hitting enter.
So basic so good.
But I noticed his does not work for every parameter. If I take a "RS Color Abs" node and drag the color of that, I get the Desc Id as well. But after hitting enter an
AttributeError: Parameter value not accessible (object unknown in Python)
which seems odd as this should just be a Vector as well.
Does anyone have an idea how to get this exact parameter value?
Cheers,
David
But I appreciate that you where trying to make things more streamlined
Hi Maxime,
I initialy tested exactly that: set the matrices with the tool and wait for c4d to do the autokeying (for free).
But that does not happen. if autokey is enabled and I just set the matrices, the objects jump right back to their old tracks.
That is why I check if autokey is enabled with c4d.IsCommandChecked(ID_AUTOKEYING_COMMAND)
and then request c4d to do a autokey.
If the user disables autokey or disables the position autokeying nothing happens. So it isn't like I am doing something where the user ends up saying "who made that key?"
Is there another way?
Cheers,
David
Hi zipit,
Sorry, maybe I was unclear. If you set a matrix on an object via code and that object is animated, the normal behaviour is (if you scrub through the timeline, or whatever) that the object just plays its animation. So there is no logic in my code for that, I was just testing the behaviour with autokey enabled and disabled.
But I actually just found the error and it was a human one. I had an EventAdd() in GetCursorInfo() and that apparently kind of blocked the animation being properly played if the mouse still hovered over the viewport. what I really needed was a call of DrawViews()...
Thank you for trying to understand me though
Cheers,
David
Hi there,
I am currently making a plugin that is similar to the move tool in cinema.
The problem:
If you take the MOVETOOL, change the position of an animated object with the movetool, DON'T make a new key for the position of the object and go to the next frame this object will go to the animated position again and ignore the changes I did. very logic.
interestingly enough if I use my tool, change the position of an animated object, DON'T make a key, go to the next frame...
... stunningly enough the object does not go back to the keyed position. sometimes it does. sometimes it only goes there after I go to the next frame, sometimes to the frame after. It seems to be locked or something, and get unlocked only after a certain time, or whatever...
What I tried so far:
I tried c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE)
because it sounded promsing, EventAdd
is in it of course. I tried to set the matrix dirty manually (of course SetMg will do that anyways I guess). I don't know if it is something that I am missing, maybe something thread related that blocks the object. or that the object doesn't know it needs to be updated. Or just an error I made?
The simplified code:
def MouseInput(self, doc, data, bd, win, msg):
objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
if len(objects) == 0:
return True
# Retrieves which clicks is currently clicked
device = 0
if msg[c4d.BFM_INPUT_CHANNEL ]== c4d.BFM_INPUT_MOUSELEFT:
device = c4d.KEY_MLEFT
elif msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSERIGHT:
device = c4d.KEY_MRIGHT
else:
return True
# Retrieves the X/Y screen position of the mouse.
mx = msg[c4d.BFM_INPUT_X]
my = msg[c4d.BFM_INPUT_Y]
# need to store the undo for autokey
doc.StartUndo()
undoObjs = list()
for o in objects:
doc.AddUndo(c4d.UNDOTYPE_CHANGE, o)
undoObjs.append( doc.GetUndoPtr() )
# Start a Dragging session
win.MouseDragStart(button=device, mx=int(mx), my=int(my), flags=c4d.MOUSEDRAGFLAGS_DONTHIDEMOUSE|c4d.MOUSEDRAGFLAGS_NOMOVE)
result, dx, dy, channel = win.MouseDrag()
# While the Mouse is still in the Dragging (clicked) state
while result == c4d.MOUSEDRAGRESULT_CONTINUE:
# If user doesnt move the mouse simply updates frag information
if dx == 0.0 and dy == 0.0:
result, dx, dy, channel = win.MouseDrag()
continue
# Offsets the original position with the delta of the dragging
mx += dx
my += dy
# do something with the matrices of the objects
for i in xrange(len(objects)):
objects[i].SetMg(SOME MATRIX)
# Updates the Viewport
c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_ANIMATION)
# and attribute manager
c4d.GeSyncMessage(c4d.EVMSG_DOCUMENTRECALCULATED)
# maybe this helps with that problem? but no
c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE)
# Updates drag information
result, dx, dy, channel = win.MouseDrag()
# do autokey
ID_AUTOKEYING_COMMAND = 12425
if c4d.IsCommandChecked(ID_AUTOKEYING_COMMAND):
for i in xrange(len(objects)):
doc.AutoKey(objects[i], undoObjs[i], False, True, False, False, False, False)
doc.EndUndo()
# If the user press ESC while dragging, do an Undo (remove the Metaball Object)
if win.MouseDragEnd() == c4d.MOUSEDRAGRESULT_ESCAPE:
doc.DoUndo(True)
# Pushes an update event to Cinema 4D
c4d.EventAdd()
return True
if anybody has an idea, please let me know!
Thank you,
David