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. Kantronin
    3. Posts
    • Profile
    • Following 3
    • Followers 0
    • Topics 20
    • Posts 38
    • Best 2
    • Controversial 0
    • Groups 0

    Posts made by Kantronin

    • String to Spline (cast)

      I have a string variable whose value is the identifier of a spline:

      <c4d.SplineObject object called 'Spline1/Spline' with ID 5101 at 0x000001D672DC4F70>

      Given this identifier, how do I get a spline-type variable ?

      posted in General Talk programming
      KantroninK
      Kantronin
    • RE: I want to extract the polygon index of the inverted normal

      @ferdinand
      I'm showing an example with a curved surface composed of 8 zones.
      Each zone is the union of several polygons with normals oriented in the same direction (represented by an arrow).
      I think C4D should be able to identify this type of tiling and colorize these areas to highlight them.
      Depending on the case, this tiling could be important, but most often, creators assemble the faces logically.
      A window could then offer the option to select each tiling, in order to invert the normals with a single click.
      A plugin could also do this kind of work, which would save creators time.
      surface.jpg

      posted in General Talk
      KantroninK
      Kantronin
    • RE: I want to extract the polygon index of the inverted normal

      @seora
      If you take a simple, seamless 3D surface bounded by edges, you can almost always create two distinct sets of faces with the same orientation. Thus, under certain conditions, you can find the misoriented faces with a Python program.
      But generally, since C4D coding cannot find how a polygon should be interpreted, finding misoriented faces is geometrically impossible. Only an AI program could list possible scenarios to answer this question (knowing that several scenarios exist).
      On the other hand, if your Python program knows the target shape you're working on (cube, sphere, ellipse, torus, etc.), you can find the misoriented faces very easily.
      pic_surface.jpg

      posted in General Talk
      KantroninK
      Kantronin
    • RE: I want to extract the polygon index of the inverted normal

      @seora

      From a purely mathematical point of view, there must exist a set of polygons for which this extraction is theoretically possible, given how C4D encodes faces.
      But I think there must exist many polygons for which this possibility makes no sense. For example, a Möbius strip where there is no back and no front for a face.

      Twist.gif

      posted in General Talk
      KantroninK
      Kantronin
    • Joining Polygon Objects (MCOMMAND_JOIN)

      Hi
      The menu Mesh > Convert > Connect Objects allows you to connect polygons.
      I need to make this type of connection with a Python script.
      My current script isn't working properly.

      script_connect.py

      alt text

      posted in Cinema 4D SDK python
      KantroninK
      Kantronin
    • RE: Center Axis with Python

      The following example illustrates my problem.
      In this example, I translate and rotate the ring using C4D's interface.

      In figure 1, the ring is at point (0,0,0) with an angle of zero.
      Figure 1

      In figure 2, using the Cinema 4D interface, I translate the ring with the vector <2,1,3> in centimeters.
      Then I performed three successive rotations: 322° on the X axis, 30° on the Y axis and 343° on the Z axis.
      Cinema 4D positioned the axis center of the ring correctly.
      Figure 1

      But when I create my ring with 4 splines, at a point in space other than (0,0,0), the axis center always remains at the point (0,0,0) with an angle of zero.
      I'd like the axis center to be at the center of my ring and at the same angle as in Cinema 4D.

      posted in General Talk
      KantroninK
      Kantronin
    • RE: Center Axis with Python

      Let me explain.
      My problem may be complicated to understand, but my final request is very simple.
      In C4D, I've got into the habit of creating my 3D objects with splines, which allows me to create objects of any kind.
      I do this with Python.
      So to create a ring, I create 4 splines. Then, with these 4 splines, I create the ring.

      If my 4 splines are centered on the point (0,0,0) as shown in the image below, my ring lies on the XZ plane.
      The axis center of the ring is also on the point (0,0,0). What's more, it's well oriented, as its Y axis corresponds to the Y axis of my ring.
      Furthermore, the X axis of the axis center is aligned with the segments connecting the point (0,0,0) with the first points of my construction splines.
      In this case, everything is perfect.
      Figure 1

      However, if the center of my 4 splines is elsewhere and the orientation is arbitrary, as shown in the image below, this is where the problem arises.
      After creating my ring, the axis center remains at the point (0,0,0) and its orientation is identical to the previous case.
      Figure 2

      So I need to use Python to bring the axis center back to the center of my ring (translation).
      Next, I need to rotate the axis center so that its Y axis is perpendicular to the plane of my ring.
      Next, I need to rotate the axis center around its Y axis, so that its X axis is parallel to the segments connecting the center of the ring with the first points of my construction splines.

      In conclusion:
      I need the following functions:

      • a function that allows the translation of the axis center, from a point A to a point B
      • a function that allows the rotation of the axis center around its X axis
      • a function that allows the rotation of the axis center around its Y axis
      • a function that allows the rotation of the axis center around its Z axis
      posted in General Talk
      KantroninK
      Kantronin
    • Center Axis with Python

      Hi,

      With python, I generate a ring in space that is far from the center (0,0,0)

      The ring is in the plane formed by two vectors u and v.

      The vector w is perpendicular to the ring.

      After creating the ring, its center axis is at the position (0,0,0)

      I would like to place the center axis at the center of the ring whose position I know.
      In addition, I would like the axes of the center axis to correspond to the base (u,v,w) in which I created the ring.

      pic1.png

      posted in General Talk programming
      KantroninK
      Kantronin
    • RE: Updating a spline

      @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
      
      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • Updating a spline

      Hi

      How to update a spline if the number of points changes ?

      If the number of points is the same, we can use the following function:

      def spline_update(spline,tabPoint):
      	dim = len(tabPoint)
      	for i in range(0,dim):
      		spline.SetPoint(i,tabPoint[i])
      
      	spline.Message(c4d.MSG_UPDATE)
      	return spline
      

      If the number of points changes, we must use the ResizeObject() method

      I'm looking for an example, which will save me from doing tests.

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • RE: Move objects in the hierarchy

      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()

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • Move objects in the hierarchy

      Hi,

      With a script, I create a large number of objects in my scene.
      In the hierarchy, they are presented in the form of a list, which becomes difficult to read because it's too long.
      So I want to put the names of the child objects under the name of the root object.
      How can I do this ?

      def hierarchie_organise(doc, object_root, list_object):
      	# document name: doc
      	# object root: object_root
      	# child objects: list_object 
      
      	# checking (exclusion of the root object if it's in the list of child objects)
      	list_child = []
      	for object in list_object:
      		if object != object_root:
      			list_child.append(object)
      
      	# positioning of list_child objects under the object_root object
      	...
      	...
      	...
      
      	return 
      

      Truepic1.png

      posted in Cinema 4D SDK python
      KantroninK
      Kantronin
    • Remove points from a polygon

      I have created a function that adds points to a polygon.
      But how to remove a point from a polygon, as well as remove the faces that contain it ?

      posted in General Talk
      KantroninK
      Kantronin
    • Creation of UVW tag for a plane

      Creation of UVW tag for a plane
      I would like to know how to create texture coordinates for a plane, with python.
      So I want to create with python the basic UVW tag for a plan.
      I would like to get the same result as with Bodypaint.

      pic.jpg

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • RE: Rotation for polygon

      @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.
      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • Rotation for polygon

      Hi,
      I want to do a rotation for a polynone.
      I know the coordinates of the points of the polygon, in the global coordinate system.
      For this rotation, I know the axis of rotation, defined by a vector V, and the angle of rotation A with respect to this axis.

      I manage to do this type of rotation, with matrices and with a change of Cartesian coordinate system, but I know that there is a much simpler method with C4D python functions

      posted in Cinema 4D SDK python
      KantroninK
      Kantronin
    • RE: Polygon corresponding to a selection

      I am going to write a new script, using c4d.CallCommand and c4d.utils.SendModelingCommand which can do the same thing much faster.
      The Script log window presents the code very well, in real time, for many operations.

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • RE: Polygon corresponding to a selection

      @cairyn said in Polygon corresponding to a selection:

      SendModelingCommand

      Indeed, with SendModelingCommand it would be faster.
      I don't remember how we visualize with C4D the python code corresponding to the actions of the keyboard and the mouse.

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • Polygon corresponding to a selection

      Hi,

      I would like to know if we can quickly obtain a polygon corresponding to a selection.

      I manage to do it in python, but for the large meshes it's much too slow, because I do treatments on the indices of points and faces.

      Below, with python, I create two polygons with the corresponding material, for the two selections (selection_1 and selection_2)
      For a large mesh (greater than 100 Mo), the use of indices for points and faces considerably slows down the program.

      img1.jpg

      We see that the initial polygon has been divided correctly, according to the two selections

      img2.jpg

      posted in Cinema 4D SDK
      KantroninK
      Kantronin
    • RE: Selection associated with a texture tag

      Thank you.
      I had forgotten about this excellent feature of C4D.
      It must be said that I rarely do plugins, because now C4D can do a lot of things.

      posted in Cinema 4D SDK
      KantroninK
      Kantronin