• 0 Votes
    6 Posts
    2k Views
    ferdinandF
    I did that for the same reason @m_adam created a copy in his version: A node can only be member of one document at a time and also only be inserted exactly one time into the same document (long way of saying that Cinema is monohierachical). Cheers zipit
  • Python script for texture baking

    Moved Cinema 4D SDK
    9
    0 Votes
    9 Posts
    2k Views
    M
    Hi @emlcpfx please open a new topic with your exact question and with an explanation about what you call "camera mapped textures". Cheers, Maxime.
  • FIELDLIST SIZE DON'T FIT IN UI

    Cinema 4D SDK python
    7
    1
    0 Votes
    7 Posts
    1k Views
    M
    While the bug is still there I set the topic as solved. I will bump the topic once the fix is in a release. Cheers, Maxime
  • TreeView: c4d.DRAGTYPE_FILES

    Cinema 4D SDK r20 python
    10
    0 Votes
    10 Posts
    2k Views
    M
    Hello Maxime, thanks for that detailed answer. Much appreciated. I see, drawing slows down things massively. (3minutes vs. a few seconds) Bad luck for me then. But it still helped me though, I'm now going for another approach. (The GUI part was just for convenience, so everything is fine) Thank you and cheers, Robert
  • Output all renderpaths

    Cinema 4D SDK r20 r21 windows python
    3
    1 Votes
    3 Posts
    668 Views
    B
    Thanks Maxime! In the mean time I will cycle through takes, AOVs and Frames manually to get the paths.
  • Automate Turbosquid uploading with Python script

    Moved General Talk r21 python jobs
    9
    0 Votes
    9 Posts
    2k Views
    CairynC
    @JasenLux said in Automate Turbosquid uploading with Python script: Even if in the morning I've got a bunch or renders done over night - and it's all automated - I'd be very happy. A more or less automated rendering could be achieved by using the native Render Queue if you create your files with some rigid discipline. Start out by creating a base C4D file that contains the necessary cameras and render settings with some appropriate naming. The render settings should be hierarchically ordered, with the basic setting on top and all the different resolutions as children of that setting, with only the necessary settings overwritten. If there are TurboSquid requirements that you cannot achieve with render settings, you can create some takes that offer the necessary changes (this might be the most difficult part, as you may need to overwrite parameters in tags that you don't have in the basic file, but only create with your project, but that very much depends on what you really need to change, I am not familiar with the TurboSquid requirements. Once that file is set up, you only need to copy your master data into that, save it under the appropriate name, and in the evening add it a few times to the render queue. As you can select the take, rendersetting, and camera for each job, the prepared file can be rendered out without saving multiple versions of it first. (That sounds like some script would make it easier, too, but I just fleetingly looked at the Python and C++ documents about BatchRender, and it doesn't look as if you can control the job settings individually?) I recognize that this would only be good for the rendering part, but... if TurboSquid doesn't offer an official, supported web interface for uploading, then as @zipit said, "hacking" into the protocols would be just one gigantic mess that you don't really want to spend money on as it is very likely to break at the first opportunity. Thanks for mentioning me
  • Disable default Right-Click Menu

    Cinema 4D SDK python r19 r20 r21
    9
    0 Votes
    9 Posts
    2k Views
    U
    @m_adam Thanks! Thats a perfect explanation that solves many of my issues - even in some of my other Plugins. I am sorry, I did in fact refer to c4d freezing when I said crashing. Sorry for the confusion.
  • 0 Votes
    5 Posts
    1k Views
    B
    Thanks! I'll try that.
  • DescID shift operator

    Cinema 4D SDK classic api python r21
    4
    0 Votes
    4 Posts
    526 Views
    M
    This bug is now resolved in R21 sp2. Cheers, Maxime
  • Find nearest position on a geometry

    Cinema 4D SDK r21 python
    6
    0 Votes
    6 Posts
    687 Views
    r_giganteR
    Hi Frank, thanks for reaching out us. With regard to your request, aside from confirming that nothing comes with Python API for obvious performance reasons, in C++ the nearest thing you can find is KDtree - as already pointed out by @zipit - or other similar accelerating structures. On top of these notes, I would consider this topic more a general programming / algorithm-related topic which could find, based on the contour conditions, different "better" solutions. Best, R
  • 0 Votes
    6 Posts
    1k 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
    364 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
    850 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
    2k 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
    867 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
    2k 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!