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 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 code :)

best 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 working :)

now 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 today :)

best 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 (unfortunately :(

  
          def 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 anyway

c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)
working for pictureviewer and netrender but not for batchrender

so 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