plugin tag works just for 1 object
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/11/2012 at 08:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
(you're missing prefixes for TIMELINEONOFF and CAMONOFF).
so they are suppoed to be named TTIMELINEONOFF and TCAMONOFF
as they are used in a tag?best wishes
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/11/2012 at 11:58, xxxxxxxx wrote:
Hi Jops,
_
> >> I know, that my code looks awfull._
Well, you're learning, as everyone here is. You'll write more clear code by time for sure.> >> I still have problems of understanding classes, initialistaion and the rest of this objectbased
>>> stuff.
I can really really recommend the official Python tutorial. It allows you to dive in very quickly. It
is easy to understand and starts from bottom up. Once I was starting out with Python, I read it
although I have been trying to write Python for about a month already (and had over a year
experience with COFFEE). It helped me a lot understanding the mechanisms of Python and of
OOP programming in general._> >> I now use the method, as you said (was it wrong the way I did it (it wasnt object oriented
>>> right?)) _
Not necessarily because of that reason (it actually was kind of OOP, however), but it is- easier to read
- I don't know about the internals of Py4D, but it could be possible that there is a reason
the method was implemented (either just for convenience, or maybe it does some
additional actions).
> >> for the naming conventions... I will have a look at them, thats a good thing. _
It's not just for making it easier to read (because you immediately know what the symbol
belongs to), but also prevents naming collisions (as I stated in the thread linked above).
_
> >> my execute is just a shortend version (as mentioned)
I must have missed that, sorry.> >> and unfortunately havent seen a answer to it in your post
That is due to the fact that there was no direct answer in my post. I think the problem lies
in the Execute() method, therefore it's a good thing that you have posted the complete code
now. As I didn't read it was the "shortened" version, I was wondering if this is really the complete code.> >> so they are suppoed to be named TTIMELINEONOFF and TCAMONOFF
No. Symbols in Cinema 4D are prefixed with what they belong to (also mentioned in the thread
linked above). Like MSG_~, PRIM_~, COLOR_~, SPLINECONTROL_~. Therefore, it is recommended
to prefix your symbols with PLUGINNAME_~. This avoids name-collisions and is easier (especially
for others) when reading your code.
Description-symbols are embedded into the c4d module (that's why names can collide). When your
plugin is installed, you can do "print c4d.TIMELINEONOFF" for example, and it will yield 1001 in
the console.Unfortunately I currently cannot see the issue directly from the code. Is it possible that
you upload the complete plugin-folder (including resource files) somewhere? If you want, I can
try to find the issue and correct your code.Just FYI, the way you store the information (frame, offset, zoom) is not OOP style.
Best,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/11/2012 at 01:56, xxxxxxxx wrote:
Hi Niklas,
thanks a lot for this response. kind words and good information
thanks to your information I now understand the need of prefix naming for Symbols and corrected them in the code.
I uploaded everything adn sent you the link via PM
also best
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/11/2012 at 01:43, xxxxxxxx wrote:
Hi Jops,
I've recieved the message, thank you.
It's rather simple, but it didn't occurr to me earlier. As I already said, the
way you store the frame, offset and zoom data is not OOP style. And that is
actually why your plugin doesn't behave the way you want it.When tags are executed in Cinema 4D, they are invoked one after another. (Ok,
sometimes even parallel, but not every tag at once!) When the tag on the first
object is being executed, it does its stuff and checking, etc. AND (now comes
the fatal thing) : It sets the global information of the last frame, offset and zoom.The problem here is the word global. When the first tag was executed,
the frame, offset and zoom values are already updated, and therefore, all other
tags will work on different data than the first tag.However, it's rather easy to solve. In general, it's considered
bad style using globals in Python (and many other languages as well). They
cannot be ommited sometimes, but their use can be reduced.You can imagine the current situation like the following : Every tag is a pupil
in school, and they all have to do the same task.
- What you are doing, is let them solve it on the chalkboard. And after the
first pupil has solved it, all other pupils don't have to do it anymore.
- What a teacher should do, if all pupils must do the work on their own, is
to give each pupil their own sheet.Transferred to the world of OOP programming: Store the information in the
Tag-instance instead of in the global scope.class TagPlugin(c4d.plugins.TagData) : def __init__(self) : super(TagPlugin, self).__init__() self.last_frame = -1 # etc.. def Execute(self, tag, doc, op, bt, priority, flags) : frame = doc.GetTime().GetFrame(doc.GetFps()) if frame != self.last_frame: # ... self.last_frame = frame # etc..
Some other notable things:
- visible = 1, Rather use a boolean, like visible = True
- Rather use implicit boolean checking, like if not visible:
- I personally prefer spaces rather than tabs. This way, you have more control
over the look of your code.
- Class names are usually CamelCase. It's not a must, but widely accepted in
the community.
- It's very unusual to write variable-names CamelCase with the first letter
being uppercase. CamelCase with starting with a lowercase letter (mostly found
in Java) or even underscore separated variable names (and all lowercase, the
more Pythonic way) are more conform.
- As I already stated, you don't have to define your description symbols in the
plugin-file. They are embedded in the c4d module. You can
write data.GetBool(c4d.FSPA_TIMELINEONOFF).See the PEP8 for information about the Python style-guideline
(which, again, is not a must, just a guideline).Best,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/11/2012 at 02:04, xxxxxxxx wrote:
Hi Niklas,
wow fantastic response! thanks you.
it will take a while till I got my head around this all (and corrected it in the codebest regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/11/2012 at 04:59, xxxxxxxx wrote:
Hi Niklas,
again thanks a lot. I managed to make all the corrections but
data.GetBool(c4d.FSPA_TIMELINEONOFF) doesnt work... I dont think that ists a big problem. i will just stick to the way I got it workingnow I will integrate some more features and userdata.
I am quite hopefull that I can handle it from here. my plan is to make the plug public in the near future on my website.never the less, if you want to have a look at the final code...I will send it to you.
I hope to get done todaybest regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/11/2012 at 05:27, xxxxxxxx wrote:
Hi Jops,
> >> data.GetBool(c4d.FSPA_TIMELINEONOFF) doesnt work... I dont think that ists a big problem
Sorry, forgot to tell you about it. That may be due to the symbolcache Cinema 4D generates. If
you change your plugin resource, Cinema might not be able to detect this and the symbolcache
won't change. The symbols in this file are loaded and then embedded into the c4d module, instead
of parsing all resources once again (which would delay startup time). You can manually delete the
file from your plugin while developing, but make sure your plugin does not delete it when you have
released it.The file is located at %appdata%/MAXON/Cinema 4D RXX/prefs. It is called coffeesymbolcache in
R12 and symbolcache in R13+.Best,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/11/2012 at 03:16, xxxxxxxx wrote:
Hi Niklas,
but then it seems to me that handling the way I do is more stable?
if I release a new version of the plugin I have to take care about the cache on every computer the former version was installed?best regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/11/2012 at 03:58, xxxxxxxx wrote:
Hi Niklas,
my plugin is not running on the renderfarm
is there something I have to care about?I uploaded the current version.
best regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/11/2012 at 04:01, xxxxxxxx wrote:
ok maybe I have to explain something... that might be the root of the problem.
I have to find out If the scene is rendered in the picturefiewer or in the editorview. therefor I check:
if doc == documents.GetActiveDocument() :
this works fine for the picturemanager and the editor view but maybe not for the renderfarm.
the plugin is installes on every client.
best regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/11/2012 at 07:42, xxxxxxxx wrote:
You should get the correct doc with:
doc = mytag.GetObject().GetDocument()Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 05:44, xxxxxxxx wrote:
Thanks lennart,
that was by the way something I was looking for, as GetOrigin doesnt work for a plugin
but:
I actually was looking for a possibility to find out if the szene is rendered in the pictureviewer, the renderfarm or the editorview.
this little function works good for the editor and pictureviewer, but not for the netrender (unfortunatelydef is_render() : # find out if rendered in Pictureviewer if doc == documents.GetActiveDocument() : return True else: return False
best regards
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 06:18, xxxxxxxx wrote:
ok one step further:
this code works for pictureviewer and batchrender but not for netrender
def is_render() : # find out if rendered in Pictureviewer, batchrender and net if c4d.documents.GetBatchRender().IsRendering() : # finds out if batchrender return False if doc == documents.GetActiveDocument() : # finds out if pictureviewer return True else: return False
so maybe someone knows how I can find out If the scene is rendering with netrender?
thanks a lot
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 08:12, xxxxxxxx wrote:
Have you tried to call c4d.CheckIsRunning(c4d.CHECKISRUNNING_EDITORRENDERING) and c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 01:29, xxxxxxxx wrote:
Hi Yannick,
thanks again. unfortunately I didnt find it in the SDK searching for render and rendering
but now you told be thanks
c4d.CheckIsRunning(c4d.CHECKISRUNNING_EDITORRENDERING)
not working ... but I dont need it anywayc4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)
working for pictureviewer and netrender but not for batchrenderso to include batchrender the function looks loke this:
def is_rendering() : if c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING) or c4d.documents.GetBatchRender().IsRendering() : return True else: return False
it seems to work. great!
thank you all for the help
Jops -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2012 at 03:22, xxxxxxxx wrote:
again... thanks a lot to all that helped me.
I published the Plugin Fs_preview_accelerator on my website.
http://www.webarts.net (english button is in the upper right corner.best regards
Jops