Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Script Befehl

    Cinema 4D SDK
    r21
    6
    24
    16.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      WDP
      last edited by WDP

      Benötige den Python Script Befehl für Sichtbarkeit im Editor und Sichbarkeit beim Rendern, habe keinen Python Script Befehl gefunden können Sie mir bitte weiterhelfen? Red Button
      Dankeschön!!Picture.png

      1 Reply Last reply Reply Quote 0
      • W
        WDP
        last edited by

        Wenn ich ein Python Funktion mit einen Objekt ausführe funktioniert Sie ganz normal wenn ich jedoch mehrere Objekte Auswähle funktioniert die Funktion nicht gibt es da vielleicht ein Script dafür?
        Dankeschön!

        1 Reply Last reply Reply Quote 0
        • M
          mogh
          last edited by mogh

          https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/index.html#BaseObject.GetEditorMode

          drag n drop the (red dot) into the (c4d) comandline would have get you on track

          https://developers.maxon.net/docs/py/2023_2/classic_resource/base_list/obase.html

          kind regards

          1 Reply Last reply Reply Quote 0
          • a_blockA
            a_block
            last edited by a_block

            I think, the only German speaking person in SDK Team is currently on vacation.
            So, I'll try to jump in:

            Benötige den Python Script Befehl für Sichtbarkeit im Editor und Sichbarkeit beim Rendern, habe keinen Python Script Befehl gefunden können Sie mir bitte weiterhelfen? Red Button

            Question is, how to set the Visibility parameters from a Python script.
            mogh already answered. I may add, the Script Log can be equally of help here.

            German translation of mogh's answer:
            Ziehe einfach die "Sichtbarkeit..." Parameter in die Python Konsole, da hast Du alles was Du brauchst. Alternativ öffne das Skript Log und verändere danach die Sichtbarkeit von Hand. Daraufhin tauchen die nötigen Code Zeilen im Skript Log auf.

            Wenn ich ein Python Funktion mit einen Objekt ausführe funktioniert Sie ganz normal wenn ich jedoch mehrere Objekte Auswähle funktioniert die Funktion nicht gibt es da vielleicht ein Script dafür?

            Question is, why a Python function works with a single object and not with multiple selected?

            The question is so broad and general, it simply can not be answered. We'd need at least some code sample or at the very least some description of what is actually intended.

            Answer in German:
            Die Frage lässt sich so allgemein schlicht nicht beantworten. Ohne irgendein Code-Beispiel oder wenigstens eine Beschreibung dessen, was Du tun möchtest, ist Hilfe unmöglich.

            Some final words:

            Lastly, you should really open one thread per topic/question. Furthermore at least try provide some details, so it is easier to help you. Usually people in this forum (and especially Maxon's SDK team) are really helpful and invest a lot of effort to get people going. It's a matter of respect to at least try to make their job not harder than need be. Also thread topics should be meaningful!

            And in German:
            Letztlich solltest Du wirklich einen Thread pro Thema/Frage eröffnen. Außerdem solltest Du zumindest versuchen, einige Details zu liefern. Damit wäre es einfacher, Dir zu helfen. Normalerweise sind die Leute in diesem Forum (und vor allem das SDK-Team von Maxon) sehr hilfsbereit und geben sich viel Mühe, um den Leuten weiterzuhelfen. Es ist eine Frage des Respekts, zumindest zu versuchen, ihnen die Arbeit nicht schwerer zu machen als nötig. Auch die Überschrift eines Threads sollte einen Sinn ergeben.

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              Hi,

              thanks a lot @a_block and @mogh for jumping in and your answer.

              @WDP please read our forum guidelines we ask you to write your post in English. Even if in the team we can speak several languages, we think that the English will be understood by most of the user out there that might have the same question.

              You already asked the question but you wanted to create keyframe. There is also this thread talking about it and how to change the value of the selected objects using GetActiveObjects.

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • W
                WDP
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • a_blockA
                  a_block
                  last edited by a_block

                  Whut?
                  I'm starting to doubt, we are communicating with a human. Maybe the account got hijacked? Looking at the other thread, the English was way better than the actual German in here.
                  Maybe it's a language barrier. Then I'd suggest to tell us, which language could work better. Maybe we can find somebody to help with translation. Obviously the answers in the other thread did not help and it won't help either, to simply ask again in a different language with even less details.

                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    I agree, he's Austrian so German should not be an issue here.

                    @WDP i will consider your account to be hijacked if your next answer is not in English.

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    1 Reply Last reply Reply Quote 0
                    • W
                      WDP
                      last edited by

                      Ok Sorry I Post the next Trhead in English.
                      That was the Google translator!

                      1 Reply Last reply Reply Quote 0
                      • a_blockA
                        a_block
                        last edited by

                        Kudos to Google Translator, did a pretty good job then.
                        If you are willing to pay a few bucks, I could also talk you through in German while sharing screen.
                        You could find me as MighT over on Core4D forum and DM me there. Or you can mail to job AT andreasblock DOT de.

                        1 Reply Last reply Reply Quote 0
                        • W
                          WDP
                          last edited by

                          Thank you kudos! for the nice Answer!

                          1 Reply Last reply Reply Quote 0
                          • W
                            WDP
                            last edited by WDP

                            M_Magalhaes Thank you for your answer, I'm sorry that I expressed myself so wrongly and asked the same question again.
                            Have you a tip for me, how the keyframe command is for a Python Script?
                            Thank you very much!

                            1 Reply Last reply Reply Quote 0
                            • W
                              WDP
                              last edited by WDP

                              I mean the adtribute palette / base / editor visibility and render visibility key frame i can't find a script command for this click function?
                              Thank you very much!

                              1 Reply Last reply Reply Quote 0
                              • a_blockA
                                a_block
                                last edited by

                                There is no single function to accomplish this. You will need to add a track, a curve and aa keyframe.

                                1 Reply Last reply Reply Quote 0
                                • ManuelM
                                  Manuel
                                  last edited by

                                  hi.

                                  thanks a lot @WDP

                                  as @a_block said, there is no one function solution for that. You need to know how to create a key for that parameter. We have an example on github how to create a track and a keyframe for the coordinates (only the Y track) of an object. If you know how to use DescID, that will be easy to adapt the example. You have our manual about DescID on our c++ documentation that will help you to understand how it works.

                                  I would start using GetActiveObjects and iterate the retrieved objects to display the current state of the "Show in viewport" and after that, trying to add the track and the keyframe.

                                  Cheers,
                                  Manuel

                                  MAXON SDK Specialist

                                  MAXON Registered Developer

                                  1 Reply Last reply Reply Quote 0
                                  • W
                                    WDP
                                    last edited by Manuel

                                    allmost alll functions in C4D have a Script ID and there is no script command for editor visibility and rendering visibility of Renderer( Key Frame) for a Animation? I have an animation and would like to only undef objects from the keyframe for editor visibility and render visibility per Key Frame, why isn't there a script command for these two functions?
                                    Tried the Git Hub sample that only creates new objects.
                                    I just want a script command that lets you control the (attributes base editor visibility and render visibility / Key Frame).
                                    Do you also have a tip for me why can I only control individual objects and not several with this script?
                                    Thank you very much!

                                    import c4d
                                    
                                    def main():
                                        """ Toggles both the render and editor visbilty of the active object.
                                        """
                                        if op is None:
                                            return
                                    
                                    
                                        if op.GetEditorMode() == c4d.MODE_UNDEF:
                                            op.SetEditorMode(c4d.MODE_ON)
                                            op.SetRenderMode(c4d.MODE_ON)
                                    
                                        elif op.GetEditorMode() == c4d.MODE_OFF:
                                            op.SetEditorMode(c4d.MODE_UNDEF)
                                            op.SetRenderMode(c4d.MODE_UNDEF)
                                    
                                        else:
                                            op.SetEditorMode(c4d.MODE_OFF)
                                            op.SetRenderMode(c4d.MODE_OFF)
                                    
                                        c4d.EventAdd()
                                    
                                    
                                    if __name__=='__main__':
                                        main()
                                    
                                    CairynC 1 Reply Last reply Reply Quote 0
                                    • CairynC
                                      Cairyn @WDP
                                      last edited by

                                      @wdp That's not quite correct, the CallCommand IDs and the simple property calls will (almost) never set a key, for example, if you change the subdivision property in a cube, this will be a static change and not set any animation key either. The visibility flags behave exactly the same. Triggering the key-setting is just another functionality, which must be called separately.

                                      If you're interested in this specific group of functions, I have a course
                                      https://www.patreon.com/cairyn
                                      which explains this stuff in section 14.
                                      (Though I am also sure that the PluginCafé has the answer for free already, I remember the topic being discussed, but you may need to search for it, and perhaps study the API some more. Also, as @m_magalhaes said, there is a Maxon Github example where you can copy and paste code from.)

                                      Once you understand the way keys are handled, you can create a function that works for any DescID (or copy it...), which is probably what you want.

                                      As for your other question, you are calling the EditorMode functions on the op variable which is a predefined variable containing a single selection. If there are no objects selected OR there is more than one object selected, then op will be None so your call causes an error.
                                      To handle more than one selected object at a time, you need to retrieve a list of selections by calling GetActiveObjects ( @m_magalhaes said that as well) and then go through a for loop calling the functions for every object in the list.

                                      1 Reply Last reply Reply Quote 0
                                      • ManuelM
                                        Manuel
                                        last edited by

                                        @wdp said in Script Befehl:

                                        allmost alll functions in C4D have a Script ID and there is no script command for editor visibility and rendering visibility of Renderer( Key Frame) for a Animation? I have an animation and would like to only undef objects from the keyframe for editor visibility and render visibility per Key Frame, why isn't there a script command for these two functions?

                                        You mean that the script log does not log it correctly? That could be considered as a bug, but the script log does not log everything.

                                        I 'am not sure if you are asking to someone to do the work or want to learn how to do it?
                                        I linked you this thread where i added some code to toggle the viewport and render setting from default to off for all the selected objects, using GetActiveObjects

                                        Based on examples found on github you can do something like this. You would need to add the Undo step, please have a look at our manual to understand how it works

                                        Of course, you must add the check for the render track. That can be done by creating an array of descID and with a loop you can check several tracks.

                                        from typing import Optional
                                        import c4d
                                        
                                        
                                        def IsThereAKey (obj) -> None:
                                             # Searches object's view track
                                             # For that the track ID must be defined and created. DescID are composed of descLevel. See c++ manual for more information
                                            trackID = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_VISIBILITY_EDITOR, c4d.DTYPE_LONG, op.GetType()))
                                            # With the track ID, FindCTrack can be used to retrieve if a track exist for this object.
                                            track = obj.FindCTrack(trackID)
                                            if track is None:
                                                raise RuntimeError("Failed to retrieve the track, Object may not have a visibility track.")
                                        
                                            # Retrieve the curve from the track. For more information see our track manual 
                                            # https://developers.maxon.net/docs/cpp/2023_2/page_manual_ctrack.html
                                            curve = track.GetCurve()
                                            if curve is None:
                                                raise RuntimeError("Failed to retrieve the curves, Object may not have curves.")
                                            # Retrieve the document current time to see if a key exist for that frame
                                            time = doc.GetTime()
                                            # try to find a key at the current time of the document
                                            found = curve.FindKey(time)
                                            if found is None:
                                                raise RuntimeError("Could not find key at given BaseTime.")
                                        
                                            # The key information can be or the key can be deleted.
                                            # To delete the key, the function DelKey will be used
                                            
                                            # The index of the retrieved key
                                            index = found["idx"]
                                            # The retrieved key
                                            key = found["key"]
                                            print (index, key)
                                            # To delete the key, the function DelKey will be used
                                            curve.DelKey(index)
                                        
                                        
                                        def main() -> None:
                                        
                                            allobj = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
                                            for obj in allobj:
                                                IsThereAKey(obj)
                                            c4d.EventAdd()
                                        
                                        if __name__=='__main__':
                                            main()
                                        

                                        Cheers,
                                        Manuel

                                        MAXON SDK Specialist

                                        MAXON Registered Developer

                                        1 Reply Last reply Reply Quote 0
                                        • W
                                          WDP
                                          last edited by

                                          Thanks for the script that deletes a key frame, but do you also have a script that adds the key frame?

                                          1 Reply Last reply Reply Quote 0
                                          • ManuelM
                                            Manuel
                                            last edited by Manuel

                                            hi,

                                            I already pointed you to our github repository and our example to create a track and a keyframe in this post. 22 days ago. The purpose of this forum is to answer people's question, not to develop their tool. Please read our forum guidelines. Is there anything topic you do not understand to create your script, or what part are you struggling with?

                                            Cheers,
                                            Manuel

                                            MAXON SDK Specialist

                                            MAXON Registered Developer

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post