Like this post if you are a Python Developer.
Best posts made by kbar
-
RE: How many C++ and Python devs do we have here?
-
C++ Plugin Development Tutorials
I created a short series of getting started videos for anyone just starting out developing C++ plugins for Cinema 4D. I hope you find them useful.
https://www.youtube.com/playlist?list=PLEPTxkpDVvX0r292yn8xL39Cm3Wi3E69i
-
How many C++ and Python devs do we have here?
I am just curious to know how many C++ developers we have here.
Since we don't have polls on this forum can you do the following...
Like this post if you are a C++ Developer.
-
Documentation Plugin
Hi everyone,
I have released a plugin I use to create documentation for my plugins.
The plugin is free. Currently available for R20 for Windows. I will add an OSX version if people ask for it.
https://www.plugins4d.com/docs
If you use it for anything let me know. Also if you have any features requests then send them my way.
Cheers,
Kent -
RE: How many C++ and Python devs do we have here?
Like this post if you are using the new Node System to create features.
-
Ray Tracing In One Weekend
I have posted my source code for the integration of Peter Shirleys Ray Tracing In One Weekend series to github.
https://github.com/kentbarber/rtow4d
This might be of interest to anyone wanting to play around with writing their own ray tracer.
You can also download a compiled version from here: https://plugins4d.com/Product/FunRay
Cheers,
Kent -
RE: Project Tool failing when installing on Mac
Try using the absolute path to where your sdk is: /Users/YourName/Documents/C4D/sdk
https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_projecttool.html
g_updateproject: Defines the folder the tool should work on. Currently the tool only accepts absolute paths. This is typically the location of the SDK including frameworks and plugins. See SDK Overview.
-
RE: Using "config" plugins to modify the loading queue in R19
You can use SetPluginPriority to tell your plugins to load in a specific order. IE tell some plugins to load after others have been loaded. Useful in cases where one of your plugins may register a library that your other plugins need to access as they start up.
-
Do not delete your posts once you get an answer
Yesterday I helped someone out with a question. Now they have marked it as deleted. The only reason I would help out on this forum is to help everyone and add to the knowledge pool here in this forum.
So please... do NOT delete your post if you received the answer you were looking for.
-
Something to watch out for with GetAllAssets
I just found that in S22 they have inverted the behaviour of a flag for GetAllAssets.
In R21 there existed a flag ASSETDATA_FLAG::MISSING.
From S22 onwards the functionality of this flag has been inverted and it is now called ASSETDATA_FLAG::NOMISSING.
The problem is that it sets the exact same bit.
So if you have a plugin that is compiled against R21 and your users use it in S22 then your code will not be getting the missing assets anymore, since this bit is set (if you use the MISSING flag) and it will now mean DO NOT get missing assets.
Compiling against the S22 SDK and removing the MISSING flag will fix your bugs if you have any.
Just something to watch out for if anyone is hearing of problems from your users relating to gather up assets. Mainly applies to people writing renderers and dealing with textures and materials.
Cheers,
Kent -
RE: Goodbye
It has been absolutely amazing having you here for the past 5 years. I can't believe it has been that long already. Thank you for all your help and the best of luck for your future!
Cheers,
Kent -
RE: Python: Global Variable vs Plugin ID
I am not exactly sure how it works in Python but I will give you a run down of how Global Variables work in C++.
If you set a global variable in C++, and you are using it in a Generator Object, then that variable will be exactly the same in every object in every document that you have open. So if you change the value of it on any object (again in any document you have opened) it will be changed across everything. That is the definition of a global variable. It is global, it is the same everywhere.
Now it may not work exactly like this in python depending on how it is setup in C4D. But in general it is a bad idea to use this for ay variable in something like a generator object.
So even though it might be working for now in a basic test scene, it will come back to bite you once you use it for anything more complex, such as two or more objects.
It all comes down to what it is that you are trying to achieve and what this data is that you are using in a global variable.
In C++ you could use a SceneHook to hold scene wide data. But I don't think that is in Python yet, so the best option to use scene wide data is to use a PluginID as your way to access that data in the preferences for your scene.
For storing a matrix value to compare why don't you just use a local variable in the generator object itself?
Also I would avoid using the word "Save" when you discuss this data, since "saving" and "persistent" mean writing data to disk. And that is not what you are doing. But if you did want to save the value then just make the matrix a description in the resource files for your object generator and access it using the BaseContainer. Then it will be saved automatically.
Cheers,
Kent -
TreeViews with GeListHead and a checkbox column can lock up C4D
Just came across a bug that took me about 2 hours to figure out.
- Create a AutoAlloc<GeListHead> and add some child nodes. Store this in a GeDialog.
- In your GeDialog create a TreeView. Set the TreeViewCustomGui->SetRoot( mygelisthead->GetFirst(), &treeviewfuncs, this));
- In your TreeViewFunctions::GetFirst() { return root;}
- When setting your treeview layouts, add a checkbox. layout.SetInt32(TREE_COLUMNS_CHECK, LV_CHECKBOX);
- Implement the functions for IsChecked and SetCheck
- Run your code and when you click on the checkbox it will enter an endless loop somewhere in the c4dplugins code.
The reason for this is (2). Instead of calling SetRoot(mygelisthead->GetFirst()...). I should have just passed in the GeListHead.
Then for (3) I should have returned the First element: GeListHead op = (GeListHead)root; return op->GetFirst();
With these changes it works, but that took a while to figure out.
-
RE: We are looking for plugin developers!
Just checked out your website, looks really great. Can't wait to see that in C4D. Best of luck with the project!
-
RE: Struggling with Python Documentation and pyc4d
The res folder is located in the same location as your pyp file. It is described in the link you mentioned in the Directory Structure section.
A res folder contains the UI code for the plugin. These are resource files (.res) for descriptions and dialogs as well as the strings used in these. I am not sure if these are described in the python docs but you can find the info in the C++ help files.
Resource Files:
https://developers.maxon.net/docs/cpp/2023_2/page_manual_resource_files.htmlDescription files:
https://developers.maxon.net/docs/cpp/2023_2/page_description_resource.htmlDialogs:
https://developers.maxon.net/docs/cpp/2023_2/page_dialog_resource.htmlHave you gotten the examples python scripts to work in C4D? I made a video for R17 a while back which may help.
For R20 you may need to put the SDK files in your own plugins folder, which you define from the Edit->Preferences->Plugins in C4D.
Once you get the examples going then you can start editing them live and then in C4D you can press the Plugins->Reload Python Plugins button.
The support team I am sure will jump into this thread and help you out.
My advice would be to start with a Command Plugin. But for the life of me I can't find you a good example of that either.
I will leave this up to the python guys here in the forum and the support team to help you out further.
Hope some of this info is of use to you. Good luck!
-
RE: Interfacing with Gumroad's API
@orestiskon I use the GumRoad API and their License Key System for all my plugins. Here is a quick overview of how you would implement it.
- Enable the license key generation for your product in your gumroad store. This sends the user a key when they purchase
- You then need to implement a way for your users to input that key into their plugins. I have a plugin manager that gives users one location to do this for all of my plugins I sell.
- In your plugin you then call the GumRoad API license endpoint and pass in the Key that the user received.
- The API then returns if the key is valid and how many times it has been used. Each time the endpoint is called you can choose to increase this "used" counter.
- If it has never been used then you then need to generate an offline key that you will store on the users machine somewhere, or in their preferences. This Key would be something like an MD5 Hash of their Cinema 4D User ID, Email Address or System ID combined with some secret key and an identifier for your plugin. UserID+SecretKey+PluginModuleID
- When the user restarts C4D your plugin then looks for this offline key and if found your plugin would run.
The biggest problem with this solution is when users changes machine or move to a new version of C4D. If they haven't backed up their offline key, or if it is not even accessible to them then your GumRoad API key is no longer userful to them.
To remedy this I also have an AWS API that gets called by GumRoad when the purchase. You can add a Callback in your GumRoad account for this. I then call my own AWS API to handle allowing users to re-install the plugins if the GumRoad key has already been used by checking my own API database. Having my own database allows me to reset they keys on my side (something GumRoad doesn't let you do, but I have requested this already from them, ie the ability to reset the Used counter back to zero would do the same thing). But having my own API future proofs me in the event that I wish to move away from GumRoad as well, since I have now essentially built my own licensing system on AWS and may in future remove my dependence on the GumRoad license key generation completely.
I have contemplated providing a monthly service to developers to give them a proper licensing solution for C4D development. But there is really no market for it. There are not enough developers and we are all just wanting to do our own thing for the fun of it mostly anyway.
MAXON really need to sort this out and have an internal system for us developers. It is absolutely insane that they removed the existing system without implementing a replacement. Forcing every developer to roll their own licensing system is a complete waste of time and does away with what the developer wants to do in the first place, which is make a C4D plugin, not spend months investigating and writing their online licensing system.
-
RE: AdditionalCompileOptions breaks any plugin
Looks like your setting preprocessing definitions. So try the following instead...
AdditionalPreprocessorDefinitions.Win=ANYSETTING;SETTING2;SETTING3;
or
AdditionalPreprocessorDefinitions.Win64.Debug=ANYSETTING;SETTING2;SETTING3;
-
RE: Interfacing with Gumroad's API
@orestiskon said in Interfacing with Gumroad's API:
@kbar Hey Kent, I have one more additional question:
You mentioned the issue with Gumroad keys is you cannot reset them, so you use the AWS database. But if you want to allow users to install it at another machine, couldn't you also allow generating the offline key beyond gumroad's first use? What is the difference?
That’s up to you to allow using it multiple times. But if you don’t limit it then they can post their key online and then everyone can use it, making your product free essentially.
Their license key system is perfect for subscriptions. But for single install software you have to create a system that works for you.
I just use my AWS system as a way to let me reset a license so a user can use the key again.
Or if you write out an offline key to disk then that user could copy it to their second computer manually. I did this for a while but it caused too many support tickets. So instead I limited it and if anyone wants a reset they just contact me.
-
RE: Multiple animation import
Looks great Loïc.
It would be great if you could also add in the Timeline Markers to indicate where each animation starts and finishes.
Here are a couple of posts that should help.
https://gist.github.com/gr4ph0s/0badf708657aaa117be0f84dd176e2b8
Cheers.
Kent -
RE: Interfacing with Gumroad's API
@orestiskon said in Interfacing with Gumroad's API:
The reason I'm going with Gumroad is because it provides a system that I can automate as an indie developer. I can make useful C4D tools and plugins, but I'm not a web developer nor a fully-fledged programmer.
This is the exact same reason I chose GumRoad. It at least allows for a way for a customer to license their plugin without having to extract a Json file from C4D and send that, or parts of that, to the developer. Which the developer then needs to process somehow or handle by hand. It leads to too much confusion and support tickets.
The GumRoad check allows for a hands off licensing approach. I have virtually zero support tickets now.
@r_gigante This not about MAXON making an online store, marketplace or anything like that. It is purely about licensing. Something that MAXON should provide a solution for.
It can be solved with an C4D SDK solution and a simple backend API.
The problem is that no one at MAXON is an external plugin developer trying to sell plugins. So you have never hit these pain point. I have extensive experience with many different online sales platforms now, all in the search for something “simple” that would work with C4D due to the removal of the previous system.
Knowing how online sales systems work and how they can be connected is the knowledge required to be able to understand how an external developer would license the plugins in an automated way. A way to produce a license key that can then be checked by the plugin. This can all be automated. A solution from MAXON can 100% be made that would work for all online stores. I previously talked about this with Rick and Paul when R21 left all developers in the lurch and out on their own. But it seems like there is no interest in this and no budget. I even offered to provide a solution. But I can’t sell that to developers, it should really be done by MAXON.
You could also use your new system and allow developers the ability to lock licenses that way, ie with separate licenses or entitlements and control over seats and orgs etc… But I also have very in-depth knowledge of that system as well and understand how messy that could get. So I think an alternative licensing system built just for the use by external plugin developers would be a good solution.