• iterating on multiple Tmgselection tags

    2
    0 Votes
    2 Posts
    498 Views
    N
    Replying to my own question. We need to define it using mo.GeGetMoDataSelection(Tag) Code that works. import c4d from c4d.modules import mograph as mo def main(): Cloner = op.GetObject() md = mo.GeGetMoData(Cloner) AllTags = Cloner.GetTags() for Tag in AllTags: if Tag.GetType() == c4d.Tmgselection: print Tag SelTag = mo.GeGetMoDataSelection(Tag) #This is the new line print SelTag.GetCount()
  • Add Custom Command in the Content Browser?

    r21 python
    3
    0 Votes
    3 Posts
    363 Views
    B
    @m_adam Thanks for the confirmation. Will close this for now.
  • Written Description in the Documentation?

    c++ r21
    2
    0 Votes
    2 Posts
    260 Views
    r_giganteR
    Hi @bentraje , thanks for pointing it out. We'll get it filled by a future documentation release. Best, Riccardo
  • Copying All Compatible Properties from One Object to Another?

    python s22
    6
    0 Votes
    6 Posts
    1k Views
    dskeithD
    Realizing I never responded to this Thank you @m_magalhaes, @mikegold10, and @PluginStudent. I ended up manually making a list of the parameters I wanted to copy and iterating through all of them. Not ideal, but at least glad to know there wasn't an automated method I was missing.
  • 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
    698 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
    348 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
    621 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
    904 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
    368 Views
    B
    @m_magalhaes Thanks! It works as expected
  • TreeViewFunctions, two LV_USER fields

    r20 python
    8
    1
    0 Votes
    8 Posts
    960 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
    604 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
    923 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
    462 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