Navigation

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

    C4DS

    @C4DS

    66
    Reputation
    401
    Posts
    381
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Location Rupelmonde Age 52

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

    Best posts made by C4DS

    RE: Send message to tooldata

    If I remember correctly we did discuss the other way (from CommandData to ToolData) quite a while ago (see https://plugincafe.maxon.net/topic/10044/13513_using-objectmessage). But I guess using this same technique could still be applicable to your current request.

    Most important is to understand that a CoreMessage is not captured by a ToolData. This type of message can only be captured by a MessageData plugin, where you then could "translate" it into a message that actually is sent to the ToolData.

    What I have been successful in using is, performing following from the "transmitter":

    BasePlugin* tool = FindPlugin(TOOL_PLUGIN_ID, PLUGINTYPE::TOOL);
    if (tool)
    	tool->Message(TOOL_MSG_PREPAREDATA);
    
    

    Where TOOL_PLUGIN_ID is the plugin ID of the ToolData, and TOOL_MSG_PREPAREDATA is a custom defined message, using a unique plugin ID.

    And then using following in the "receiver" ToolData:

    Bool MyToolData::Message(BaseDocument *doc, BaseContainer &data, Int32 type, void *t_data)
    {
    	if (type == TOOL_MSG_PREPAREDATA)
    	{
    		PrepareData();
    	}
    
    	return DescriptionToolData::Message(doc, data, type, t_data);
    }
    
    
    posted in Cinema 4D SDK •
    RE: Shortcuts for buttons from gui.GeDialog

    You cannot assign shortcuts to buttons.
    An alternative solution (which I have used in the past) is to create a CommandData plugin for each button, and let the CommandData::Execute call the button. Or instead of a CommandData plugin you could also create a separate script for each button.
    Either way, these can then be assigned a shortcut.

    posted in Cinema 4D SDK •
    RE: Bug on GetActiveObjects() on R20.057?

    @bentraje said in Bug on GetActiveObjects() on R20.057?:

    objSel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
    print objSel[0]
    print objSel[1]

    Works fine by me.

    I have a cube and a plane primitive. With the two selected, I get a printout for both. No out of range.
    Running 20.057 (on Windows).

    <c4d.BaseObject object called 'Plane/Plane' with ID 5168 at 0x0000004C44847570>
    <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0000004C448476D0>
    
    

    When I only select a single object then I get an out of range (obviously):

    IndexError: list index out of range
    

    EDIT:
    Hang on, when I make one the child of the other and have both selected, I do get an out of range.
    But this is obvious, since your active objects flag doesn't mention children. As such, you do only have a single parent object selected.

    To take children into account as being detected as selected, you need:

     objSel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER | c4d.GETACTIVEOBJECTFLAGS_CHILDREN )
    
    
    posted in Cinema 4D SDK •
    RE: Toggle Attribute Manager from Tool to Object Mode and Vice Versa
    import c4d
    
    def main():
        c4d.gui.ActiveObjectManager_SetObject(c4d.ACTIVEOBJECTMODE_OBJECT, op, 0, c4d.ACTIVEOBJECTMANAGER_SETOBJECTS_OPEN)
    
    if __name__=='__main__':
        main()
    
    posted in Cinema 4D SDK •
    RE: Recent spam boom

    spam frenzy all over again, lately.

    posted in Maxon Announcements •
    RE: detect the selection of an object

    I have been in need of something similar as well. And if I remember correctly it has been discussed a few years ago.
    Reason is that a ToolData or DescriptionToolData might need to initialize some stuff depending the currently active object. When the user selects a different object in the ObjectManager, the ToolData might need to reinitialize some stuff.

    The solution proposed in the past was to use a MessageData and listen to EVMSG_CHANGE to check if a different object has been selected using the object's "unique" id and then trigger the ToolData by sending a SpecialEvent ... or something.

    It is quite a complex implementation that seems to work, but probably is very error prone.
    I wish we would have had some kind of message telling the active object selection was changed (from inside the ToolData), not via-via. And definitely not using such a hacky and complex solution.
    It has been a while, but I seem to remember that the whole use of the object's unique id was rather flawed as the id didn't exactly seem to be that unique after all.

    Anyway, I am still hoping for a nice solution to detect when user changes the current active object. But it seems to not be possible after all.

    posted in Cinema 4D SDK •
    Best Wishes to the team

    I am less active since a few months, and this will probably not change any time soon, but let that not restrict me for sending Best Wishes for 2021 to everyone of the SDK team.
    Not only to those more present and visible in the forums, but also to those behind the scenes that keep everything running.

    Thank you for your 2020 support and best wishes for 2021.

    posted in Maxon Announcements •
    RE: Calling a Tool (Naming Tool) and Modify the Parameters

    You need to obtain the tool's data in order to be able to modify/set it.
    The callcommand just activates the tool.

    import c4d
    
    def main():
    
        # activate the command
        c4d.CallCommand(1019952)
    
        # change its settings
        nTool = c4d.plugins.GetToolData(doc, 1019952)
        nTool[c4d.ID_CA_JOINT_NAMING_REPLACE] = "_L_"
        nTool[c4d.ID_CA_JOINT_NAMING_REPLACE_WITH] = "_R_"
    
    # Execute main()
    if __name__=='__main__':
        main()
    
    posted in Cinema 4D SDK •
    RE: Calling a Tool (Naming Tool) and Modify the Parameters

    In the above code "nTool" is a BaseContainer, that won't work.

    I also found the following in the legacy forum

    import c4d
    
    def main():
        
        toolID = 1019952
        c4d.CallCommand(toolID) 
    
        tool=c4d.plugins.FindPlugin(toolID, c4d.PLUGINTYPE_TOOL)  
        tool[c4d.ID_CA_JOINT_NAMING_REPLACE] = "_L_" 
        tool[c4d.ID_CA_JOINT_NAMING_REPLACE_WITH]= "_R_"
        c4d.CallButton(tool, c4d.ID_CA_JOINT_NAMING_REPLACE_APPLY)  
        
        c4d.EventAdd()
    
    

    Another take on modifying the settings, since the "tool" returned from FindPlugin is a BasePlugin which is derived from BaseList2D, exactly what we need for the CallButton

    posted in Cinema 4D SDK •
    RE: Unusual Remove() Results

    The geometry of an object is stored in hidden tags (points and polygons, namely)
    These are not visible, nor selectable ... and thus can theoretically not be deleted by user. But you still can access these via Python, or C++. As such, when removing all tags you also remove critical ones, that are needed by the object in order to exist.

    posted in Cinema 4D SDK •

    Latest posts made by C4DS

    RE: How to detect CTRL being pressed in a GeDialog

    Thanks @m_adam
    I can confirm that the following does work with R20, R23 and 2023

    Int32 MyDialog::Message(const BaseContainer& msg, BaseContainer& result)
    {
    	BaseContainer keyChannels;
    	if (GetInputState(BFM_INPUT_KEYBOARD, QCTRL, keyChannels))
    	{
    		Bool ctrlModifier = (keyChannels.GetInt32(BFM_INPUT_QUALIFIER) & QCTRL) != 0;
    
    
    posted in Cinema 4D SDK •
    RE: Removing IsolateObjects document

    I was reading the original R20 documentation, when the above question popped up.
    Luckily, the latest online SDK documentation contains a BaseDocument Manual, where it mentions (if I understand it correctly) that KillDocument is to be called to remove a BaseDocument from the list.
    Which means KillDocument should only be used if a BaseDocument was created and inserted in the list (via InsertBaseDocument).

    So, as long as I use IsolateObjects without performing an InsertBaseDocument I should be fine with calling BaseDocument::Free to free the obtained basedocument.
    If I perform an IsolateObjects and subsequently call InsertBaseDocument then I should use KillDocument.
    Correct?

    posted in Cinema 4D SDK •
    Removing IsolateObjects document

    I am using IsolateObjects to copy an object into a separate document in order to render a preview of the isolated object.

    The documentation mentions "The caller owns the pointed document."
    Do I simply need to perform a BaseDocument::Free on the obtained document?
    Or do I need to call KillDocument?

    posted in Cinema 4D SDK •
    RE: Can we add a folding option for the code block when searching

    see also
    https://plugincafe.maxon.net/topic/13376/search-results

    posted in General Talk •
    RE: How to detect CTRL being pressed in a GeDialog

    The following works in R20

    Int32 MyDialog::Message(const BaseContainer& msg, BaseContainer& result)
    {
    	BaseContainer keyChannels;
    	if (GetInputEvent(BFM_INPUT_KEYBOARD, keyChannels))
    	{
    		const Int32 qualifier = keyChannels.GetInt32(BFM_INPUT_QUALIFIER);
    		ApplicationOutput("qualifier @", qualifier);
    	}
    

    It shows a value '2' when I press CTRL key, '0' when I let go.

    But in R23 (and above), I don't get any output in console window.

    posted in Cinema 4D SDK •
    How to detect CTRL being pressed in a GeDialog

    I am in a GeDialog and have a button that is by default disabled.
    I want to enable it as long as CTRL key is being pressed.

    posted in Cinema 4D SDK •
    RE: Notify CommandData Plugin from a PreferenceData Plugin

    I ma not familiar with PreferenceData, but maybe the following might help you:
    https://plugincafe.maxon.net/topic/13379/send-message-to-commanddata

    In short: you let the PreferenceData call your CommandData's ExecuteSubID via a specific unique ID (similarly obtained from plugincafe as a pluginID).
    The CommandData knows if that specific subID is called that it should react to a change of preferences.

    Not the most elegant solution, and maybe there are ways to do this directly from PreferenceData, but as said I am not familiar with it.

    posted in Cinema 4D SDK •
    RE: GePrint no longer works?

    If I remember correctly, most strings now need to be of type maxon::String. Can't remember in which version this was introduced (and that doesn't really matter).
    Since then you could be using suffix _s
    GePrint("Print this string..."_s);

    There are different ways to output to the console, but I am now mainly using ApplicationOutput.

    Wasn't this listed in one of the "API Changes in Rxx"?

    posted in Cinema 4D SDK •
    RE: Updating my r20 C++ plugins to r21 and up

    For a start some of the methods of CommandData have received an additional argument GeDialog *parentManager.

    Apart from that I would suggest to just setup an R21 (and up) environment(s), port your project files to these, and start building the plugins.
    From the errors you encounter you might find out what needs to be changed.

    I know, this sounds quite a lot as "trial and error", but that's the only advice I have right now.
    Unless you want to dig through all the SDK documentation's "API changes in R21, S22, R23, S24, R25, S26"

    Once you have adapted your source files for macOS, you will be able to just take these over in your Windows (updated) projects, and build the plugins for PC.

    EDIT:
    I myself had set up on Windows an "SDK_Rxx" folder per release, and had extracted the SDK into these, together with the specific projecttool per release.
    Same for macOS, but there I had prepared an external SSD with different OS versions, and XCode installs.
    (example: Sierra -> R20 + XCode 9, High Sierra -> R21 + XCode 10, Mojave -> R23 + R25 + XCode 11)

    posted in Cinema 4D SDK •
    RE: Detect CTRL + RightMouseButton in SceneHook

    No worries.
    From your reply it seems this is a bug that is being tackled in a future release.
    I don't mind this being fixed, but was hoping for another solution (or workaround) to be available for current and older versions (I am still on R20).

    However, if using the MouseInput is the only way to go for detectig CTRL+RMB (with known limitations) then I guess we can close this topic.
    Thank you for your time.

    posted in Cinema 4D SDK •