Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login
    1. Home
    2. pim
    P
    • Profile
    • Following 0
    • Followers 0
    • Topics 92
    • Posts 279
    • Best 8
    • Controversial 0
    • Groups 0

    pim

    @pim

    10
    Reputation
    365
    Profile views
    279
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    pim Unfollow Follow

    Best posts made by pim

    • RE: Fit image to a plane maintaining the ratio of the image?

      Together with the help from the c4dlounge.eu forum the issues is solved.
      The main issue was I did not read the manual good enough.

      "Note that Size symbolizes the axis size and not the expansion of the object itself. For planar projections, the true dimension is the two/fold of the axis length."

      posted in Cinema 4D SDK
      P
      pim
    • RE: DrawLine2D on top of everything else

      I did some more testing and I think I got it now.
      In MouseInput() get and set your coordinates.
      Then call c4d.DrawViews(). This will call Draw(), where you can (and should) do the drawing like bd.DrawLine2D().

      class PlaceTool(c4d.plugins.ToolData):       	
      
          v1 = c4d.Vector(0,0,0)
          v2 = c4d.Vector(0,0,0)
          
          def Draw(self, doc, data, bd, bh, bt, flags):	
              bd.SetPen(c4d.Vector(256,256,256))
              bd.DrawLine2D(self.v1, self.v2)
              return True
              
          def MouseInput(self, doc, data, bd, win, msg):
              self.v1 = c4d.Vector(0,0,0)
              self.v2 = c4d.Vector(msg[c4d.BFM_INPUT_X], msg[c4d.BFM_INPUT_Y], 0)
              c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK)  #Added 
              return True
              
              
      
      posted in Cinema 4D SDK
      P
      pim
    • RE: Insert object in Treeview

      Thanks, great explanation!
      One small issue. Delete doesn't work because objParent' is not defined.

      Traceback (most recent call last):
      File "scriptmanager", line 251, in DeletePressed
      NameError: global name 'objParent' is not defined
      

      Here the code that, I think, solves the issue:

          def DeletePressed(self, root, userdata):
              "Called when a delete event is received."
              for tex in reversed(list(TextureObjectIterator(self.listOfTexture))):
                  if tex.IsSelected:
                      objParent = tex.GetParent()               # Added
                      listToRemove = objParent.GetChildren() if objParent is not None else self.listOfTexture
                      listToRemove.remove(tex)
      
      posted in Cinema 4D SDK
      P
      pim
    • RE: Best plugin type for background (thread) processing?

      @heilei said in Best plugin type for background (thread) processing?:

      Py-TextureBaker

      That is a very good working example.
      I rebuild my plugin using py-texturebaker and now it is working!

      After some studying, I think @PluginStudent is fully correct when referring to the global scope.

      @PluginStudent said in Best plugin type for background (thread) processing?:

      Please read my post above and the C4DThread Manual carefully.

      You can start the thread in a CommandData plugin. But this plugin must not own the thread instance. The thread instance should be stored in the global scope.

      In the MessageData plugin, you should react to a core message sent from the thread. Nothing else; no creation or waiting.

      I guess it is working because in the dialog the thread class is initiated.
      textureBakerThread = None
      and further in the code it is referenced with self.textureBakerThread.

      I was using

              thread = UserThread()
              thread.Start()
      

      Everybody thanks for all the help.

      posted in Cinema 4D SDK
      P
      pim
    • RE: Reading script file into memory

      @PluginStudent said in Reading script file into memory:

      You have to define the APIS in the projectdefinition.txt of your plugin.

      Not in the projectdefinition.txt of the solution.

      Great, tht solved it. Thanks!

      posted in Cinema 4D SDK
      P
      pim
    • RE: Reading script file into memory

      To summarise, there are 2 projectdefinition.txt files.

      1. on main / sdk level, Define which project (plugins, etc.)
        Example:
      Platform=Win64;OSX
      Type=Solution
       
      // defines the level of rigour of the source processor's style check
      stylecheck.level=0
      
      Solution=\
      	plugins/cinema4dsdk;\
      	plugins/maxonsdk.module;\
      	plugins/commandline;\
          plugins/CommandLineRendering
      
      1. on plugin level, // Configuration of a custom solution in the projectdefinition.txt file
        Example:
      // Supported platforms
      Platform=Win64;OSX
      
      // Type of project
      Type=DLL
      
      // this plugin depends on these frameworks:
      APIS=\
        cinema.framework; \
        misc.framework; \
        image.framework; \
        core.framework; \
        python.framework
      
      // Enable some advanced classic API support; not needed for hybrid plugins
      C4D=true
      
      // Plug-in code-style check level
      stylecheck.level=0
      
      // Custom ID
      ModuleId=net.maxonexample.commandlinerender
      
      posted in Cinema 4D SDK
      P
      pim
    • RE: Passing a variable to the python script

      Yes, I am referring to that page.
      I saw that statement, but I assumed it was the main definition for the python plugin.

        // set __name__ = __main__
        scope.Add("__name__"_s, maxon::Data("__main__"_s)) iferr_return;
      

      If I understand you correctly, I can add different parameters with different values.
      For example:

        // set __param1__ = "c:/temp"
        scope.Add("param1"_s, maxon::Data("c:/temp"_s)) iferr_return;
        scope.Add("param2"_s, maxon::Data(220)) iferr_return;
      posted in Cinema 4D SDK
      P
      pim
    • RE: First time compiling of plugin with R21

      Yes, I must read the manuals more throroughly (RTFMS).
      Excuses: it is so much and I just wanted to compiler R20 in R21.
      But you are correct.

      BUT, adding iferr to the code worked, AND also solved the other issue.
      Everything is working now!

      Thanks!

      posted in Cinema 4D SDK
      P
      pim

    Latest posts made by pim

    • RE: Graphic card

      Great input, thanks.
      I will have a look at the Mac mini, if not, I will go back to a windows desktop.
      Again, thank you both.

      Regards,
      pim

      posted in General Talk
      P
      pim
    • Graphic card

      I am looking for a new pc with windows 11.
      This time I would like to buy a mini pc.
      However, most mini pc have none NVidia card, for example the AMD Ryzen 680M 12 Core 2400 MHz graphic card.
      Is that a good choice for running cinema 4d?

      posted in General Talk off-topic
      P
      pim
    • RE: Setting Noise as the Shader in a Displacer

      Ok, I understand it now better, thanks.

      posted in Cinema 4D SDK
      P
      pim
    • RE: Setting Noise as the Shader in a Displacer

      @pim
      I solved it.
      You must insert the shader into the document and then insert it in the displacer

      from typing import Optional
      import c4d
      
      doc: c4d.documents.BaseDocument  # The active document
      op: Optional[c4d.BaseObject]  # The active object, None if unselected
      
      def main() -> None:
      
          displacer = c4d.BaseObject(c4d.Odisplacer)
          doc.InsertObject(displacer)
          
          shd = c4d.BaseList2D(c4d.Xnoise)
          doc.InsertShader(shd)
          displacer[c4d.ID_MG_SHADER_SHADER] = shd
          
          #displacer.InsertShader(shd)
          c4d.EventAdd()
          
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK
      P
      pim
    • Setting Noise as the Shader in a Displacer

      I am trying to set the Shader field in the Displacemtn object to Noise. However, the filed is not filled.

      Here the code.
      What am I doing wrong?

      from typing import Optional
      import c4d
      
      doc: c4d.documents.BaseDocument  # The active document
      op: Optional[c4d.BaseObject]  # The active object, None if unselected
      
      def main() -> None:
      
          displacer = c4d.BaseObject(c4d.Odisplacer)
          doc.InsertObject(displacer)
          
          shd = c4d.BaseList2D(c4d.Xnoise)
          #displacer[c4d.ID_MG_SHADER_SHADER] = shd
          
          displacer.InsertShader(shd)
          c4d.EventAdd()
          
      if __name__ == '__main__':
          main()
          
      
      posted in Cinema 4D SDK python 2023
      P
      pim
    • RE: Best way to detect an object has been deleted?

      Thanks again for the great explanation.
      I guess I will go for a different workflow then.

      posted in Cinema 4D SDK
      P
      pim
    • RE: Best way to detect an object has been deleted?

      I am not sure what you mean with a Baselink?

      A Cloner, imo, does not notice when a child is added or deleted.

      I guess there is (somewhere) a message that signals a deletion?

      posted in Cinema 4D SDK
      P
      pim
    • Best way to detect an object has been deleted?

      I have a plugin that created a Cloner and insert planes as children of that cloner. After that I update the Cloner Count.
      However, when the user deletes a plane ( a child of that cloner), the Cloner count must be updated.

      What is the best way to detect an object has been deleted and I can update the Cloner count?

      posted in Cinema 4D SDK python 2023
      P
      pim
    • RE: Insert my own command in main render Tab

      I really do appreciate all your effort and I will take your warning seriously and create my own menu Tab.
      Thanks again.

      Regards,
      Pim

      posted in Cinema 4D SDK
      P
      pim
    • RE: Insert my own command in main render Tab

      @ferdinand
      I run the script, but it hangs cinema 4d.
      After some debugging, I could see that the insertion point was found and that it was inserted in items.
      I am not sure what statement hangs cinema 4d.

      I am using R2023.2.1 on a Windows 10 Pro 22H2.
      d55cbe3b-bde3-460d-8c7f-d82e92fde5fc-image.png

      posted in Cinema 4D SDK
      P
      pim