• 0 Votes
    6 Posts
    930 Views
    B
    @Cairyn and @r_gigante Apologies for the late response. Yes, the ExecutePasses works as expected. Thanks for the solution. I can't use the SetMg()/GetMg() because the script is part of a larger base code which is not limited only to the PSR tag. Thanks again. Have a great day ahead!
  • How to Open a Dialog Plugin from a Tag Plugin?

    Cinema 4D SDK sdk python
    6
    0 Votes
    6 Posts
    1k Views
    S
    Hello, the important question is, if you want to open a modal or asynchronous dialog. An asynchronous dialog must be hosted by a CommandData plugin (GeDialog Manual) (e.g. py-memory_viewer). As mentioned above, a double-click on a tag can be detected by looking for the MSG_EDIT message (NodeData::Message() Manual). So, when you detect MSG_EDIT, you simply have to execute the command that hosts you dialog. You can simply do that using CallCommand() (Command Utility Manual). Within your dialog, you can find your tag by getting the active tag. best wishes, Sebastian
  • 1 Votes
    3 Posts
    337 Views
    CairynC
    Yes, C4DAtom.CheckType() in Python. Thanks for the confirmation, it bugged me that it was only in the Python doc but not in the C++ doc.
  • Selecting Objects in Order

    Cinema 4D SDK python
    2
    1 Votes
    2 Posts
    2k Views
    M
    Hi @dskeithbuck thanks for reaching us. In fact, it's written in the C++ BaseDocument - Selection Manual but I agree maybe a note in the function will be welcome. IN any case, I will add a note for the python doc. Thanks again. Cheers, Maxime.
  • Show/Hide Tabs in GUI

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    701 Views
    N
    Hello Sebastian, sorry, for not using the QA System, will do in the future! This was exactly what I needed. I have never changed my GUI outside the res file and it felt kinda confusing to me what exactly I have to do after reading the doc. Thanks for your awnser! Best Regards, Florian
  • Dynamic VertexMap

    Cinema 4D SDK python sdk r20
    6
    0 Votes
    6 Posts
    1k Views
    N
    Hello Maxime, thanks for your answer! Its too bad that I can't do it without some hacky way, but thanks for your code snipped and example. I'll mark this thread as solved, so thanks! Best Regards, Florian
  • What's wrong with GetSelection()?

    Cinema 4D SDK r21 python
    7
    0 Votes
    7 Posts
    828 Views
    M
    Hi @Cairyn thanks for spotting it out, it's an issue in the python documentation, if you take a look at the C++ documentation it's said that it supports only Objects and Tags (see BaseDocument Selections Manual). (I will fix the Python doc) On other hand, I confirm to deselect all objects/tags the best way is to call SetSelection with None/nullptr. And finally, as zipit said, in the end, it's only a wrapper around BIT_ACTIVE with the benefic of GetSelection, that the selection is cached so you avoid the iteration on the whole scene. Cheers, Maxime.
  • Python Tag: Matrix is always dirty? (or vice versa)

    Cinema 4D SDK sdk python
    9
    0 Votes
    9 Posts
    1k Views
    M
    Hi @orestiskon I'm afraid there is nothing much more to say except what @zipit said. Just a few notes: IsDirty is build to be used within a generator to check the current object only. GetDirty retrieves an integer value ta represents the dirty state of an object. It can be used to retrieve DirtyCount from outside. Now take into consideration that the matrix object is kind of special since in reality, it creates nothing. But only feed some MoData and display them (but create no geometry). So how does an object that creates nothing can have its cache dirty? That's why it's up to the object that modifies the MoData (stored in its hidden tag ID_MOTAGDATA) to tell the matrix its content is dirty so other people that rely on this matrix know about it. Additionally to what @zipit said (which will work in any case and it's preferred) You can also consider checking for the dirtiness of the linked effector (but this will not consider Field). Here an example in a Python Generator import c4d def CheckDirtyObj(obj, uuid, flag): """ Checks if an object by comparing the current Dirt Value with the one stored in the current op.BaseContainer :param obj: The BaseList2D to retrieve the dirty state from. :param uuid: The uuid used to store in the BaseContainer. :param flag: The dirtiness flag to check for. :return: True if the object is dirty, False otherwise. """ def GetBc(): """ Retrieves a BC stored in the object BC, or create it if it does not exist yet :return: A BaseContainer where value can be stored. """ bcId = 100001 # Make sure to obtain an UNIQUE ID in plugincafe.com bc = op.GetDataInstance().GetContainerInstance(bcId) if bc is None: op.GetDataInstance().SetContainer(bcId, c4d.BaseContainer()) bc = op.GetDataInstance().GetContainerInstance(bcId) if bc is None: raise RuntimeError("Unable to create BaseContainer") return bc # Retrieves the stored value and the true DirtyCount storedDirtyCount = GetBc().GetInt32(uuid, -1) dirtyCount = obj.GetDirty(flag) # Compares them, update stored value and return if storedDirtyCount != dirtyCount: GetBc().SetInt32(uuid, dirtyCount) return True return False def main(): # Retrieve attached object and check if it's a matrix object matrixObj = op[c4d.ID_USERDATA, 1] if matrixObj is None or not matrixObj.CheckType(1018545): return c4d.BaseObject(c4d.Onull) # Retrieve the current cache opCache = op.GetCache() # We need a new object if one of the next reason are False # The Cache is not valid # The Parameter or Matrix of the current generator changed # The Parameter or Matrix of the linked Matrix changed needNewObj = opCache is None needNewObj |= not opCache.IsAlive() needNewObj |= op.IsDirty(c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) needNewObj |= CheckDirtyObj(matrixObj, 0, c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) # The Parameter or Matrix of effectors of the linked Matrix changed objList = matrixObj[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] for objIndex in xrange(objList.GetObjectCount()): # If the effector is disabled in the effector list, skip it if not objList.GetFlags(objIndex): continue # If the effector is not valid or not enabled, skip it obj = objList.ObjectFromIndex(op.GetDocument(), objIndex) if obj is None or not obj.IsAlive() or not obj.GetDeformMode(): continue # Check for the dirty value stored (+1 because we already used ID 0 for the matrix object) needNewObj |= CheckDirtyObj(obj, objIndex + 1, c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) if not needNewObj: print "Old Obj" return opCache print "Generated New Object" return c4d.BaseObject(c4d.Ocube) Cheers, Maxime.
  • Dirty State with Python Generator

    Cinema 4D SDK python sdk
    5
    1 Votes
    5 Posts
    1k Views
    orestiskonO
    Thanks a lot for the explanation! I replaced the plugin id with a user data and it seems to work ok. Still trying to figure out the matrix on the other thread though. Here is the adapted code: def main(): ID_PYGEN_DIRTY_CACHE = op[c4d.ID_USERDATA,3] linked_object = op[c4d.ID_USERDATA, 2] # Get the last cached dirty count and the current dirty count. lst_dcount = ID_PYGEN_DIRTY_CACHE cur_dcount = linked_object.GetDirty(c4d.DIRTYFLAGS_ALL) if linked_object is None: return c4d.BaseList2D(c4d.Onull) # Return the linked object if its dirty count exceeds our cached dirty # count or there is no cached dirty count. if lst_dcount is None or lst_dcount < cur_dcount or op.GetCache() is None: # Cache the current dirty count. op[c4d.ID_USERDATA,3] = cur_dcount clone = linked_object.GetClone(c4d.COPYFLAGS_NO_HIERARCHY) clone.SetMg(c4d.Matrix()) print "Built cache" return clone # Otherwise return the cache. else: print "Returned cache" return op.GetCache() And the file: python_dirtyState_0001.c4d
  • Attribute Manager not updating with Tag Selection

    Cinema 4D SDK python
    5
    0 Votes
    5 Posts
    1k Views
    M
    @C4DS Thank your reply! I had to come back to this because I had problems with switching back to object context and this solved that!
  • Mirroring a Pose

    Cinema 4D SDK python
    3
    1
    0 Votes
    3 Posts
    452 Views
    ?
    Thank you for the clarification, @zipit.
  • 0 Votes
    6 Posts
    2k Views
    r_giganteR
    Hi @gheyret, thanks for reaching out us. Although @zipit has already provide an exhaustive answer to the topic (thanks man!) , I warmly suggest to look also to this blog post[URL-REMOVED] from @fwilleke80 and also to have a look at Navigation in Lists and Trees section on the GeListNode Manual. Best, Riccardo [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
  • 0 Votes
    6 Posts
    999 Views
    ?
    @kbar Thank you for your response. That's really helpful, thank you.
  • 0 Votes
    5 Posts
    776 Views
    B
    I'm just going to go ahead and mark this as solved. Either using an empty Basecontainer or the set function solve the problem. Thank you for explaining!
  • How to handle C4D Unicode in Python scripting?

    Cinema 4D SDK r21 python windows
    12
    0 Votes
    12 Posts
    2k Views
    CairynC
    @zipit said in How to handle C4D Unicode in Python scripting?: well, that API object names thing is a flaw of Python 2. So working as expected or not as expected is a bit a question of the point of view. If you got the string passed from any other source the problem would be the same. Right. The main thing is to understand the issue, and then to write the chapter in a way that explains what to watch out for. (I do wonder how third-party modules would do with a name string passed to them from a script that reads them from the API... well, another bridge to cross another day.) Python 3 clearly is superior in that respect, as there is no unicode class and all str objects are unicode (what they appear to be already in C4D, but with matching len, index, and slice capabilities). On a more productive note: I think that focusing in Unicode strings isn't really that important for Python stuff in c4d, since object names should be something you largely ignore as they are a unreliable source of identification and only are rarely important in other contexts. Hmm, I am not sure whether I would agree to that. Good naming is essential to find your way through complex scenes, and a good naming schema can be built in a way that is friendly to string search and comparison criteria, esp. if you can build your own scripts to perform the search and selection. I just point at the _L _R naming schema for joints that is common in C4D's docs. Of course, if your objects are all named Cube, Cube.1, Cube.2, Cube.3, then name-based identification may be unhelpful Anyway, I am not the person to judge that, as I am only teaching Python to interested users. What they do with it is their own decision; I just have to point out the crucial points so they can apply the code to their own concepts.
  • Howto add a Field input to a python plugin

    Cinema 4D SDK python r19 r20 r21
    3
    0 Votes
    3 Posts
    587 Views
    P
    @s_bach said in Howto add a Field input to a python plugin: FIELDLIST works fine - i think i got an strange error before and trying CUSTOMFIELDLIST etc. solved
  • Error after hitting Undo.

    Cinema 4D SDK r20 python
    13
    0 Votes
    13 Posts
    2k Views
    ManuelM
    @m_magalhaes said in Error after hitting Undo.: i just scratch a bit your code, but i've discovered that with the R21, MCOMMAND_SPLIT only return true. I've opened a bug entry for that. this is fixed in R21.1
  • Mirror a matrix over a defined plane.

    General Talk
    7
    0 Votes
    7 Posts
    2k Views
    D
    @zipit Thank you. That'll help me.
  • ObjectData plugin not rendering to picture viewer

    Moved Cinema 4D SDK
    6
    0 Votes
    6 Posts
    1k Views
    S
    Hello, as now said multiple times, GetActiveDocument() must not be used, but GetDocument() instead. What is the point of your In/Exclude list? Are these the objects you "rotate along the timeline"? This is typically not how a ObjectData object works; it generates objects based on its child objects or deforms objects in its hierarchy. It is not supposed to move arbitrary other objects. As mentioned above, a tag plugin may be the better solution. The "look_at_camera" example show such a plugin rotating its host object. best wishes, Sebastian