Navigation

    • Register
    • Login
    • Search
    1. Home
    2. jochemdk
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by jochemdk

    RE: Slow MoGraph in 2023?!

    Thx for updating.. 2023.1 seems to be working well again

    posted in General Talk •
    RE: Slow MoGraph in 2023?!

    Hi manuel,

    Thx for answering. The first part of my previous reply was native C4D, so I'll send a simple file to regular support.

    As stated in my initial question, I spent almost a day trying to isolate the issue which I thought was an issue within my script, which wasn't the case.

    Seems I have to accept normal instances to be slow & adjust my scripts accordingly.. Thx, Jochem

    Edit / fyi: Just got this back from support: "As I can reproduce your issue here, I reported it to our development."

    posted in General Talk •
    RE: Slow MoGraph in 2023?!

    Hi @iplai,

    Thx for your answer. Changing the mode in 2023 to renderInstance gives me about 40 FPS & multiInstance about 54 FPS. This is still less on my machine, but better than the normal instance :}

    For another script, I'm heavily relying on instances (not the other 2..). Is there anything I can change/adjust/script to make the normal instanceMode work decently? Or is that now something of the past?

    Hope there's some info about it, thx, Jochem.

    posted in General Talk •
    Slow MoGraph in 2023?!

    Hi all,

    Yesterday I was revisiting an old project of mine & spent almost the entire day figuring out why the hell it was so slow in R2023..

    So this morning I made a simple setup, with just a basic cloner - with a plainEffector - who has a moWeight tag as a selection - and where the weightTag is driven by a randomField.. nothing special.

    Running this simple thing in R26 vs 2023 gave an amazing speed reduction - see the image below (on the left)..

    moFPS.jpg

    So, the issue was not my pyScript.. it has about 800 lines of checks & calculations so to me it's fine that it runs 6 FPS slower in R26 than the randomField example. (the image in the middle..)

    Please note the FPS getting even slower when a pyTag is attached to the cloner in 2023. (image on the right)

    Is there some temporary moGraph issue in 2023, or can this be something different?

    Can't see any changes in the docs, Hope someone knows, tia, Jochem

    posted in General Talk •
    RE: In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?

    Done, didn't know I could do it myself :}

    posted in Cinema 4D SDK •
    RE: In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?

    Hi @manuel,

    Thx for your reply. You might be surprised again... your code also works from the main func of a pyTag :} (But that's probably because of the buttons running in the mainThread..)

    Consider it solved, Jochem

    posted in Cinema 4D SDK •
    In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?

    Hi,

    I just installed 2023 and discovered parts of my scripts stopped functioning, because you can’t insert any tag into an In-Exclusion list anymore? :{

    The In-ExclusionData is just a simple userData item on a pythonTag..
    I included a simple script below, which works in previous versions of C4D - Just a pyTag (on a Null) with 3 pieces of user data (2 buttons and an inex List..)

    So, A - I’m hoping this is a temporary bug.
    or B - There’s a new way to automatically insert (especially python)Tags in some sort of list. (couldn’t find any changes in de docs..)

    Please let me know, really need a solution.
    tia, Jochem

    import c4d # just a simple example..
    
    
    def add():
        inexList = op[c4d.ID_USERDATA,3]
    
        item = op # <<< can't insert "op" or other pyTags anymore?..
        item = op.GetObject().GetTag(5698) # e.g. vibrationTag, seems I can't insert any tag..
        item = op.GetObject() # this works..
    
        inexList.InsertObject(item, 0)
        op[c4d.ID_USERDATA,3] = inexList
    
    
    def rem():
        op[c4d.ID_USERDATA,3] = c4d.InExcludeData()
    
    
    def message(id, data):
        if id == c4d.MSG_DESCRIPTION_COMMAND:
            id2 = data['id'][0].id
            if id2 == c4d.ID_USERDATA:
                userDataId = data['id'][1].id
                if userDataId == 1: add()
                if userDataId == 2: rem()
    
    
    def main(): pass
    
    posted in Cinema 4D SDK •
    RE: Ensuring only 1 specific pyTag in a document?

    Hi @ferdinand, Learned a couple of new tricks, almost had a good solution, but in the end it still wasn't 100% safe.. So I decided to just disable the pyTags in such a way they never would be able to initialize again. Not the nicest solution, but anyhow.. Thx for your input - consider the topic closed.

    posted in Cinema 4D SDK •
    RE: Ensuring only 1 specific pyTag in a document?

    Thx @ferdinand for the input, I'll look at it as soon as I can!

    posted in Cinema 4D SDK •
    RE: Ensuring only 1 specific pyTag in a document?

    Hi @ferdinand, thx for your reply. Think I've got some more investigating to do... I've been looking for message-function examples, but there aren't that many (or I use the wrong search terms:).

    If anyone has some examples to get me in the right direction, it would be very much appreciated. Otherwise, just close the topic & I'll have to study harder:) Thx, J

    posted in Cinema 4D SDK •
    RE: Ensuring only 1 specific pyTag in a document?

    Hi @ferdinand, Indeed the above code is checked via the main function of 1 or 2 python tags..
    I’m aware of things you’re not supposed to do with a pythonTag, but sometimes it just works.
    I’ve been testing for over a week now with the above code in py3 & literally not a single problem 🙂

    Ok, so I understand you’re not supposed to give me advise on things I shouldn’t do, but perhaps you can point me in the right direction..
    I use the message function all the time for user data buttons, but how would I proceed to “catch a python tag insert” from a message (id)?

    Tia, Jochem

    posted in Cinema 4D SDK •
    Ensuring only 1 specific pyTag in a document?

    Hi, I've got a prototype/pythonTag running in py2 & py3, where all the basics are just working fine. The problem is that python2 crashes when I try to avoid multiple "MSG" pyTags in one scene/doc...

    I can only have 1 tag per scene since the pyTag adjusts the timeLine where needed. Multiple tags would fight each other..

    I thought of a workaround involving 2 items set to the document container (op & op.GetObject()).
    The basic principle is that I know what/where to delete if a new tag is copied/inserted by the user. (The pyTag itself is set to No_Delete & No_DragNDrop)

    As said, this works fine in py3 (R23/24), but I don't understand why this isn't working in py2 - for I can just read the doc.GetDataInstance & ..GetData(..) etc.

    Any clues on what's causing the crash in py2?
    (and as a sub-question - is there a smarter way to ensure 1 specific tag per scene?..)

    See the check_single_pytag() func below. Tia, Jochem

    def set_doc_bc(uniqueId):
        doc = op.GetDocument()
        docBC = doc.GetDataInstance()
        subBc = c4d.BaseContainer()
        subBc[123] = op
        subBc[124] = op.GetObject()
        docBC.SetContainer(uniqueId, subBc)
        doc.SetData(docBC)
    
    
    def check_single_pytag(): # check pyTag(s) - for there can be only one..
        doc = op.GetDocument()
        docBC = doc.GetDataInstance()
        uniqueId = 12345 # not this :)
    
        def new_null(): # small local func to set pyTag to a new null..
            nully = c4d.BaseObject(c4d.Onull)
            nully.InsertBefore(op.GetObject())
            nully.SetName("MSG")
            nully[c4d.NULLOBJECT_DISPLAY] = 14 # none
            nully.InsertTag(op)
            op[c4d.ID_USERDATA,52] = nully
            op.Message(c4d.MSG_UPDATE)
    
        try:
            docBcTag = doc.GetDataInstance()[uniqueId].GetData(123)
            if docBcTag == op: pass # original tag, so skip
            elif not docBcTag.GetDocument(): # orginal tag deleted - set a new one
                new_null()
                set_doc_bc(uniqueId)
            else:
                # UD52 = linkfield on pyTag with op.GetObject()
                if op[c4d.ID_USERDATA,52] == None or op.GetObject() == doc.GetDataInstance()[uniqueId].GetData(124):
                    op.Remove() # 2nd tag on original pyNull - remove
                    return False
                else: # new/copied tag - remove all..
                    op.GetObject().Remove()
                    return False
        except AttributeError: # no tag in doc yet..
            new_null()
            set_doc_bc(uniqueId)
    
        return True
    
    posted in Cinema 4D SDK •
    RE: Priority Delay on Stacking Skin Deformers

    Hi @m_magalhaes,

    No there's still a problem, but for now it seams to be unsolvable.. It would be nice if C4D would allow for priority changes on the skin deformer - for polygon objects.

    posted in Cinema 4D SDK •
    RE: Priority Delay on Stacking Skin Deformers

    Hi @ferdinand, I was working on a similar topic, trying to change the prio of skin deformers to "after dynamics"... (didn't want to start a new thread, thx for replying anyway:)

    posted in Cinema 4D SDK •
    RE: Priority Delay on Stacking Skin Deformers

    Hmmm… some extra notes: Although it’s possible to change the priority of skin deformers - it’s of no use.
    The documentation states that priorities only will be applied if the “Force” option under “Include” is turned on.
    But that’s not for polygon objects.

    So in my case, I wanted to set skin deformers after dynamics had been applied, but that’s a no-go.
    The only alternative I found was to add an extra pythonTag (Gen.412), which updated all meshes.
    This means that on render time all works well, but in the viewport it will still lag 1 frame 😞

    posted in Cinema 4D SDK •
    RE: Priority Delay on Stacking Skin Deformers

    Hi, @m_magalhaes & the rest,
    Joints & skins work a bit differently than setting priorities in the usual way..
    Basically, only the first line changes @ the "declaration" of pd.

    Hope this helps, Jochem

    for item in items: # .. a list with objects or tags..
    	# prioGeneric
    	pd = item[c4d.EXPRESSION_PRIORITY]
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, 4) # 4 = Generators (as an example..)
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, 412)
    	item[c4d.EXPRESSION_PRIORITY] = pd
    
    for j in joints: # .. a list with joints..
    	# prioJoints
    	pd = j[c4d.ID_CA_JOINT_OBJECT_PRIORITY]
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, 4)
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, 413)
    	j[c4d.ID_CA_JOINT_OBJECT_PRIORITY] = pd
    
    for s in skins: # .. a list with skins..
    	# prioSkins
    	pd = s[c4d.ID_CA_SKIN_OBJECT_PRIORITY]
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, 4)
    	pd.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, 414)
    	s[c4d.ID_CA_SKIN_OBJECT_PRIORITY] = pd
    
    posted in Cinema 4D SDK •
    RE: WeightManager/Autoweight > set the amount of Joints in Python?

    So, now we have a maxon.Int :}
    Yes, the system is working - thx @m_adam
    Consider it solved // more info in general on the maxon framework - especially on the python side - would we be welcome..

    posted in General Talk •
    RE: WeightManager/Autoweight > set the amount of Joints in Python?

    Hi @m_adam, thx for your input, it does reset the WeightManager, but doesn’t do the autoWeighting accordingly..

    _First thing I noticed: a difference between int 64 & 32. Not sure if this might be a problem..
    Reading the GET> AutoWeight…base.jointcount : <int64> “number of joints”
    Reading the SET> AutoWeight…base.jointcount : <int32> “number of joints”

    _After the WeightManager is being set (to 1 joint in my case), I can’t click on the “Calculate button” manually.
    Nothing happens, unless I change the joint count manually to another number. So something in the update hasn’t been applied..
    Note that reading the dict says <int32>, until manually changed, than is says <int64> again..

    _I also tried wmgr.SetDirty(doc) / wmgr.Update(doc) / followed by another c4d.EventAdd().. Perhaps these need a different approach as well?
    I tried to find something in the “maxon/frameworks” folders you linked to, but couldn’t find any info on how to tackle this issue.

    So the current status is still that “default weighting” is applied.
    If you can please help in the right direction, it would be greatly appreciated, tia, Jochem

    import c4d, maxon
    from maxon.frameworks import animation
    
    
    def main():
        doc = c4d.documents.GetActiveDocument()
        wmgr = c4d.modules.character.CAWeightMgr
        #wmgr.SetDirty(doc)
        
        heatmap_id = wmgr.GetAutoWeightAlgoId(doc, 1) # heatmap
        settings = wmgr.GetAutoWeightDictionary(doc, heatmap_id)
        settings.Set(maxon.frameworks.animation.AUTOWEIGHTPARAMETERS.JOINTCOUNT, 1)
        settings.Set(maxon.frameworks.animation.AUTOWEIGHTPARAMETERS.SELECTEDPOINTS, False)
        settings.Set(maxon.frameworks.animation.AUTOWEIGHTPARAMETERS.ALLOWZEROLENGTH, False)
        wmgr.SetAutoWeightDictionary(doc, settings, heatmap_id)
        #doc.ExecutePasses(None,True,True,True,flags=c4d.BUILDFLAGS_NONE)
        c4d.EventAdd()
        
        # getWeightTag - setActive
        firstJoint = doc.GetFirstObject().GetDown().GetDown() # just in my testDoc..
        weightTag = (firstJoint.GetWeightTag())["op"]
        doc.SetActiveTag(weightTag, c4d.SELECTION_NEW)
        #weightTag.GetObject().SetBit(c4d.BIT_ACTIVE)
            
        # update weightManager / doesn't make any difference..
        #wmgr.SetDirty(doc)
        #wmgr.Update(doc)
        #c4d.EventAdd()
        
        # autoWeight func
        wmgr.SelectAllJoints(doc)
        bla = wmgr.AutoWeight(doc)
        print(bla) # prints True, but not in the right way :{
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    
    posted in General Talk •
    RE: WeightManager/Autoweight > set the amount of Joints in Python?

    Super, thx a lot! Will check first thing in the morning :}

    posted in General Talk •
    WeightManager/Autoweight > set the amount of Joints in Python?

    For a particular setup in R23/24, I’m trying to restrict the auto weighting to 1 joint - to avoid blending between weights (which will save me trouble down the line..).

    Since R21 the “ID_CA_WEIGHT_MGR_AUTOWEIGHT_JOINTS” is removed so I can’t set it directly (see the simplified code below).

    I tried to figure out a workaround, with no luck. My thought was that if I could read the autoweightDictonary, I could also set it.
    The function “GetAutoWeightDictionary” needs a stringId (which is a maxon.Id, but that didn’t help me any further..)

    So, the main question: How can I set the amount of Joints (to 1) when autoweighting?
    And of course I don’t mean mannualy :} tia, Jochem

    import c4d, maxon
    
    def message(id, data):
        if id == c4d.MSG_DESCRIPTION_COMMAND:
            id2 = data['id'][0].id
            if id2 == c4d.ID_USERDATA:
                userDataId = data['id'][1].id
                if userDataId == 1:
                    accessWM()
                    c4d.EventAdd()
    
    
    def accessWM():
        doc = op.GetDocument()
        for tag in op.GetObject().GetTags():
            if tag.GetType() == 1019365: wTag = tag
        doc.SetActiveTag(wTag, c4d.SELECTION_NEW)
        wmgr = c4d.modules.character.CAWeightMgr
        wmgr.SetParameter(doc,c4d.ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE,1) # heatmap
        wmgr.SetParameter(doc,c4d.ID_CA_WEIGHT_MGR_AUTOWEIGHT_IN_BIND_POSE,True)
        # ID_CA_WEIGHT_MGR_AUTOWEIGHT_JOINTS // removed since R21 :{
        wmgr.AutoWeight(doc)
        wmgr.Update(doc)
        
        """
        hmmm1 = wmgr.GetAutoWeightDictionary(doc, maxon.Id("AutoWeight"))
        hmmm2 = wmgr.GetAutoWeightDictionary(doc, maxon.Id)
        print (hmmm1, type(hmmm1))
        print (hmmm2, type(hmmm2))
        # both print: <class 'maxon.reference.DataDictionary'>
        """
    
    def main():
        pass
    
    posted in General Talk •