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. moGRR
    3. Posts
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 21
    • Best 3
    • Controversial 0
    • Groups 0

    Posts made by moGRR

    • RE: Is it possible to get a spline wrap object to use a python generated spline?

      Thanks @Cairyn

      I tried searching for that post, but I couldn't find it.

      I'm trying a slightly different approach now by using a python tag on a spline object. It's almost working but I'm having update issues.

      posted in Cinema 4D SDK
      M
      moGRR
    • Is it possible to get a spline wrap object to use a python generated spline?

      Hi all.

      I have created a Python Generator that looks at the hierarchy of it's children and generates a spline through them all. This part all works fin.

      However, when I create a Spline Wrap object and set the Python Generator as it's spline, nothing happens. Is there a way I can get a Spline Wrap object to use a spline created by a Python Generator?

      Thanks,
      Jamie

      posted in Cinema 4D SDK python
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      Hi @zipit - Thanks again for all your help and guidance with this.

      That last code you sent was really beneficial in helping me get a better understanding of how Python Generators work. I've got my Python Generator code working now just as I intended.

      Also, creating python tags rather than xpresso is a much more elegant way to achieve what I'm trying to do. I'm guessing that Python Generators might not be the best way to introduce yourself to Python in C4D?

      Having used AE for years and utilising Javascript expressions, I'm really excited about what python can open up to me with regards to C4D work. 🙂

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      @zipit Ah I did wonder if the behaviour was slightly different due to it being a Python Generator.

      I think I understand most of what you have said there, but being new to Python (and coding really) it can be quite tricky for me grasp. From the sounds of it, I might be trying to do TOO MUCH of it within a Python Generator? I'm open to better/alternative pipelines.

      Here is a bit more detail about what I'm trying to to achieve overall:

      • Create a Python Generator that:
        • Has a series of User Data values which it then uses to create a hierarchy with a Connect Object at the top (root) (tick)
        • When collapsing the Python Generator by pressing 'C', the Connect object also inherits the same User Data from the Python Generator (tick - it does this by default)
        • The Connect object also has an xpresso tag that links certain attributes within the hierarchy to the Connect object's User Data. (this is where I am stuck)

      So overall, what I would like to have is a Python Generator which allows me to change certain User Data values so that it generates the correct hierarchy of Cloners, Objects and Deformers. (This all works fine) , but then what I would also like is the Python Generator to create an Xpresso tag that dynamically links certain attributes to the root object's User Data so that even after I have collapsed the Python Generator into the hierarchy, I can still change the User Data on the root object (The Connect object) and Deformer objects within the hierarchy will change accordingly.

      I hope that makes sense?

      Does this sound like something that is possible?

      Cheers,
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      Thanks again @zipit

      To make things a bit clearer, here is what I am trying to do:

      Use a Python Generator to:

      • Create a Connector object
      • Create an Xpresso tag and assign it to the Connector object
      • Create a Deformer object (eg Bend) that is a child of the Connector object
      • Create a Node in the GV for the Connector Object
      • Create output ports for all of the Connector object's User Data.
      • Connect these ports to attributes of the Deformer object.

      I'm afraid I've got so confused with trying to get this right, that my code has become really messy with lots of things commented out as I try to figure what is working and what isn't.

      So I've created a new Python Generator with this code which is pretty much where I'm up to:

      def main():
          # Create Connector Object and insert an Xpresso tag to it
          connector_obj      = c4d.BaseObject(c4d.Oconnector)
          tag_xpresso        = c4d.BaseTag(c4d.Texpresso)
          connector_obj.InsertTag(tag_xpresso)
      
          # Get the node master and the root noode of that graphview.
          gvNode_master      = tag_xpresso.GetNodeMaster()
          gvNode_root        = gvNode_master.GetRoot()
          
          # Create a GV Node in the node Master 
          gvNode_controller  = gvNode_master.CreateNode(gvNode_root, c4d.ID_OPERATOR_OBJECT) 
          
          # Add port to GV Node
          USERDATA_NUMBER = 1
          gvNode_controller.AddPort(c4d.GV_PORT_OUTPUT, c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(USERDATA_NUMBER)), message=True)
          
          return connector_obj
      
      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      Hi all. I've installed the trial version of R21 (I'm looking to upgrade at some point anyway). However, I'm still struggling to get some python code that successfully adds ports to a GV node and then connects them.

      Any help would be massively appreciated.

      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      Thanks again @zipit

      From the link you sent it looks like it's fixed for R21. So I'm downloading the trial version now to see if I can get it working.

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Linking ports to xpresso node

      Thanks @zipit - that's helped me get a better understanding for connecting ports (please forgive me, I'm still very new to python). However, I'm still stuck with trying to add a 'User Data' port to the node.

      The Node I have created is c4d.ID_OPERATOR_OBJECT and then I use the following code to make sure it's referring to the right object:

      parentNode[c4d.GV_OBJECT_PATH_TYPE] = 0
      parentNode[c4d.GV_OBJECT_START_TYPE_ID] = 1
      

      But then I try and use the AddPort function to add an output port to the node but I can't get it working.

      posted in Cinema 4D SDK
      M
      moGRR
    • Python Generator - Linking ports to xpresso node

      Hi all.

      I’m wanting to use a python generator to create an xpresso tag that then links user data to an object’s attribute.

      I’ve got as far as being able to add the xpresso tag and have added the object node in the xpresso tag, but I’m having no joy with adding ports and linking them.

      Could anyone show me a simple example that does this?

      Many thanks,
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Adding Shaders to Deformer Objects

      @mp5gosu

      Ah brilliant. Thanks for that!

      And apologies for being such a noob at this.

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Adding Shaders to Deformer Objects

      @m_adam

      Sorry I should have made that a bit clearer. I didn't mean a specific context to my problem, obviously that is impractical.

      To give a better idea, with the GitHub link that Plugin Student sent, I'd find it really beneficial if there was a summary text that explained what the code does, and then maybe another example showing the code in another context?

      As someone that isn't a coder but is eager to learn the benefits of Python in C4D, I'd personally find that really helpful.

      Cheers,
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Adding Shaders to Deformer Objects

      Hi @m_adam

      Hmm good questions.

      I found the BaseShader Manual confusing because it looks like the example code isn't Python? It might be useful to have something that explicitly states what language the example code is in and what it does to help people like myself.

      The GitHub link was more useful but I think it could benefit from having a few more examples of the code being used in context. It helped me get a better understanding of what I was trying to do, but without actually confirming to me what it is I had to do exactly.

      I hope this makes sense?

      Thanks,
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Adding Shaders to Deformer Objects

      Thanks @PluginStudent - that's working now.

      Just so you know that I wasn't being lazy, I did look at the linked manual and the GitHub link, I just sometimes find them hard to follow as I'm not a coder.

      Thanks again for your help
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - Adding Shaders to Deformer Objects

      Thanks again @PluginStudent

      I'm not sure I fully understand how to get it working still... I adapted my code to below, but it still is generated with nothing in the [c4d.ID_MG_SHADER_SHADER] property

      def main():
          myNull = c4d.BaseObject(c4d.Onull)
          myCube = c4d.BaseObject(c4d.Ocube)
          myDeformer = c4d.BaseObject(1018685) # Deformer Object - Displacer
          myShader = c4d.BaseList2D(c4d.Xcolor) # Color Shader
          myDeformer.InsertShader(myShader)
          myCube.InsertUnder(myNull)
          myDeformer.InsertUnder(myNull)
          print myShader
          return myNull
      
      posted in Cinema 4D SDK
      M
      moGRR
    • Python Generator - Adding Shaders to Deformer Objects

      Hi all.

      I'm trying to use a python generator to create a Displacer deformer object that has a Color shader. However, I can't seem to get the Color shader bit of it to work. The Displacer object is generated but with nothing in it's [c4d.ID_MG_SHADER_SHADER]property. Here is an example of the code I'm using:

      def main():
          myNull = c4d.BaseObject(c4d.Onull)
          myCube = c4d.BaseObject(c4d.Ocube)
          myDeformer = c4d.BaseObject(1018685) # Deformer Object - Displacer
          myShader = c4d.BaseShader(5832) # Color Shader
          myDeformer[c4d.ID_MG_SHADER_SHADER] = myShader
          myCube.InsertUnder(myNull)
          myDeformer.InsertUnder(myNull)
      
          return myNull
      
      posted in Cinema 4D SDK python
      M
      moGRR
    • RE: Python Generator - Accessing Contour Spline

      Thanks again @PluginStudent for helping me so quickly.

      That was enough information to help me find the .MakeUserSpline function that allows me to do exactly what I'm after:

      MakeUserSpline('sin(x * PI)', 5)
      

      More info here for anyone looking.

      Cheers,
      Jamie

      posted in Cinema 4D SDK
      M
      moGRR
    • Python Generator - Accessing Contour Spline

      Hi all.

      I'd like to be able to have a python generator that creates a field object with a custom preset for it's contour spline for remapping

      I've used [c4d.FIELD_CONTOUR_MODE] = 4 to set the Contour Mode to Curve.

      I also have [c4d.FIELD_CONTOUR_SPLINE] for accessing the contour spline, I'm just not sure how I can go about setting it to a preset. Any help is massively appreciated.

      Many thanks,
      Jamie
      www.moGRR.co.uk

      posted in Cinema 4D SDK python
      M
      moGRR
    • RE: Python Generator - How to assign a field object to a deformer

      Oops - I forgot to have the following line:

      myDefObj[c4d.FIELDS] = myFieldList
      

      It all works perfectly now. Thanks again for your help @PluginStudent

      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - How to assign a field object to a deformer

      Thanks again Plugin Student.

      I wasn't too sure if I should have an EventAdd in a Python Generator or not, so thanks for clearing that up.

      So this is the code I now have, but it still isn't successfully adding the FieldList to the Deformer object:

      import c4d
      #Welcome to the world of Python
      
      
      def main():
          myParentNull = c4d.BaseObject(c4d.Onull)
      
          myDefObj = c4d.BaseObject(1021280) #1021280 = Squash And Stretch Deform Object
          myDefObj.InsertUnder(myParentNull)
      
          myFieldNull = c4d.BaseObject(c4d.Onull)
          myFieldNull.InsertUnder(myParentNull)
      
          myFieldObj = c4d.BaseObject(c4d.Flinear)
          myFieldObj.InsertUnder(myFieldNull)
      
          myFieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLfield)
          myFieldLayer.SetLinkedObject(myFieldObj)
      
          myFieldList = c4d.FieldList()
          myFieldList.InsertLayer(myFieldLayer)
      
          return(myParentNull)
      
      posted in Cinema 4D SDK
      M
      moGRR
    • RE: Python Generator - How to assign a field object to a deformer

      Thanks for the reply Plugin Student.

      Having a FieldList makes sense. I was kind of looking for something along those lines.

      I've tried incorporating your code into my python generator and I'm getting this error with the .InsertLayer line:
      AttributeError: 'NoneType' object has no attribute 'InsertLayer'

      Maybe I'm misunderstanding how the fieldlist and layers work? Here is the Python Generator code I am getting that error with:

      import c4d
      #Welcome to the world of Python
      
      
      def main():
          myParentNull = c4d.BaseObject(c4d.Onull)
      
          myDefObj = c4d.BaseObject(1021280) #1021280 = Squash And Stretch Deform Object
          myDefObj.InsertUnder(myParentNull)
      
          myFieldNull = c4d.BaseObject(c4d.Onull)
          myFieldNull.InsertUnder(myParentNull)
      
          myFieldObj = c4d.BaseObject(c4d.Flinear)
          myFieldObj.InsertUnder(myFieldNull)
      
          myFieldList = myDefObj[c4d.FIELDS]
          
          myFieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLfield)
          myFieldLayer.SetLinkedObject(myFieldObj)
          myFieldList.InsertLayer(myFieldLayer)
      
          c4d.EventAdd()
          return(myParentNull)
      
      posted in Cinema 4D SDK
      M
      moGRR