Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi @jenandesign, first of all, welcome in the plugincafe community.
No worry at all, since it's your first post, but I would like to point you about few rules in order to properly ask questions in this forum for future ones (I've set up this one).
With that's said. Regarding your question. I get it to work (a bit hacky) but it's working. When C4D render a scene, actually the whole scene is cloned in memory and then it renders this one. (It allow a user to still work on C4D while the other scene is rendering). So this render scene is read-only, you shouldn't modify at anytime anything in this scene, or you can screw up the render. Moreover in a shaderData, in order to optimize memory, only relevant information (aka polygon, UV) are copied. So you are losing your UserData. This means you have to find another way to find your effector. So the way I find to achieve what you want is to get the document from the object passed to the shader(the rendered document). Then in this document, I search for an effector called "Plain" (Not the most robust way but it's working).
Then here the final code I put on the python color channel of a sketch and toon
import c4d def main(): doc = op.GetDocument() effector = doc.SearchObject("Plain") if not effector: return c4d.Vector() eff = c4d.modules.mograph.C4D_Falloff() if not eff: return c4d.Vector() eff.InitFalloff(bc=effector.GetData()) eff.SetMg(effector.GetMg()) eff.SetMode(effector[c4d.FALLOFF_MODE]) # World position currently sampled value = eff.Sample(wPnt, False) return c4d.Vector(value)
And the attached scene where a plain effector drives a mograph effector and the sketch and toon shader. 0_1542626486830_SketchAndToon.c4d
If you have any questions, please let me know! Cheers, Maxime!
Hi @merkvilson first of all pip and Niklas localimport module is completely two different things.
Now how to install pip?
cmd
c4dpy get-pip.py
c4dpy -m pip install numpy
With that's said we do not provide support for 3rd party modules, so if it does not work with Cinema 4D Python environment, we can't help you.
Cheers, Maxime.
Hi @kisaf,
MCOMMAND_MIRROR is indeed a bit special because when you click on the Apply button from the GUI, it does send a message to some c4d elements, then these elements read MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE calculates values for MDATA_MIRROR_POINT and MDATA_MIRROR_VECTOR and then call the SendModelingCommand. Unfortunately, there is no way for you to send this message, and the best way to do it is to recalculate the stuff as bellow.
import c4d def main(): # Checks if selected object is valid if op is None: raise ValueError("op is none, please select one object.") # Defines some general settings, take care MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE settings = c4d.BaseContainer() settings[c4d.MDATA_MIRROR_DUPLICATE] = True settings[c4d.MDATA_MIRROR_SELECTIONS] = True settings[c4d.MDATA_MIRROR_ONPLANE] = True settings[c4d.MDATA_MIRROR_WELD] = True settings[c4d.MDATA_MIRROR_TOLERANCE] = 0.01 # Corresponds to MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE value = 1000.0 system = 0 # 0 = Object, 1 = World plane = 1 # 0 = XY, 1 = ZY, 2 = XZ if not 0 <= system < 2: raise ValueError("System can only be 0 or 1") # Buffer position vector pos = c4d.Vector() # Calculates Local (Object) coordinates if system == 0: globalMatrix = op.GetMg() if plane == 0: pos = globalMatrix.v3 elif plane == 1: pos = globalMatrix.v1 elif plane == 2: pos = globalMatrix.v2 settings[c4d.MDATA_MIRROR_POINT] = globalMatrix.off + pos * value settings[c4d.MDATA_MIRROR_VECTOR] = pos # Calculates World coordinates elif system == 1: if plane == 0: pos = c4d.Vector(0.0, 0.0, 1.0) elif plane == 1: pos = c4d.Vector(1.0, 0.0, 0.0) elif plane == 2: pos = c4d.Vector(0.0, 1.0, 0.0) settings[c4d.MDATA_MIRROR_POINT] = pos * value settings[c4d.MDATA_MIRROR_VECTOR] = pos # Send the Modeling Operation res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_MIRROR, [op], c4d.MODELINGCOMMANDMODE_ALL, settings, doc) c4d.EventAdd() if __name__ == "__main__": main()
Hope it solves your issue, if you have any question, please let me know. Cheers, Maxime.
So regarding your script why it crashes, it's simply because you make an infinite loop with this code since you add each time something more to iterate.
for idx in newPos: newPos.append(GlobalToLocal(oldObject, idx))
Just to make it cleaner I've called objA and objB. Then the needed steps are:
So as you may be already aware regarding our Matrix Fundamentals where is how to achieve both operations.
Finally, before providing with the solution I would like to remind you to please always execute your code in the main function. The main reason is that if you transform your script as a button in the Dialog, every code that is in the global scope of your script is executed for each redraw of the Cinema 4D GUI (which is pretty intensive!). Moreover please always check for objects, if they exist or not try to adopt a defensive programming style in order to avoid any issues.
import c4d def main(): # Declares object variables ObjA = doc.SearchObject("A") ObjB = doc.SearchObject("B") # Checks if objects are found if ObjA is None or ObjB is None: raise ValueError("Can't found a and b object") # Checks if they are polygon object if not isinstance(ObjA, c4d.PolygonObject) or not isinstance(ObjB, c4d.PolygonObject): raise TypeError("Objects are not PolygonObject") # Checks Point count is the same for both obj allPtsObjA = ObjA.GetAllPoints() allPtsObjB = ObjB.GetAllPoints() if len(allPtsObjA) != len(allPtsObjB): raise ValueError("Object does not get the same pount count") # Retrieves all points of B in World Position, by multipling each local position of ObjB.GetAllPoints() by ObjB.GetMg() allPtsObjBWorld = [pt * ObjB.GetMg() for pt in allPtsObjB] # Retrieves All points of B from World to Local Position of ObjA, by multipling each world position of ObjB by the inverse objA.GetMg() allPtsObjANewLocal = [pt * ~ObjA.GetMg() for pt in allPtsObjBWorld] # Sets New points position ObjA.SetAllPoints(allPtsObjANewLocal) ObjA.Message(c4d.MSG_UPDATE) # Updates Cinema 4D c4d.EventAdd() # Execute main() if __name__=='__main__': main()
If you have any questions, please let me know. Cheers, Maxime.
Hi @mikeudin, due to how our Classic Python API is built deepcopy does not work since our python objects only store pointer to our internal C++ object and not directly to other Python objects, so deepcopy fail in this regards since, the deepcopy operation, free and try to recreate these data, which is not possible since they are not PyObject but real C++ object but copy.copy does works, but since it's a shallow copy operation it only works for one level (e.g. a dict of dict of DescID will fail).
For more information about the difference please read Shallow vs Deep Copying of Python Objects.
However here a couple methods to copy a dict.
import copy dict1 = {'1':dId_one,'2':dId_two} dict2 = copy.copy(dict1)
dict1 = {'1':dId_one,'2':dId_two} dict2 = dict1.copy()
dict1 = {'1':dId_one,'2':dId_two} dict2 = dict(dict1)
Hi @mike, first of all I would like to remind you to read and use the Q&A functionnality.
Regarding your question, here is an example of a basic GeDialog, which make use to SetFloat to define a range.
import c4d class MonDlg( c4d.gui.GeDialog): idSlider = 1000 idButton = 1001 # Create the Layout def CreateLayout(self): self.AddEditSlider(self.idSlider, c4d.BFH_SCALE|c4d.BFV_SCALE, initw=100, inith=20) self.AddButton(self.idButton, c4d.BFH_SCALE|c4d.BFV_SCALE, initw=100, inith=20,name = 'Get Value') return True # Called after CreateLayout def InitValues(self): self.SetFloat(self.idSlider, 0.25, min=0.0, max=1.0, step=0.01, min2=0.0, max2=0.0) return True # Called for each interaction from a widget def Command(self, id, msg): if id == self.idButton: print self.GetFloat(self.idSlider) return True def main(): dlg = MonDlg() dlg.Open(c4d.DLG_TYPE_MODAL) if __name__=='__main__': main()
If you have any questions please let me know. Cheers, Maxime!
Hi @chuanzhen actually the problem interested me and I took some personal time on my weekend to do some tests.
I did 2 test scenes, which was a cube with 163970 points driven by 3 joints With your original source code 0.53 fps optimize python: 1.09 fps (x2.05) C++: 19.36 fps (x36.52)
And the other one was the same cube but driven by 11 joints. With your original source code 0.37 fps optimize python: 0.64 fps (x1.73) C++: 12.08 (x32.65)
So here is the optimized python code. As you can see I try to avoid as much as possible doing operation in the nested loop.
class newskin(plugins.ObjectData): lasttagdirty = None #for weight change update jointdir = None #for joint change update cachedir = None #for other bindmesh check def CheckDirty(self, op, doc): #check first run if op[c4d.NEWSKINTAG] is None: op.SetDirty(c4d.DIRTYFLAGS_DATA) return #check weight change if op[c4d.NEWSKINTAG].GetDirty(c4d.DIRTYFLAGS_DATA) != self.lasttagdirty: op.SetDirty(c4d.DIRTYFLAGS_DATA) return #check matrix change checktime = op[c4d.NEWSKINTAG].GetJointCount() cdirty = 0 for i in xrange(checktime): cdirty += op[c4d.NEWSKINTAG].GetJoint(i).GetDirty(c4d.DIRTYFLAGS_MATRIX) if cdirty != self.jointdir or self.cachedir != op[c4d.NEWSKINCHECK].GetDirty(c4d.DIRTYFLAGS_CACHE): op.SetDirty(c4d.DIRTYFLAGS_DATA) return return def ModifyObject(self, mod, doc, op, op_mg, mod_mg, lod, flags, thread): if mod[c4d.NEWSKINTAG] is None or mod[c4d.NEWSKINCHECK] is None: return True tag = mod[c4d.NEWSKINTAG] self.lasttagdirty = tag.GetDirty(c4d.DIRTYFLAGS_DATA) #get current weight tag dirty self.cachedir = mod[c4d.NEWSKINCHECK].GetDirty(c4d.DIRTYFLAGS_CACHE) #get bindmesh check plist = [pos * op_mg for pos in op.GetAllPoints()] pcount = op.GetPointCount() jcount = tag.GetJointCount() self.jointdir = 0 for m in xrange(jcount): joint = tag.GetJoint(m) self.jointdir += joint.GetDirty(c4d.DIRTYFLAGS_MATRIX) #all joint current matrix dirtycount temp = c4d.Vector() for n in xrange(pcount): #n:point index temp %= temp for m in xrange(jcount): joint = tag.GetJoint(m) weight = tag.GetWeight(m, n) if not weight : continue cjmg = joint.GetMg() jdict = tag.GetJointRestState(m) jmg = jdict["m_bMg"] jmi = jdict["m_bMi"] temp += weight * cjmg * jmi * plist[n] #defrmer global pos plist[n] = temp plist = [~op_mg * pos for pos in plist] op.SetAllPoints(plist) op.Message(c4d.MSG_UPDATE) return True
And here the C++ version (compatible R20 only). It uses paralellFor, not sure it's really worth didn't do proper profiling about it but I wanted to try them. Moreover please do not consider my C++ code has fully optimized since you could probably improve it depending on the situation.
#include "c4d_symbols.h" #include "main.h" #include "c4d_objectdata.h" #include "lib_ca.h" // Local resources #include "oskinmodifier.h" #include "maxon/parallelfor.h" #include "maxon/basearray.h" /**A unique plugin ID. You must obtain this from http://www.plugincafe.com. Use this ID to create new instances of this object.*/ static const Int32 ID_OBJECTDATA_SKINMODIFIER = 1000002; class SkinModifier : public ObjectData { INSTANCEOF(SkinModifier, ObjectData) public: static NodeData* Alloc() { return NewObj(SkinModifier) iferr_ignore("SkinModifier plugin not instanced"); } virtual void CheckDirty(BaseObject *op, BaseDocument *doc); virtual Bool ModifyObject(BaseObject* mod, BaseDocument* doc, BaseObject* op, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread); private: BaseList2D* GetBaseLink(BaseObject* op, DescID id, Int excepted); Int lasttagdirty; /// get current weight tag dirty Int jointdir; Int cachedir; }; void SkinModifier::CheckDirty(BaseObject *op, BaseDocument *doc) { BaseList2D* t = GetBaseLink(op, DescID(NEWSKINTAG), Tweights); BaseList2D* l = GetBaseLink(op, DescID(NEWSKINCHECK), Opolygon); if (!t || !l) return; PointObject* linkOp = static_cast<PointObject*>(l); CAWeightTag* tag = static_cast<CAWeightTag*>(t); // check first run if (!tag) { op->SetDirty(DIRTYFLAGS::DATA); return; } // check weight change if (tag->GetDirty(DIRTYFLAGS::DATA) != lasttagdirty) { op->SetDirty(DIRTYFLAGS::DATA); return; } // check matrix change Int cdirty = 0; for (Int i = 0; i < tag->GetJointCount(); i++) { cdirty += tag->GetJoint(i, tag->GetDocument())->GetDirty(DIRTYFLAGS::MATRIX); if (cdirty != jointdir || cachedir != linkOp->GetDirty(DIRTYFLAGS::CACHE)) { op->SetDirty(DIRTYFLAGS::DATA); return; } } return; } BaseList2D* SkinModifier::GetBaseLink(BaseObject* op, DescID id, Int excepted) { GeData data; if (!op->GetParameter(id, data, DESCFLAGS_GET::NONE)) return nullptr; return data.GetLink(op->GetDocument(), excepted); } Bool SkinModifier::ModifyObject(BaseObject* mod, BaseDocument* doc, BaseObject* op, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread) { if (!mod || !op || !doc || !thread) return false; BaseList2D* t = GetBaseLink(mod, DescID(NEWSKINTAG), Tweights); BaseList2D* l = GetBaseLink(mod, DescID(NEWSKINCHECK), Opolygon); if (!t || !l) return false; PointObject* linkOp = static_cast<PointObject*>(l); CAWeightTag* tag = static_cast<CAWeightTag*>(t); lasttagdirty = tag->GetDirty(DIRTYFLAGS::DATA); cachedir = linkOp->GetDirty(DIRTYFLAGS::CACHE); PointObject* pObj = ToPoint(op); const Vector * pListR = pObj->GetPointR(); Vector * pListW = pObj->GetPointW(); const Int pcount = pObj->GetPointCount(); const Int jcount = tag->GetJointCount(); jointdir = 0; for (Int i = 0; i < jcount; i++) { BaseObject* joint = tag->GetJoint(i, doc); jointdir += joint->GetDirty(DIRTYFLAGS::MATRIX); } auto worker = [jcount, op_mg, &pListR, &pListW, &doc, &tag](maxon::Int i) { Vector temp; Vector pos = op_mg * pListR[i]; for (Int m = 0; m < jcount; m++) { Vector pos = op_mg * pListR[i]; BaseObject* joint = tag->GetJoint(m, doc); Float weight = tag->GetWeight(m, i); if (weight == 0.0) continue; Matrix cjmg = joint->GetMg(); JointRestState jrest = tag->GetJointRestState(m); Matrix jmg = jrest.m_bMg; Matrix jmi = jrest.m_bMi; temp += weight * cjmg * jmi * pos; } pListW[i] = ~op_mg * temp; }; maxon::ParallelFor::Dynamic(0, pcount, worker); // Notify Cinema about the internal data update. op->Message(MSG_UPDATE); return true; } Bool RegisterSkinModifier() { return RegisterObjectPlugin(ID_OBJECTDATA_SKINMODIFIER, "C++ oskinmodifier"_s, OBJECT_MODIFIER, SkinModifier::Alloc, "oskinmodifier"_s, nullptr, 0); }
Hi @FlavioDiniz, first of all, welcome in the plugincafe community!
Don't worry, since it's your first topic, I've set up your topic correctly. But please for your next topics, use the Q&A functionnaly, make sure to also read How to Post Questions.
With that's said you can find the manual about SetDParameter in the C++ docs which will be trigger each time a user changes a value in the description of your tag. And also the C++ manual about GetDDescription. Here a quick example of the implementation in python
extensions = ["exr","hdr","jpg","png"] # Called by C4D when loading description def GetDDescription(self, node, description, flags): data = node.GetDataInstance() if data is None: return False # Load the description if not description.LoadDescription(node.GetType()): return False # If there is no description for c4d.TESTSCALE, we create it. Otherwise we override it and set DESC_CYCLE with our extensions list. singleID = description.GetSingleDescID() paramID = c4d.DescID(c4d.TESTSCALE) if singleID is None or paramID.IsPartOf(singleID)[0]: bcParam = description.GetParameterI(c4d.TESTSCALE) items = c4d.BaseContainer() for i, extension in enumerate(self.extensions): items.SetString(i, extension) bcParam[c4d.DESC_CYCLE] = items return (True, flags | c4d.DESCFLAGS_DESC_LOADED) # Called when a parameter is Set def SetDParameter(self, node, id, t_data, flags): if not node: return # called when the filename is changed. We add the path to our list and we return c4d.DESCFLAGS_PARAM_SET to inform c4d the paramaters is just sets if id[0].id == c4d.STRINGTEST: self.extensions.append(t_data) return (True, flags | c4d.DESCFLAGS_PARAM_SET) return False
If you have any questions, please let me know! Cheers, Maxime.
Hi @Ashton_FCS_PluginDev, we are glad to see you back in the new plugincafe community! No worries at all since it's your first post here, but please make sure to read and apply the rules defined on the following topics:
Regarding your issue, you read m_spec, but you never check if there is a bitmashader in it or not. And in your case, there is no, so m_spec is set to None, and you are then trying to access value. So please always check for None. Then since you directly read the BITMAPSHADER_FILENAME parameter from this shader, please also consider to check the shader type you retrieve, maybe a user used a noise and not a bitmap.
m_spec = userMat[c4d.MATERIAL_REFLECTION_SHADER] if not m_spec or m_spec.CheckType(c4d.Xbitmap): continue
Finally, as you may already be aware, reflection gets multiple layers. You get some information in this thread, how to deal with it.
If you have any others question, please let me know! Cheers, Maxime.
Hi @mike, No worries at all since, but please make sure to read and apply the rules defined on the following topics:
Regarding your question, you can make use of the Shift Priority Tags. You can find more information on the priority in the c4d help.
But C4D also offer the Shift Priority Tag. Finally, note in some case it can be a limitation of the viewport which not refresh properly while data are correctly set. And you need to manually refresh the viewport.
Hope it solves your issue, if you have any question please let me know! Cheers, Maxime!
Hi @aturtur unfortunately the next methods GetChannelColorSettings are not exposed in Python, therefor it is not possible to access/change them.
Moreover it's most likely that they will never get ported to python due to the limited number of requests we have for these functions.
Hi @mocoloco for such a parameter, using the bracket operator will be more easy. Find bellow the code within a Python Scripting tag, this work as expected.
from typing import Optional import c4d doc: c4d.documents.BaseDocument # The document evaluating this tag op: c4d.BaseTag # The Python scripting tag flags: int # c4d.EXECUTIONFLAGS priority: int # c4d.EXECUTIONPRIORITY tp: Optional[c4d.modules.thinkingparticles.TP_MasterSystem] # Particle system thread: Optional[c4d.threading.BaseThread] # The thread executing this tag def main() -> None: obj = op.GetObject() previousLightColor = obj[c4d.LIGHT_COLOR] print(previousLightColor) newLightColor = c4d.Vector(0.0, 1.0, 1.9) obj[c4d.LIGHT_COLOR] = newLightColor
But if you really want to use G/SetParameter you can do it with the code bellow. The issue with your code is that DESCFLAGS_GET_PARAM_GET mean to be used within the implementation to notify the system that this parameter have been already retrieved so no need to retrieve it again. So if you pass this flag as an input therefor you will have nothing in return.
DESCFLAGS_GET_PARAM_GET
obj = op.GetObject() previousLightColor = obj.GetParameter(c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), c4d.DESCFLAGS_GET_NONE) print(previousLightColor) newLightColor = c4d.Vector(0.0, 0.0, 1.9) obj.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), newLightColor, c4d.DESCFLAGS_SET_NONE )
Btw if you install the Cinema 4D Vs Code extension, pyp extension should be added as Python.
How to make VS Code treat a file extensions as a certain language?
Hi @FSS first of all happy new year !
And I'm glad that you found a solution however even if this is in the documentation we don't explicitly support PyCharm and only provide a dummy package to have autocompletion working with any Python instance. But C4dpy is not supported by all IDE and we can't provide any support there.
If you want to have a better IDE workflow we released a plugin for Visual Studio Code, requiring a Cinema 4D plugin and a VS Code plugin.
Finally I moved this topic to general talk as it this is nothing related to Cinema 4D API.
Hi you need to insert the video post as shown in the C++ manual - Redshift Renderer - Set Render Engine to Redshift, adapting it to Python should be pretty straightforward.
Have a nice weekend. Cheers, Maxime.
Ok nervermind it is possible to overwrite the ASSET_PREVIEWIMAGEURL in Python it's just that AssetDescription.StoreUrlMetaData, AssetDescription.StoreMetaData, AssetDescription.EraseMetaData are bugged in Python. So find bellow a workaround for that (it will be fixed in the next version and StoreUrlMetaData will work out of the box).
ASSET_PREVIEWIMAGEURL
AssetDescription.StoreUrlMetaData
AssetDescription.StoreMetaData
AssetDescription.EraseMetaData
StoreUrlMetaData
import c4d import maxon # --- AssetDescriptionInterface monkey patching fix for AssetDescriptionInterface.StoreUrlMetaData() -------------------------- @maxon.interface.MAXON_INTERFACE(maxon.consts.MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.assetdescription") class AssetDescriptionInterface(maxon.AssetBaseInterface): @maxon.interface.MAXON_FUNCTION_EXTEND("net.maxon.interface.assetdescription.StoreUrlMetaData") def StoreUrlMetaData(self, metaId, source, kind): return self.GetRepository().StoreUrlMetaData(self, metaId, source, kind) maxon.AssetDescriptionInterface.StoreUrlMetaData = AssetDescriptionInterface.StoreUrlMetaData # --- AssetDescriptionInterface monkey patching fix for AssetDescriptionInterface.StoreUrlMetaData() -------------------------- def main(): repository = maxon.AssetInterface.GetUserPrefsRepository() assetId = maxon.Id("Id of the asset") lst = repository.FindAssets("net.maxon.node.assettype.nodetemplate", assetId, maxon.Id(), maxon.ASSET_FIND_MODE.LATEST) assetDescription = lst[0] currentLanguage = maxon.Resource.GetCurrentLanguage() name = assetDescription.GetMetaString(maxon.OBJECT.BASE.NAME, currentLanguage) print(name) metadata = assetDescription.GetMetaData() imagepUrl = maxon.Url("C:/Users/m_adam/picture.png") # Stores the Url Meta Data, if there was no preview stored previously (aka the default png file for the given category) then it will be refreshed right away # Otherwise Cinema 4D need to be restarted maxon.AssetDescriptionInterface.StoreUrlMetaData = AssetDescriptionInterface.StoreUrlMetaData assetDescription.StoreUrlMetaData(maxon.ASSETMETADATA.ASSET_PREVIEWIMAGEURL, imagepUrl, maxon.AssetMetaData.KIND.PERSISTENT) # Turn off automatic preview metaProperties.Set(maxon.ASSET.METAPROPERTIES.BASE.AUTOMATICPREVIEW, False) assetDescription.StoreMetaData(maxon.ASSETMETADATA.MetaProperties, metaProperties, maxon.AssetMetaData.KIND.PERSISTENT) if __name__ == '__main__': main()
However the limitation for InvalidateCache not being exposed is still there and as said will need a Cinema 4D update to make it work, so for the moment the only way to see new icons is to restart Cinema 4D.
I confirm that overwriting ASSET_PREVIEWIMAGEURL does not work in Python, and InvalidateCache is not exposed to the Python API and would need some internal change to the Cinema 4D code source to make it public so there is no possible workaround for you for the moment.
@baca said in Cinema 4D R2023 - c4d.plugins.RegisterObjectPlugin issue:
Any suggestion how to properly handle that kind of issues -- just catch exception and warn user using message box somehow?
Correct you can catch the OsError and check if there is the word 50 in the exception message.
Would it be reasonable to switch to NodeData from ObjectData -- It depends of your plugin if this is at the end an ObjectData then it's irrelevant, if this is just an object that you store in a list in memory or in a custom GeListHead then NodeData is perfectly relevant.
NodeData
ObjectData
does RegisterNodePlugin has separate 50 plugins registrations?
RegisterNodePlugin
Yes each type have 50 plugins.
What's the logic behind plugin initialization order -- alphabetical, date-based, random?
Folders from g_additionalModulePath are iterated by alphabetical order and each files are then iterated by alphabetical order too.
As explained in the post I linked the limitation is about Python and for each plugin type you have a limitation of 50 (call to RegisterXXXPlugin), wherever they are installed. So you can have 50 ObjectData and 50 TagData. But you can't have 51 ObjectData (the number of C++ plugins does not count). And there is no workaround.
The limitation is there since R11. Cheers, Maxime.