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
    • Login
    1. Maxon Developers Forum
    2. pim
    3. Best
    P
    • Profile
    • Following 0
    • Followers 0
    • Topics 92
    • Posts 279
    • Best 8
    • Controversial 0
    • Groups 0

    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