• VolumeObject ReadObject and WriteObject no supported?

    c++ r20
    3
    0 Votes
    3 Posts
    465 Views
    kbarK
    Thanks Riccardo.
  • CurrentStateToObject returning Null

    10
    0 Votes
    10 Posts
    1k Views
    ManuelM
    hello @rui_mac without futher information i'll change this thread as resolved tomorrow.
  • Use existing data for DynamicDescription

    c++ windows r21
    3
    0 Votes
    3 Posts
    659 Views
    O
    Thanks @s_bach This is very helpful. Best wishes.
  • Python Tag: Matrix is always dirty? (or vice versa)

    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.
  • Asset Manager

    3
    0 Votes
    3 Posts
    592 Views
    S
    Update: the previous version of the code had some ill-formatted statements. You can actually define the scheme as part of the Url, without setting it using SetScheme(): const maxon::Url myUrl { "myassets:///test.txt"_s }; Thus, the path is resolved just by adding the path to the target folder: maxon::String resolvedPath { "file:///c:/assets/" }; resolvedPath.Append(_url.GetPath()) iferr_return; best wishes, Sebastian
  • Vertex Weight Issue

    r21
    3
    0 Votes
    3 Posts
    537 Views
    O
    Did it as you said. They've just answered. It's a know bug they said. Thanks.
  • Mirroring a Pose

    python
    3
    1
    0 Votes
    3 Posts
    452 Views
    ?
    Thank you for the clarification, @zipit.
  • Dirty State with Python Generator

    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
  • Accessing a virtual matrix object.

    c++ sdk
    5
    0 Votes
    5 Posts
    938 Views
    J
    @m_magalhaes Thanks for the response Manuel, that was exactly what I needed. John Thomas
  • First R21 plugin ... memory leaks and dangling references

    r21 c++
    13
    0 Votes
    13 Posts
    2k Views
    C4DSC
    @r_gigante Thanks for the feedback. FYI, this wasn't only with R21, had the same issue with R20, since the "old laptop" was restricted to R20 only. But I guess no updates will follow for R20 anymore.
  • how to get all subobject(children) of active object?

    python r21
    6
    1
    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.
  • Where Can I Find Documentation for Licensing a Python Plugin?

    python
    6
    1
    0 Votes
    6 Posts
    998 Views
    ?
    @kbar Thank you for your response. That's really helpful, thank you.
  • This topic is deleted!

    1
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • How to handle C4D Unicode in Python scripting?

    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.
  • Preventing SetDocumentData from switching to active tool

    python r20 windows
    5
    0 Votes
    5 Posts
    775 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!
  • Howto add a Field input to a python plugin

    python r19 r20 r21
    3
    0 Votes
    3 Posts
    582 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
  • LocalDateTime and UniversalDateTime questions

    r21 c++ maxon api
    5
    0 Votes
    5 Posts
    610 Views
    ferdinandF
    Hi, well, aside from the "at least I am done with it"-approach of just adding 24 hours to each license, there is the static method UniversalDateTime::FromValues() which should be close enough to a FromString(). There is also UniversalDateTime::GetNow(). But the description on that is a bit ambiguous. It says "Return[s] the current date-time object of the current time zone.", while the UniversalDateTime class description says "Class that represents the Universal date-time (UTC+0000)". Unless I am overlooking something here, I would say both cannot be true at the same time, and would expect UniversalDateTime::GetNow() to actually return the current time in UTC +0 (as a UniversalDateTime). The problem with DST is, that it is not anything truly predictable. While your problem could be rooted in a bug, there is a rich history of big organisations struggling with DST (Microsoft, Apple, etc.) and using DST makes you dependent on them maintaining their OS/services properly. On a more light-hearted note: When dealing with standardisation of human conventions I always have to think of this XKCD [image: unicode.png] Cheers zipit
  • BFM_INPUT_DOUBLECLICK in GeUserArea...

    c++ classic api macos
    7
    0 Votes
    7 Posts
    810 Views
    fwilleke80F
    OK, thank you!
  • Can STATICTEXT be multi line?

    4
    0 Votes
    4 Posts
    466 Views
    fwilleke80F
    Thank you, that's what I suspected
  • ObjectData plugin not rendering to picture viewer

    Moved
    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