Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. fuchsundvogel
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    fuchsundvogel

    @fuchsundvogel

    0
    Reputation
    4
    Posts
    7
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    fuchsundvogel Follow

    Posts made by fuchsundvogel

    • RE: Generator plugin and loading preset objects from file (cache issue?)

      Hey Manuel,

      thanks for your code and for investing time into that!

      I tried it and found some problems:

      • Probably what you meant by 'cache will not be cloned': object is still invisible in the beginning until you refresh. But converting the generator works fine (that is because you omitted the .GetClone() in GVO I think).
      • Because you don't return a clone in GVO you get ReferenceError: the object 'c4d.BaseObject' is not alive when switching documents. But if you do so you can't use 'Make editable'.

      I think your code behaves the same as mine from the first post if you omit the .GetClone() in GVO there. I am not sure if the c4d.SCENEFILTER_SAVECACHES loading flag and ExecutePasses change anything. I have to add I only tested with a cube as preset. I could be the case that some of that is needed for Sweeps or the like.

      Jens

      posted in Cinema 4D Development
      fuchsundvogel
    • RE: Generator plugin and loading preset objects from file (cache issue?)

      Hey Manuel,

      no, the scene I load is just a simple cube object.
      Initially I started with SweepNurbs and also suspected them to be the problem but then noticed it already happens with simple objects.

      This old post I found seems to be a similar problem or even the same.
      https://plugincafe.maxon.net/topic/11787/make-editable-an-object-generated-by-getvirtualobjects
      Unfortunately the issue was not solved. The original poster gave up on loading presets and created them in code which is not sensible for me because the presets will be quite complex.

      posted in Cinema 4D Development
      fuchsundvogel
    • RE: Generator plugin and loading preset objects from file (cache issue?)

      Hey zipit,

      thank you very much for your answer!

      No errors in the console at all (unfortunately? 😁). Also no change if i add a check for self.loadedObject. Or even load the object in the GVO itself. So it looks like the order is not the problem here. The loaded object seems to be present.

      Jens

      posted in Cinema 4D Development
      fuchsundvogel
    • Generator plugin and loading preset objects from file (cache issue?)

      Hello everyone,

      I'm writing a python generator plugin that should load an preset object from a file and return a modified version of that in GetVirtualObjects().
      Right now the preset scene is just a simple cube without anything else.

      The code I'm using:

      def __init__(self):
      	self.loadedObject = None
      	self.SetOptimizeCache(True)
      
      def Init(self, op):
      	#loading preset file and save first object internally
      	if not self.loadedObject:
      		dir, file = os.path.split(__file__)
      		path = os.path.join(dir, "presets", "test.c4d")
      
      		presetDoc = c4d.documents.LoadDocument(path, c4d.SCENEFILTER_OBJECTS, None)
      		self.loadedObject = presetDoc.GetFirstObject()
      
      	return True
      
      def GetVirtualObjects(self, op, hh):
      	#return clone of loaded object
      	return self.loadedObject.GetClone()
      

      Basically loading and extracting the object from the file is fine. The problem is that the object is not loaded/executed before it is added to the current doc and a refresh was forced.
      When I add or reload the generator the object looks like this until i move the mouse and trigger a refresh:

      Anmerkung 2020-08-10 150850_02.png

      I can of course force a refresh via code, but I still can't convert the generator with "Make editable" or "Current State to object". Then only an empty object is returned.
      It looks like the conversion uses the state before the refresh and returns nothing.

      I tried a lot of things like ExecutePasses() on the loaded document or setting the cube to dirty and sending update messages but nothing helped so far.
      Adding the cube into the current document under the generator and hiding it is some kind of workaround but that leads to other problems - like being added multiple times because op.GetDown() not always returns the child on undo or scene changes or not being able to use "Make editable" and stuff like that.

      Maybe there is something I missed?

      posted in Cinema 4D Development
      fuchsundvogel