Navigation

    • Register
    • Login
    • Search
    1. Home
    2. John_Do
    John_Do

    John_Do

    @John_Do

    0
    Reputation
    10
    Posts
    5
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    John_Do Follow

    Best posts made by John_Do

    This user does not have any upvoted posts yet.

    Latest posts made by John_Do

    RE: With the new asset browser, API for the content browser is no longer possible?

    Thank you @ferdinand !

    I forgot to ask something, do you know if Python support planned or is it unlikely ? Is there technical reasons behind the lack of Python support for Content Browser, and now Asset Browser ?

    posted in Cinema 4D SDK •
    RE: With the new asset browser, API for the content browser is no longer possible?

    @ferdinand said in With the new asset browser, API for the content browser is no longer possible?:
    One of the major entry points for the new asset system is AssetRepositoryInterface in C++.

    Hi,

    I'm taking advantage of this topic to clarify something : if I've understood right is no way at the moment to access to the new Asset Browser with Python ?

    Thank you

    posted in Cinema 4D SDK •
    RE: Select and load multiple files at once

    Hi @m_magalhaes ,

    Sorry for the improper formatting of my question, I wasn't aware of these features.

    Thank you for the suggestion, the workaround can do the trick with the right safety precautions.

    posted in Cinema 4D SDK •
    Select and load multiple files at once

    Hello all,

    I'm looking for a way to load multiple files of the same type at once through a script. Image files in this case.
    I'm using the c4d.storage.LoadDialog function but it doesn't offer a setting to do a multi-selection.

    It wasn't possible before, is it still the case ?

    Thank you

    posted in Cinema 4D SDK •
    RE: From string to constant to check type

    Thank you for the explanation @ferdinand.

    The example makes sense even for a beginner like me, that's great 🙂

    posted in Cinema 4D SDK •
    RE: From string to constant to check type

    Hi @ferdinand,

    In fact I think I was looking for the eval() method which I know but somewhat have forgotten.

    Thanks for pointing the fact that using it could be dangerous, but in this particular context I'm not sure to understand why ? I'm not a seasoned coder ( far from it ) but the linked article seems to point security issues in the context of using eval() in conjunction with input(), which is not the case here.

    I'm doing this mainly to practice Python as much as possible, but I guess it is wasted computing power since these symbols are not changing anytime soon.

    Anyway, I've learned some things, thank you for the help, much appreciated !

    posted in Cinema 4D SDK •
    From string to constant to check type

    Hello !

    I've wrote a simple function to store some constants in a list, from a string ( because I'm lazy) :

    def geoTypeList():
        geo_constants = "tube,cube,plane" # not the full list
        geo_types = [("c4d.O" + i) for i in geo_constants.split(",")]  
        return geo_types # return the list
    

    I was happy with my solution until I've tried to use it :

        for i in objs:
            if i.GetType() in geoTypeList():
                print(i.GetName(), "is a", i.GetTypeName(), i.GetRealType())
            else:
                print("Not a geometry object")
    

    I've tried many times and many variant until I've realized that I'm trying to check a constant against some strings, so it can't work. But I'm stuck here, I don't know how to pass the list items as constants and not as string.
    Also before you ask, why I'm not just using ID integers ? Because I would like to keep the code easily readable, and the docs use the constants and symbols.

    Thank you,

    posted in Cinema 4D SDK •
    RE: Python, tool attributes and hotkeys

    @m_magalhaes Yes please, and sorry for the delay :3

    posted in Cinema 4D SDK •
    RE: Python, tool attributes and hotkeys

    Hello guys,

    Thank you for your detailed answers and sorry for the delay, I was on holiday.

    @Cairyn
    Sorry for the misunderstanding, in my mind hotkeys = shortcuts, I didn't want to make any particular distinction. What you described is also called Sticky Keys in some softwares.
    To answer your questions : I want to be able to modify tool settings / attributes while the tool is enabled AND in interactive mode. Since I don't want to bother with gazillions of shortcuts and multiple keyboards, it has to be context sensitive so I can use the same set of keys with many tools.

    But a picture is worth a thousand words, so I made a little demo of what I want to achieve in C4D : Modal Bevel Shortcuts demo

    As you can see, the shortcuts allows to modify tool settings in real time, without loosing the ability to enter values manually in the attributes fields. What you don't see is that I can use the same set of keys with many tools and in the same fashion ( one key to toggle an option, two other to add / sub values like segments, number of clones etc. ). This software is context-sensitive by design at many levels and allow this kind of customisation without scripting.

    @m_magalhaes
    Thank you very much for the detailed answer and the script example. I have to take a deeper look at it but it works, and I've made two other scripts from it to simulate what I show in the link above. Please take a look : Cinema 4D - Modal Bevel Shortcuts POC #1

    As you can see

    • the part with the shortcuts works : I can press keys and alter active tool settings as expected.
    • but the tool is no longer interactive, so when I want to alter the bevel radius, it doesn't work. I have to undo and restart the bevel.

    So these results are encouraging but there is room for improvements :

    • Is there is a way to alter the current tool settings values without loosing the tool interactivity ? An access to some kind of "tool buffer" ?
    • Let's say I want to add function for others tools in the same way. Wouldn't the script become too slow at some point if there is many if c4d.IsCommandChecked() commands ?
    • Is there is a way to gather all the commands in one file / script but output as many commands as shortcuts needed ? Right now I have one script per command, it's a bit clunky.
      I guess plugin and command registering is the answer ?

    Thanks,

    posted in Cinema 4D SDK •
    Python, tool attributes and hotkeys

    Hello,

    Python beginner here, my goal is to write a script or a plugin to interact with some (active) tool attributes through a predefined set of hotkeys. In short, context-sensitive hotkeys. As a bonus goal, I would like to add some settings in the Preferences window to change the hotkeys.

    Until now I've managed to write simple python scripts ( but you can call it macros ), like these lines to change bevel mode f.e. :

        if c4d.IsCommandChecked(431000015) is True : 
            if tool()[c4d.MDATA_BEVEL_MASTER_MODE] == 0:
                tool()[c4d.MDATA_BEVEL_MASTER_MODE] = 1
            else:
                tool()[c4d.MDATA_BEVEL_MASTER_MODE] = 0
            
        c4d.EventAdd()
    

    It kind of works but it doesn't affect the active tool, only the UI.

    And that's all for the moment. The SDK isn't really useful since I don't know where to start and how implement this, plus I guess there may be some specific constraints due to the interactive part.

    So I would like to get some clues on the best way to tackle this. I've watch many C4D Python tutorials, look through the docs, the Python SDK and read few scripts but it doesn't make sense yet. Like baseContainer, what is this thing and why I have to call it to interact with a tool ? ( I'm really a beginner )

    From what I've read what I want to do is not possible with a simple script, I should rather write a plugin to have the code running in background to evaluate tool activation and keystrokes. Is that correct ? Is it why the script doesn't trigger the active tool ?

    Thanks,

    posted in Cinema 4D SDK •