The Maxon SDK Team is currently short staffed due to the winter holidays. No forum support is being provided between 15/12/2025 and 5/1/2026. For details see Maxon SDK 2025 Winter Holidays.
  • How to properly update and reset deform cache.

    11
    0 Votes
    11 Posts
    2k Views
    M
    First of all, I'm sorry I simply forget your topic, so thanks for bumping it again. Regarding your question, I'm really not sure about what you want to achieve. So maybe try to explain what you want to achieve with simple step by step. Anyway, I will try to answers your question about how to retrieve the delta from a non-deformed geometry to a deformed geometry. Keep in mind that all points position retrieved by GetAllPoints() are local to the current object matrix, so doing a SetRelPos, on the object will most likely not affect the point position returned since it moves the whole object matrix. So here a quick example that properly retrieves the delta from a deformed object and its normal version. import c4d def main(): # Get the current world position allPtCurrentFrame = op.GetDeformCache().GetAllPoints() mgCurrentFrame = op.GetDeformCache().GetMg() # Move the mod +10 in Z in world position mod = doc.SearchObject('mod_1') modMat = mod.GetMg() modMat.off += c4d.Vector(0, 0, 10) mod.SetMg(modMat) # change the frame doc.SetTime(c4d.BaseTime(1, doc.GetFps())) buildflag = c4d.BUILDFLAGS_NONE if c4d.GetC4DVersion() > 20000 else c4d.BUILDFLAGS_0 doc.ExecutePasses(None, True, True, True, buildflag) # Get the next world position allPtNextFrame = op.GetDeformCache().GetAllPoints() mgNextFrame = op.GetDeformCache().GetMg() # Calculate the difference in both local space and global space diffLocalSpace = [allPtNextFrame[ptID] - x for ptID, x in enumerate(allPtCurrentFrame)] diffGlobalSpace = [(allPtNextFrame[ptID] * mgNextFrame) - (x * mgCurrentFrame) for ptID, x in enumerate(allPtCurrentFrame)] # For each axes create a Vertex map componentNames = ["x", "y", "z"] for componentId, componentName in enumerate(componentNames): # First find the maximum delta for the current component maxLocalSpace = 1 maxGlobalSpace = 1 for ptLocal in diffLocalSpace: maxLocalSpace = max(maxLocalSpace, ptLocal[componentId]) for ptGlobal in diffGlobalSpace: maxGlobalSpace = max(maxGlobalSpace, ptGlobal[componentId]) # Normalize all of them from 0 to 1 normalizedLocal = [pt[componentId] / float(maxLocalSpace) for pt in diffLocalSpace] normalizedGlobal = [pt[componentId] / float(maxGlobalSpace) for pt in diffGlobalSpace] # Create Tag for local vMapLocal = op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount()) op.InsertTag(vMapLocal) vMapLocal.SetName("{0}_local".format(componentName)) vMapLocal.SetAllHighlevelData(normalizedLocal) # Create Tag for Global vMapGlobal = op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount()) op.InsertTag(vMapGlobal) vMapGlobal.SetName("{0}_global".format(componentName)) vMapGlobal.SetAllHighlevelData(normalizedGlobal) c4d.EventAdd() # Execute main() if __name__=='__main__': main() Cheers, Maxime.
  • How to Communicate between SubDialog and main GeDialog

    s22 python sdk
    5
    0 Votes
    5 Posts
    702 Views
    ?
    @m_adam Hi Maxime, I did try your example and I saw it working as a gadget but, you're right, I want to communicate between two GeDialogs. I followed your advice on using CoreMessage and found success with SpecialEventAdd. Thank you!
  • How to Override DoubleClick() from the TreeViewFunctions?

    r21 python
    9
    0 Votes
    9 Posts
    1k Views
    B
    @m_magalhaes Thanks for the response. The confusion is entirely mine. I was confused because I initially thought the GetName and SetName is only for typical C4D objects. but there is actually a separate GetName and SetName functions for the TreeView objects. I was able to retrieve the new string by just this code: def SetName(self,root, userdata, obj, name): print name # new name when you hit enter I can now use the name variable to use in my separate renaming function (i.e. rename a folder for which the TreeView was based on). Thanks!
  • Setting the FontData for a Text Object

    s22 python sdk
    2
    0 Votes
    2 Posts
    429 Views
    ?
    For whatever reason, the default Text Object has no FontData in Text[c4d.PRIM_TEXT_FONT]. By creating a FontData instance, I was able to set the Font. import c4d def main(doc): textObject = c4d.BaseObject(c4d.Osplinetext) doc.InsertObject(textObject) fontData = c4d.FontData() bc = c4d.BaseContainer() bc.SetString(500, 'Arial') bc.SetString(501, '11') bc.SetInt32(502, 400) bc.SetInt32(503, 0) bc.SetString(509, 'Arial') bc.SetString(508, 'ArialMT') fontData.SetFont(bc) textObject[c4d.PRIM_TEXT_FONT] = fontData textObject[c4d.ID_BASELIST_NAME] = bc[500] textObject[c4d.PRIM_TEXT_TEXT] = bc[500] c4d.EventAdd() if __name__=='__main__': main(doc)
  • 0 Votes
    24 Posts
    16k Views
    ManuelM
    arff, that's really strange, I'll send you a simple example and see if the error still happen on your system.
  • Make clean-up after script

    python
    3
    0 Votes
    3 Posts
    668 Views
    r_giganteR
    Hi @iluxa7k thanks for reaching out us. With regard to your question, as already pointed out by @zipit , the Python del statement just is only responsible for decrementing the reference counter for the instance being "deleted" and not to actually free the memory used by the instance itself. This is clearly noted in the official Python documentation on the Note coming along with object.__del__(self) in Python 3 or object.__del__(self) in Python 2 . Given that, also consider that the del app statement you've described in your first post might not actually deliver the "clean-up" action you're thinking about. Best, Riccardo
  • Will R22 be Python 3 as Python 2 "dies" in 2020?

    r21 python
    4
    0 Votes
    4 Posts
    925 Views
    r_giganteR
    Hi @iluxa7k thanks for following up. At the moment, as told in the very first answer, there are no updates I can share about the adoption of Python 3 in C4D. Rest assured that this is still under our PMs' radar. Best, Riccardo
  • Rotating Spline Points

    s22 python sdk
    8
    0 Votes
    8 Posts
    2k Views
    ?
    @nophoto Very nice! Thank you
  • Remove the Default CreateContextMenu in TreeViewFunctions?

    r21 python
    3
    0 Votes
    3 Posts
    369 Views
    B
    @m_magalhaes Thanks! It works as expected
  • TreeViewFunctions, two LV_USER fields

    r20 python
    8
    1
    0 Votes
    8 Posts
    966 Views
    P
    Thanks, it is working.
  • Implement A Rudimentary Licensing Solution?

    r21 python
    13
    0 Votes
    13 Posts
    1k Views
    B
    Thanks will close the thread for now.
  • Draw HUD-like text to viewport

    r21 classic api
    12
    0 Votes
    12 Posts
    2k Views
    fwilleke80F
    Hm, not bad. In deed, it has the potential to look more like the "normal" HUD, without doing hacky stunts. And it is a bit faster than DrawMultipleHUDText(). However, even if I only draw 4 texts using this code, the framerate on my iMac is down to 24 fps (tested in R21). Using my own code, I get 127 fps. I'll see if it can be optimised more (e.g. by making the clip map a member of MyClass so it does not have to be allocated for every draw call. Cheers, Frank EDIT: And it gets slower in a linear way. drawing 4 texts only gives me 12 fps. So, it looked promising, and I thank you very much for the code, as it gives me some new inspiration on how to do text drawing in the viewport), but for what I need to do (drawing > 30 texts on average), it is not suitable.
  • Setting up ObjectData plugin priority in Python

    python sdk
    3
    0 Votes
    3 Posts
    620 Views
    M
    Hi @Eduardo-Oliveira first of all welcome on the PluginCafe community. I think @zipit already provided you some correct answers or at least point you that this workflow is kind of strange for a Cinema 4D user since normally the object by itself doesn't really set its own position, but it's up to a tag (constraint Tag) to define the object position to another one. But in case you really want to do it, doing it in the Execute method of your ObjectData is fine. def AddToExecution(self, op, list): list.Add(op, c4d.EXECUTIONPRIORITY_GENERATOR, c4d.EXECUTIONFLAGS_CACHEBUILDING) return True def Execute(self, op, doc, bt, priority, flags): op.SetMg(doc.GetFirstObject().GetMg()) return c4d.EXECUTIONRESULT_OK You also need to ensure you registered your object with the flag c4d.OBJECT_CALL_ADDEXECUTION so AddToExecution and Execute are called. Cheers, Maxime.
  • update User Data with Preset info

    Moved python
    5
    0 Votes
    5 Posts
    987 Views
    ferdinandF
    Hi, you cannot, because the data container of a BaseList2D is not dynamically typed (like Python itself), but bound to data types specified in its description. If you want to change the data type of an user data element, you will have to modify the description of that element via GetUserDataContainer and SetUserDataContainer. There is also no 2D-Vector type in Cinema, only the crosshair thing custom GUI which you can apply to a Vector description element. Cheers, zipit
  • Redshift deleting using old information

    Moved
    17
    0 Votes
    17 Posts
    3k Views
    ManuelM
    hi, your question is sometimes not obvious Even with the scene it's a bit compicated. What i can say about your code is that you should be more defensive in your code. Always check the value before continue. For example what if the object is not found ? You should continue to the next item or stop ? for item in spline_UD: rs_mat = doc.SearchObject ("S" + str (item) + " Gas") if rs_mat is None: # Because we don't have object to continue, we iterate to the next item. continue ... Cheers, Manuel
  • Changing Display Filter Does Not Work When Rendering?

    r21 python
    4
    0 Votes
    4 Posts
    464 Views
    ManuelM
    Hello, thanks for the answer by the way you could also clone the renderdata, modify the clone and send it to as a parameter to the function RenderDocument. That way, you don't have to "restore" them. Just in case, don't forget that data may not be saved in the BaseContainer. Cheers, Manuel
  • Unnecessary Executions Under BFM_INPUT_VALUE

    r21 python
    5
    0 Votes
    5 Posts
    561 Views
    B
    @zipit Thanks for the confirmation!
  • PolygonObject.SetSelectEdges() and the Neighbor() class, a giant dilemma

    6
    0 Votes
    6 Posts
    1k Views
    M
    @m_adam said in PolygonObject.SetSelectEdges() and the Neighbor() class, a giant dilemma: ... Hope it answers your questions, Cheers, Maxime Thank you Maxime, this is a lot of useful info. Let me think through all of this and reply here if I have any further issues.
  • First Time calling SetAction does show the Brush tool's AM

    r20 r21 c++
    16
    0 Votes
    16 Posts
    2k Views
    C4DSC
    @m_adam said in First Time calling SetAction does show the Brush tool's AM: And I did test only on R21 so be sure to check again because I wasn't able to reproduce as you said with default layout in R21. Cheers, Maxime. I am using R21.207 and with default layout see the brush tool in the AM (identical to what happens with R20.059). For safety, I have now tested your solution on R21 and works as expected.
  • Custom data+gui access with GetParameter()

    c++ r21 r20 r19
    6
    0 Votes
    6 Posts
    1k Views
    rsodreR
    @m_magalhaes No hurry, for now there's just one place where I need this, I get it using the BaseContainer. But I will probably use it more often, so if the DOTS example is updated I can replicate the solution to my own type and remove this workaround. Thanks!