Navigation

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

    Posts made by gheyret

    CommandData Plugin DrawHUD

    Hi Everyone!
    I want to Draw HUD in the viewport using CommandData Plugin. And i put my 'draw' function in to CommandData.GetState(self, doc)
    but nothing happend in the viewport.
    And the code like this:

    import c4d
    
    
    _Plugin_id = 20230616
    _Plugin_name = "Command_Test"
    
    
    class Command(c4d.plugins.CommandData):
    
        def __init__(self):
            self.a = False
    
        def Execute(self, doc):
            if self.a:
                self.a = False
            else:
                self.a = True
            print(self.a)
    
            return True
    
        def GetState(self, doc):
            if self.a:
                print(123)
                bd = doc.GetActiveBaseDraw()
                bd.SetMatrix_Screen()
                bd.DrawHUDText(50,50, "Test HUD")
                
                return c4d.CMD_VALUE | c4d.CMD_ENABLED
            else:
                return c4d.CMD_ENABLED
    
    if __name__ == '__main__':
        c4d.plugins.RegisterCommandPlugin(id=_Plugin_id, str=_Plugin_name, 
                                    info=0, icon=None, help='', dat=Command())
    

    And there have another problem: you can see the "print(123)" in the GetState
    method for testing, when i click my plugin, cinema4d can print correctly and continuosly in the console, but if i move my mouse to the viewport or click somewhere (like refreshing maybe), the cinema4d has been stucking.
    I don't know if I'm wrong or misunderstood something

    posted in Cinema 4D SDK •
    RE: c4d.EventAdd() is not working

    Hi @m_adam I am using Windows 10

    posted in Cinema 4D SDK •
    RE: c4d.EventAdd() is not working

    I get a solution:
    1.Create a material and insert it
    2.EventAdd()
    3.delete the material
    code like this:

    mat = c4d.Material(5703)
    doc.InsertMaterial(mat)
    c4d.EventAdd()
    mat.Remove()
    

    But this is not the correct way

    posted in Cinema 4D SDK •
    c4d.EventAdd() is not working

    There is a problem;
    When i try to add some object in the scene and add c4d.EventAdd() , the object added correctly and viewport is refreshed but nothing happed in Object Manager, i need to click some button to refresh the object manager.

    import c4d
    
    def main() -> None:
        doc.InsertObject(c4d.BaseObject(c4d.Onull))
        c4d.EventAdd()
    
    if __name__ == '__main__':
        main()
    

    Is that BUG or something changed ?
    Oh, i used Cinema 4D 2023.2.1 version.

    posted in Cinema 4D SDK •
    RE: How to get the object newly added in current scene?

    Hi @ferdinand , I get it ! Thanks again to your reply!

    posted in Cinema 4D SDK •
    RE: How to get the object newly added in current scene?

    @ferdinand
    I mean i Get the Object Data using BaseList2D.GetData() and SetDatato another object, it's only change the parameter of "Object" Tab in Attributes Manager.
    Hera is a exmaple:

    from typing import Optional
    import c4d
    
    doc: c4d.documents.BaseDocument  # The active document
    op: Optional[c4d.BaseObject]  # The active object, None if unselected
    
    def main() -> None:
        new = doc.GetFirstObject()
        old = new.GetNext()
        
        old.SetData(new.GetData())
        
        c4d.EventAdd()
    
    if __name__ == '__main__':
        main()
    

    Before run the script
    01.png

    After run the script
    02.png

    As you can see, the object name, visibilitys and display color is not changed by SetData

    posted in Cinema 4D SDK •
    RE: How to get the object newly added in current scene?

    Hi @ferdinand , thanks to your reply.
    There is another quession; the basic property (like Name, Viewport visibility, Enabled, e.t.c) of object is not in the data container? I mean the c4d.BaseContainer returned by c4d.BaseList2D.GetData()

    posted in Cinema 4D SDK •
    RE: How to get the object newly added in current scene?

    @dunhou
    Cool man ! That's what i want !
    I actually thought about traverse everything in the scene, but I felt it would be a waste. for example, if there were a lot of objects in the scene, so I think if there was another way to do that. But based on your post, that's the only way to do.
    Anyway , thank you and @ferdinand
    Cheers~:clinking_glasses:

    posted in Cinema 4D SDK •
    How to get the object newly added in current scene?

    Hi plugincafe~
    I want to get the object newly added in to current scene in my Dialog plugin and update something in my dialog.

    For example:
    Add something in the scene(like a null object), how do i get this object? and how to get this Message?

    I find c4d.EVMSG_CHANGE in SDK and i can get some document changed message in CoreMessage. But I don't know what to do next.

    posted in Cinema 4D SDK •
    RE: How to get and create redshift light groups with python?

    @manuel
    Cool ! Thank you ~

    posted in Cinema 4D SDK •
    How to get and create redshift light groups with python?

    Hi everyone~
    How did i create and get redshift light groups with python ?

    posted in Cinema 4D SDK •
    RE: Can i get global input event ?

    @ferdinand
    Wow~ Thank you so much bro

    posted in Cinema 4D SDK •
    Can i get global input event ?

    Hello everyone~
    I have a GeDialogwindow now. and i want to close it when my mouse click in anywhare.
    I can get the mouse click event in GeDialog.Message(), but it's just work inside of dialog.
    So i think maybe i need to get the global input event . But i can't find any method in SDK.
    How do i do that?

    posted in Cinema 4D SDK •
    RE: Material and Shader Questions

    @m_adam
    OK~ Thank you so much!

    posted in Cinema 4D SDK •
    Material and Shader Questions

    Hi guys!
    I want to get the shader preview image , but i can't find any method in Python SDK.

    So the question is :
    is there have some tricks to get shader preview image ?

    Another question is :
    Is that posible to change Material Preview size before i use BaseMaterial.GetPreview() ?
    Because i see the material preview image size is 90*90, it's small to me.

    posted in Cinema 4D SDK •
    RE: OpenGL in Cinema 4D

    @fwilleke80
    Yes, it's a solution. But it's can not to orbiting the scene or transforming the model.
    I think i need to make a desktop application, and make sure the window always on top.
    However, this will lead to more work for me.
    And thanks to your reply!
    cheers:clinking_glasses:

    posted in Cinema 4D SDK •
    RE: OpenGL in Cinema 4D

    @ferdinand
    Hi!
    Actually, i developed a simple model viewer using PyOpenGL and GLFW(for the window).
    And i don't know if i can use CINEMA 4D VIEWPORT(replace the GLFW) to show my own OpenGL things.
    So , clearly i need a dockable opengl window. is that possible?

    posted in Cinema 4D SDK •
    OpenGL in Cinema 4D

    hello everyone!
    is that posible to attach an OpenGL window to Cinema 4D GUI using python?
    if posible , how can i do that?

    posted in Cinema 4D SDK •
    RE: ShowBitmap() from website URL

    @ferdinand
    Wow! you perfectly solved my problem!
    Thank you! :beers:

    posted in Cinema 4D SDK •
    ShowBitmap() from website URL

    Hi! plugincafe~
    I try to get an image from website, And ShowBitmap() in C4D python.
    This is my simple code:

    import c4d
    from c4d import gui, bitmaps
    
    def main():
        img = "https://images.pexels.com/photos/10204089/pexels-photo-10204089.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
        bmp = bitmaps.BaseBitmap()
        a,b = bmp.InitWith(img)
        print(a,b)
        if a == c4d.IMAGERESULT_OK:
            bitmaps.ShowBitmap(bmp)
        bmp.FlushAll()
        
    # Execute main()
    if __name__=='__main__':
        main()
    

    Sometimes it can ShowBitmap() correctly like this:
    01.jpg

    Sometimes it's can show bitmap but the image is not loaded correctly:
    02.jpg

    And sometimes it's faild! And the InitWith() result is -6
    Is there have some right way to show an image from the URL?

    posted in Cinema 4D SDK •