Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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. Kantronin
    3. Topics
    Offline
    • Profile
    • Following 3
    • Followers 0
    • Topics 20
    • Posts 38
    • Groups 0

    Topics

    • KantroninK

      String to Spline (cast)

      Watching Ignoring Scheduled Pinned Locked Moved General Talk programming
      2
      0 Votes
      2 Posts
      270 Views
      ferdinandF
      Hey @Kantronin, Thank you for reaching out to us. Unfortunately, I do not understand your question. The print out you provided, <c4d.SplineObject object ..., already indicates that the object is a c4d.SplineObject. So, I do not really understand what you mean with 'get a spline-type variable'. To get the underlying editable spline object for a spline generator, e.g., get a spline with editable vertices and tangents for a Flower Spline generator, you should use BaseObject.GetRealSpline. But that is only necessary when you have a BaseObject which under the hood represents a spline. It does not apply when you already have a SplineObject as you do. Cheers, Ferdinand
    • KantroninK

      Joining Polygon Objects (MCOMMAND_JOIN)

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      2
      0 Votes
      2 Posts
      271 Views
      ferdinandF
      Hello @Kantronin, Thank you for reaching out to us. Your script does not work because it does not follow the conditions of MCOMMAND_JOIN. Joins the objects that are parented to the passed null object. Passing multiple objects into SMC will not join them. edit: Moved this into the correct forum and added a small example. Cheers, Ferdinand Here is how I would write that in modern Cinema 4D. I have seen that your screenshot is from an older version such as S26, or even older, but I cannot write code examples for such old versions. There are multiple things that wont work in such old version such as type hinting and the mxutils lib, but you will be able to copy the general approach - move everything under a null while preserving the transforms. Code """Demonstrates how to join all objects in a document. """ import c4d import mxutils doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. def main() -> None: """Called by Cinema 4D when the script is being executed. """ # There is no super good way to do this in the manner you implied, joining everything in a # document. I clone here the whole document, which is not the cheapest operation (but also # not as expensive as it may sound like). When we do not have to join everything, it is better # just to clone the things you want to join. En even better way could be to not clone anything # and instead use undos to revert the transform and hierarchy changes we have to make. temp: c4d.documents.BaseDocument = doc.GetClone(c4d.COPYFLAGS_NONE) firstObject: c4d.BaseObject | None = temp.GetFirstObject() if firstObject is None: c4d.gui.MessageDialog("No object selected.") return # Get all objects in the document, and move them under a null object. We must record and # restore their global matrices, when we deconstruct the scene and move it all under one null # object. allObjects: list[c4d.BaseObject] = list(mxutils.IterateTree(firstObject, True)) null: c4d.BaseObject = mxutils.CheckType(c4d.BaseObject(c4d.Onull)) for obj in allObjects: mg: c4d.Matrix = obj.GetMg() # save the transform of the object obj.Remove() # Technically not necessary in the Python API, as it will do it for you when # you call things like InsertUnderLast. But C++ will not do that and a node # cannot be inserted more than once in a document, otherwise the fireworks # will start. obj.InsertUnderLast(null) obj.SetMg(mg) # restore the transform of the object under the null # Insert the null object into the temporary document and then join all objects under it. temp.InsertObject(null) result: list[c4d.BaseObject] = c4d.utils.SendModelingCommand( command=c4d.MCOMMAND_JOIN, list=[null], doc=temp, mode=c4d.MODELINGCOMMANDMODE_ALL, ) if not result: c4d.gui.MessageDialog("Failed to join objects.") return # Now insert the joined object into the original document. joinedObject: c4d.BaseObject = result[0] joinedObject.SetName("Joined Object") joinedObject.Remove() doc.InsertObject(joinedObject) c4d.EventAdd() if __name__ == '__main__': main()
    • KantroninK

      Center Axis with Python

      Watching Ignoring Scheduled Pinned Locked Moved General Talk programming
      5
      1
      0 Votes
      5 Posts
      1k Views
      i_mazlovI
      Hi @Kantronin, Instead of creating multiple consequent postings please consolidate them in a single one. I've also noticed that you've added "programming" tag but haven't mentioned the language you're talking about (is it c++ or python?). Regarding your questions. Transforming the axis of a PointObject effectively means transforming the point values. There're some helping commands that I've shown you in my previous message, but what they effectively do is just transforming the points. Please have a look into the operation_transfer_axis_s26.py example, which demonstrates how to perform axis translation. As for the rotation part, I'd need to point you once again to our Matrix Manual, which actually contains the answer to your question. Namely, the chapter "Constructing and Combining Transforms" explains the usage of functions c4d.utils.MatrixRotX(), c4d.utils.MatrixRotY() and c4d.utils.MatrixRotZ(). I will not copy & paste the same code snippet from our manual, so please check it youself. Combining these with the example above should do the trick for you, unless you don't have the initial transformation of your ring splines. If that's the case, then your task turns into a way more complex form of the optimization problem. Please also note, that you can only do the object axis transformations on PointObject (and on PolygonObject since it's inherited from PointObject). This effectively means that if you're using the Osplinecircle instead of an ordinary Ospline, this wouldn't work, as it doesn't store any points inside. In this case you'd need to convert to Ospline. If that's not an option for you, you can check the Geometry Axis and Geometry Orientation scene nodes, as they allow you to transform the axis "on-the-fly", so this would work even with non-point objects. Cheers, Ilia
    • KantroninK

      Updating a spline

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      3
      0 Votes
      3 Posts
      677 Views
      KantroninK
      @ferdinand I made this function which works fine: def spline_update(doc,spline,tabNewPoint): tabPoint = spline.GetAllPoints() dim = len(tabNewPoint) if len(tabPoint) != dim: spline.ResizeObject(dim) for i in range(0,dim): point = tabNewPoint[i] spline.SetPoint(i,point) spline.Message(c4d.MSG_UPDATE) return spline
    • KantroninK

      Move objects in the hierarchy

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      2
      1
      0 Votes
      2 Posts
      659 Views
      KantroninK
      I found the solution on https://plugincafe.maxon.net/ It was enough in the for loop to add the following line of code: for object in list_object: if object != object_root: object.InsertUnder(object_root) c4d.EventAdd()
    • KantroninK

      Remove points from a polygon

      Watching Ignoring Scheduled Pinned Locked Moved General Talk
      2
      0 Votes
      2 Posts
      749 Views
      ferdinandF
      Hey @kantronin, Thank you for reaching out to us. I would recommend having a look at the Modeling Python Examples. They are a bit hidden, but in the Geometry section I went over the general classic API geometry model of Cinema 4D. Regarding your core questions: Removing points from a polygon: Without wanting to be overly pedantic, I must point out that polygons only index vertices, they do not hold them; CPolygon references with its fields a, b, c, and d the vertices of the PolygonObject it is attached to. In this sense removing points from a polygon is not possible, you can just de-index them. Cinema 4D expresses both triangles and quadrangles with the type CPolygon, i.e., as quadrangles. A triangle simply repeats its c index in its d index. I explained this in the modelling examples in more detail. Removing vertices or polygons from a PolygonObject: There is neither a PolygonObject.RemovePolygon nor aPointObject.RemovePoint if that is what you are looking for. When you want to change the vertex or polygon count of a PolygonObject, you must call PolygonObject.ResizeObject and then call PointObject.SetAllPoints() and for each (new) polygon PolygonObject.SetPolygon. The operation_extrude_polygons_s26 example covers this subject, although I go there into the opposite direction, I increase the point and polygon count rather than decreasing it. PS: Useful might also be geometry_polygonobject_s26 because I explained there the type from scratch. Cheers, Ferdinand
    • KantroninK

      Creation of UVW tag for a plane

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      2
      1
      0 Votes
      2 Posts
      465 Views
      ManuelM
      hi, you can use CallUVCommand. The forum also has different thread already talking about it. This one for example, explain how to use command to pack your UVs. It shows how to automatically unwarp your model and answer what you are looking for. This is done using SendModelingCommand with some parameters, those parameters can be found here in the c++ documentation. Of course, you can also create the uvw tag yourself and define the uvw coordinates as you wish. You have this thread for example that shows how to do a planar projection. Cheers, Manuel
    • KantroninK

      Rotation for polygon

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      3
      0 Votes
      3 Posts
      775 Views
      KantroninK
      @ferdinand Thanks, it works well My first method was complex: creation of a new orthogonal spatial system, with one of its axes is identical to the axis of rotation compute the coordinates of the points of the object in this new spatial system, then rotate the object calculation of the new coordinates in the initial orthogonal spatial system.
    • KantroninK

      Polygon corresponding to a selection

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      5
      2
      0 Votes
      5 Posts
      939 Views
      M
      Hi @Kantronin I don't think there is that much to add but I want to mention that c4d.CallCommand automatically add an undo to the undo stack, while c4d.utils.SendModelingCommand with it's flags arguments can be defined. But you need to start and end the undo with the c4d.utils.SendModelingCommand, so this way you can have multiple SendModelingCommand within an undo. See basedocument_undo example for undo management. Cheers, Maxime.
    • KantroninK

      Selection associated with a texture tag

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      4
      0 Votes
      4 Posts
      636 Views
      M
      Hi @Kantronin, I don't have a lot to add Thanks @Cairyn , for more information about the console, please read Python Console. Cheers, Maxime.
    • KantroninK

      Face associated with a selection

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      4
      1
      0 Votes
      4 Posts
      677 Views
      KantroninK
      Thanks for your quick replies I used GetBaseSelect() which allowed me to have the selected faces for each selection list_polygon = obj.GetAllPolygons() dim = len(list_polygon) L = [] tag = obj.GetFirstTag() while tag: if tag.GetType() == c4d.Tpolygonselection: sel = tag.GetBaseSelect() L2 = [] for i in range(0,dim): if sel.IsSelected(i): L2.append(i) L.append([tag.GetName(),L2]) tag = tag.GetNext() for item in L: print item[0] print item[1]
    • KantroninK

      How to create a layer Reflection (Legacy) ?

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      2
      0 Votes
      2 Posts
      588 Views
      KantroninK
      I found the solution to my problem, on the internet, with code samples: https://www.c4dcafe.com/ipb/forums/topic/101805-materials-and-shaders-with-python/
    • KantroninK

      Transparency channel - Color update

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      3
      0 Votes
      3 Posts
      714 Views
      KantroninK
      I found the solution (I already had this problem but I couldn't remember the right code) mat [c4d.MATERIAL_TRANSPARENCY_COLOR] = c4d.Vector (1.0, 1.0, 1.0) #color white mat.Update (True, True)
    • KantroninK

      How to apply a material to a selection of an object

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      3
      0 Votes
      3 Posts
      530 Views
      ManuelM
      hi, juste as a follow up, we've update our example and include this one. insert a material to the selected polygons Cheers, Manuel
    • KantroninK

      Welding point for a polygon

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      2
      0 Votes
      2 Posts
      493 Views
      r_giganteR
      Hi Kantronin, thanks for reaching out us and welcome to PluginCafé. To make Cinema 4D programatically executing modeling commands, you can make use of SendModelingCommand which properly satisfy your scope. Aside from the example shown in the documentation you can also have a look at this post from @maxime and this other post about Optimize command. Last but not least be aware that the modeling command settings are specified in the BaseContainer passed to the SendModelingCommand and whose parameters can be found in the MCOMMAND page. Finally please remind to use Tags and Ask as a question for any future support entries
    • KantroninK

      Adding points to a spline

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      3
      0 Votes
      3 Posts
      746 Views
      ManuelM
      hello, without information from your part, i'll consider this thread as solved and change its states Cheers, Manuel
    • KantroninK

      Using AddEditNumberArrows

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python
      2
      0 Votes
      2 Posts
      401 Views
      ManuelM
      hello, you have to use the step parameter as showned in the documentation here self.SetFloat(datafield_displacement, 1.0, min=0.0, step=0.1) Cheers, Manuel
    • KantroninK

      Transform coordinates of a polygon's points

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      5
      0 Votes
      5 Posts
      1k Views
      i_mazlovI
      Hi @SmetK, Please note that we have a great Matrix Manual with code samples. You can also check our github repository for the geometry examples, e.g. the Polygon Object example. For your further questions I kindly encourage you to create new thread and shape your posting according to how it's described in our Support Procedures: Asking Question. Cheers, Ilia
    • KantroninK

      Objects created in real time

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK python r19 r21 r20
      6
      0 Votes
      6 Posts
      1k Views
      ManuelM
      Hello, For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here. Q&A New Functionality. How to Post Questions especially the tagging part. @zipit and @Cairyn have already answer here (thanks a lot) nothing to add. Cheers, Manuel
    • KantroninK

      How to print in the console ?

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      3
      0 Votes
      3 Posts
      635 Views
      KantroninK
      I used the frame of your code to make plugins from scripts that I wrote, and now I can send my results to the console. Thanks