thanks a lot! Both are valid solutions for me. Very helpful.
I'm aware, I'm doing something out of the box here. If it's too absurd, simply ignore my question.
For organizational reasons in a larger project, I'm trying to register a ToolData plugin from a "sub module".
This is roughly the intended project structure:
./plugins/ |-- myplugin/ |-- myplugin.pyp |-- subdir/ |-- submodule.py |-- res/ |-- usual suspects here
A link to a small example project follows at the end.
I'd like to call
RegisterToolPlugin() from within submodule.py as follows.
import submodule # actually a tad bit more complicated, as the subdirs need to be manually added to the search path first submodule.RegisterSubmodule()
class HolyCowToolData(c4d.plugins.ToolData): pass def RegisterSubmodule(): c4d.plugins.RegisterToolPlugin(..., dat=HolyCowToolData())
This already worked for
CommandData plugins or maybe also any plugin type, as long as no resource files are involved. But I doubt one can have a ToolData without at least a dummy resource...
In case of the above example with a dummy ToolData I end with the following error thrown by the call of
ReferenceError:Could not find required '__res__'.
If I do instead in myplugin.pyp:
it works again. But for several reasons it is not what I'd like to have...
My guess is, C4D is somehow looking in the wrong place for the expected resource files. Yet, having another res folder in submodule doesn't make a difference. So I have no idea, where it's looking for resources. Then again, I may be misinterpreting the error message completely...
As said in the beginning, I'm aware I'm doing something esoteric here and I understand, if no time can be invested to support such stupid ideas. On the other hand I hope, above error message may ring a bell and I could get a hint, what to do differently.
Here's an example project (really just the few lines needed) demonstrating the issue (change
REGISTER_HERE in myplugin.pyp from True to False to switch between both cases):
test_tooldata_registration.zip (temporary link to my Dropbox, if a future reader still needs this, please PM me)
It also shows, with a CommandData the approach works in principal.
Thanks in advance.
There's also the "Send to Picture Viewer" command (by default in viewport View menu), command ID is 300001097, which would fit your purpose quite well...
Unfortunately it has some downsides, when trying to use it from code instead of from the UI.
Edit: Forget it, playing around with it, I think it is broken for every other than the first viewport (regardless of code or UI). Sorry.
Dear fellow developers,
my seasonal greetings to the entire community.
But I'd also like to take the chance to say thanks to "our" SDK Team, who served us so well during the entire year. Patiently answering even my most stupid questions, as if they had nothing else to do (which of course they most likely have)...
So, please, everybody in this community join me in saying:
Thanks for supporting us so well, Riccardo, Sebastian, Maxime and Manuel!
Everybody hopefully gets some well deserved days of rest.
Unfortunately it seems to have issues. No other code than te snippet found in docs is needed:
dId = c4d.DescID(c4d.DescLevel(30), c4d.DescLevel(40), c4d.DescLevel(50)) dId<<2
Here in my R21 on Win10 this results in:
TypeError: unsupported operand type(s) for <<: 'c4d.DescID' and 'int'
Trying to call
__lshift__() directly results in
NotImplemented, which could be a hint ;)
the API of the SplineObject seems to suggest, one could have a spline with the open and closed segments (as one can set the closed flag on a per segment basis in SplineObject.SetSegment()). But I simply can't get it to work.
Basically I'm doing something like the following, always ending up with all open segments:
import c4d def main(): spline = c4d.SplineObject(6, c4d.SPLINETYPE_LINEAR) spline.ResizeObject(7, 2) spline.SetPoint(0, c4d.Vector(0.0, 0.0, 100.0)) spline.SetPoint(1, c4d.Vector(100.0, 0.0, 100.0)) spline.SetPoint(2, c4d.Vector(100.0, 100.0, 100.0)) spline.SetSegment(0, 3, True) spline.SetPoint(3, c4d.Vector(0.0, 0.0, 200.0)) spline.SetPoint(4, c4d.Vector(100.0, 0.0, 200.0)) spline.SetPoint(5, c4d.Vector(100.0, 100.0, 200.0)) spline.SetSegment(1, 3, False) spline.Message(c4d.MSG_UPDATE) doc.InsertObject(spline) c4d.EventAdd() if __name__=='__main__': main()
Playing around with the Spline Pen, I'm somewhat afraid, this feature of the API is not working at all, as the Pen starts working with two spline objects as soon as a segment of the other "openess" gets involved.
Not urgent at all, I can work with the obvious workaround of multiple splines.
While writing this, I took a look at the C++ API and now, I'm pretty sure, I can answer the question myself already. In C++ such option does not seem to exist. Strangely so, this additional "closed" parameter in Python is not even optional.
So, it's maybe more a request for a documentation fix than a real question.
Ah, that novel!
Yeah, sorry. Not one of my personal highlights. Sometimes answering simple questions can be more difficult than one might expect. Such changes can involve quite a few people and seemingly easy processes can become quite lengthy (up to the point, where you (or rather I) forget about the beginning). And certain topics might be regarded so sensitive, that communication on even remotely related topics can get difficult (e.g. due to legal issues). But then again, in the end it was in my responsibility to gather the info you needed or wanted, and I failed to provide it to you. Or at least provide you with a semi-satisfactory answer without touching things I was not allowed to. Sorry!
And see? I'm pretty sure, my follow up will not make the same mistakes (as he or she is most likely human maybe others...). So, if it's not the same anymore without me, then probably better!