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. johntravolski
    3. Topics
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 27
    • Best 0
    • Controversial 0
    • Groups 0

    Topics created by johntravolski

    • J

      ZeroConf error: Couldn’t get bonjour version [sys_bonjour.cpp(1725)]

      General Talk
      • • • johntravolski
      2
      0
      Votes
      2
      Posts
      521
      Views

      ManuelM

      Hi,

      This forum is dedicated for questions from developers about our API. Your issue is a user issue, please contact our support for that question.

      Cheers,
      Manuel

    • J

      Commandline.exe not loading lib4d preset materials

      General Talk
      • r19 • • johntravolski
      2
      0
      Votes
      2
      Posts
      541
      Views

      ManuelM

      Hi,

      This forum is dedicated to the support of our API. Your issue does not seem to be related to any coding question. If this is not the case, please contact our user support for any question.

      Cheers,
      Manuel

    • J

      Python Script to Export multiple GLTF files (glTF Exporter Unexpected Error)

      Cinema 4D SDK
      • python • • johntravolski
      3
      0
      Votes
      3
      Posts
      707
      Views

      J

      @m_magalhaes This worked great, thank you.

    • J

      Cubic Spline Looks Jagged

      General Talk
      • • • johntravolski
      5
      0
      Votes
      5
      Posts
      945
      Views

      ferdinandF

      Hello @johntravolski,

      without further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly.

      Thank you for your understanding,
      Ferdinand

    • J

      Formula Effector Spherical Effect U and V Interpretation

      General Talk
      • • • johntravolski
      2
      0
      Votes
      2
      Posts
      460
      Views

      ferdinandF

      Hello @johntravolski,

      thank you for reaching out to us. Please note that the Forum Guidelines state that the scope of Plugin café support requests is "bound to the scope of Cinema 4D public API support". So, your question is unfortunately out of scope for this forum. Please contact user support for questions about Cinema 4D itself.

      Thank you for your understanding,
      Ferdinand

    • J

      How to use c4d.VertexColorTag in Python Generator?

      Cinema 4D SDK
      • • • johntravolski
      5
      0
      Votes
      5
      Posts
      995
      Views

      ManuelM

      hi,

      it's not possible, but I've answer your other thread so we can figure out there what are the options to achieve your goal.

      Cheers,
      Manuel

    • J

      Color Surface with Python Generator

      Cinema 4D SDK
      • • • johntravolski
      18
      0
      Votes
      18
      Posts
      3.5k
      Views

      ferdinandF

      Hello @johntravolski,

      without any further questions, we will consider this topic as solved by Monday and flag it accordingly.

      Thank you for your understanding,
      Ferdinand

    • J

      scipy.special in R19?

      General Talk
      • • • johntravolski
      2
      0
      Votes
      2
      Posts
      462
      Views

      ferdinandF

      Hi @johntravolski,

      thank you for reaching out to us. I unfortunately have to point out that 3rd party library support is not being provided by us, as declared in our Forum Guidelines. You are however more then welcome to discuss this topic with the community.

      That being said, ufuncs is a numpy library that encapsulates common important functions used in numpy in a C library and somewhat known to sometimes cause hiccups when your numpy installation is "out of sync" with your os. This is probably here caused by mismatching versions of numpy and scipy. At least this would be my first guess. We unfortunately can provide no further support on this.

      Cheers,
      Ferdinand

    • J

      Create Geometry from Python Generator

      Cinema 4D SDK
      • python • • johntravolski
      7
      0
      Votes
      7
      Posts
      1.3k
      Views

      J

      @johntravolski
      I figured it out, I needed to add

      node.Message(c4d.MSG_UPDATE)

      after the for double loop where I set the polygons.

    • J

      Cannot Connect Xpresso Nodes in Python

      General Talk
      • • • johntravolski
      3
      0
      Votes
      3
      Posts
      727
      Views

      M

      Hi, here in Cinema 4D S22 defining the type of the cloner I don't have anymore an issue

      import c4d from c4d import gui import math def main(): # Build Parent Cloner cloner = c4d.BaseObject(1018544) cloner[c4d.ID_MG_MOTIONGENERATOR_MODE] = c4d.ID_MG_MOTIONGENERATOR_MODE_LINEAR doc.InsertObject(cloner) # Build Null newnull = c4d.BaseObject(c4d.Onull) newnull.InsertUnder(cloner) # Build Children Cloner internal_cloner = c4d.BaseObject(1018544) internal_cloner[c4d.ID_MG_MOTIONGENERATOR_MODE] = c4d.ID_MG_MOTIONGENERATOR_MODE_GRIDARRAY internal_cloner.InsertUnder(newnull) internal_cloner.Message(c4d.MSG_MENUPREPARE, doc) # Cube cube = c4d.BaseObject(c4d.Ocube) internal_cloner.Message(c4d.MSG_MENUPREPARE, doc) cube.InsertUnder(internal_cloner) # Xpresso Tag xtag = c4d.BaseTag(c4d.Texpresso) cloner.InsertTag(xtag) # Setup Parent Cloner cloner[c4d.MG_LINEAR_OBJECT_POSITION, c4d.VECTOR_Y] = 0.0 cloner[c4d.MG_LINEAR_OBJECT_POSITION, c4d.VECTOR_Z] = 500.0 cloner[c4d.MG_LINEAR_COUNT] = 10 cloner[c4d.MGCLONER_VOLUMEINSTANCES_MODE] = c4d.MGCLONER_VOLUMEINSTANCES_MODE_RENDERINSTANCE # Setup Children Cloner internal_cloner[c4d.MG_GRID_SIZE] = c4d.Vector(300, 200, 100) # Setup Cube cube[c4d.PRIM_CUBE_LEN] = c4d.Vector(20, 10, 100) # Setup Xpresso # http://mograph.net/board/index.php?/topic/26338-creating-xpresso-nodes-with-python-script/ nodemaster = xtag.GetNodeMaster() node1 = nodemaster.CreateNode(nodemaster.GetRoot(), c4d.ID_OPERATOR_OBJECT, None, 100, 100) node1[c4d.GV_OBJECT_OBJECT_ID] = internal_cloner gridResParam = c4d.DescID(c4d.DescLevel(c4d.MG_GRID_RESOLUTION, c4d.DTYPE_VECTOR,0), c4d.DescLevel(c4d.VECTOR_Z, c4d.DTYPE_REAL,0)) node1out = node1.AddPort(c4d.GV_PORT_OUTPUT, gridResParam) node2 = nodemaster.CreateNode(nodemaster.GetRoot(), c4d.ID_OPERATOR_OBJECT, None, 300, 100) node2[c4d.GV_OBJECT_OBJECT_ID] = cloner posParam = c4d.DescID(c4d.DescLevel(c4d.MG_LINEAR_OBJECT_POSITION, c4d.DTYPE_VECTOR,0), c4d.DescLevel(c4d.VECTOR_Z, c4d.DTYPE_REAL,0)) node2in = node2.AddPort(c4d.GV_PORT_INPUT, posParam) # Connect if node1out is not None and node2in is not None: node1out.Connect(node2in) c4d.EventAdd() # refreshed viewport to see changes automatically if __name__=='__main__': main()

      And as pointed by @PluginStudent the problem was because the AddPort fails. And I guess it failed because at the time you ask for the port creation since no explicit mode was defined in the Cloner the XPresso description was not properly fed so this GvPort didn't exist.

      Cheers,
      Maxime.

    • J

      Set Spline Tangents with Python Generator

      Cinema 4D SDK
      • • • johntravolski
      3
      0
      Votes
      3
      Posts
      1.1k
      Views

      J

      @zipit said in Set Spline Tangents with Python Generator:

      > """Example for constructing smooth tangents in a bezier spline. > > Run this with a spline object selected that has at least three vertices. It > will set the tangents of the second vertex of the spline in respect to its > neighbors. > """ > > import c4d > > > def project_on_line(p, a, b): > """Projects the point p onto the line which contains the line segment ab. > > Args: > p (c4d.Vector): The point to project. > a (c4d.Vector): The first point of the line segment. > b (c4d.Vector): The second point of the line segment. > > Returns: > c4d.Vector: The projection of p onto the line described by the line > segment ab. > """ > # Not much to explain here, check a trigonometry textbook on point line > # projections / the dot product if you are lost. > ab = b - a > t = ((p - a) * ab) / ab.GetLengthSquared() > return a + ab * t > > > def construct_vertex_frame(p, q, r): > """Constructs a frame for a spline vertex and its two normalized tangent > lengths. > > Args: > p (c4d.Vector): The point of the vertex for which to construct the > frame. > q (c4d.Vector): The point of the vertex which is the vertex before p. > r (c4d.Vector): The point of the vertex which is the vertex after p. > > Returns: > float, float, c4d.Vector: The normalized length of the left and > right tangent and the frame. > """ > > # The Vectors pointing from p to q and from p to r. > a, b = q - p, r - p > > # Now we construct our frame axis, I did use axis labels instead of the > # terms normal, binormal and tangent to keep things unambiguous. > > # The x-axis or tangent of the frame, i.e. the axis along which we will > # place out tangent control points. > x = (r - q).GetNormalized() > # The z-axis or normal of the frame, which is the normal to the plane > # of the three points. We just take the cross product of two vectors that > # lie in that plane. > z = (x % a).GetNormalized() > # The y axis or binormal of the frame, we just build it with the two > # other axis. > y = (x % z).GetNormalized() > # The finished matrix/frame. It is important to set the offset to the > # zero vector and not p, since each tangent pair lives in its own tangent > # space relative to their vertex. > frame = c4d.Matrix(c4d.Vector(), x, y, z) > > # We are technically finished here, but we could do some more, as we > # will have to determine the length of each tangent. We could just set > # these to a fraction of the vectors a, b, but this will give us odd > # results when theta, the angle between a and b is getting smaller and > # smaller. Instead we will project both a and b onto x and return the > # lengths of those two projections as the normalized length for the > # respective tangent. > origin = c4d.Vector() > tlength_left = project_on_line(a, origin, x).GetLength() > tlength_right = project_on_line(b, origin, x).GetLength() > > # Return the length of the left and right tangent and the frame. > return tlength_left, tlength_right, frame > > > def align_tangents(node, i, rel_scale_left=.5, rel_scale_right=.5): > """Aligns the tangents of a spline at a given index. > > Calculates the frame for the given vertex and sets its tangents for a > smooth interpolation in respect to its two neighbors. Will also force > the spline into bezier mode. > > Note: > This currently cannot handle the first and last vertex. It is trivial > to implement this, but things would have gotten more bloated, so I > kept short and (slightly) flawed. > > Args: > node (c4d.SplineObject): The spline. > i (int): The index of the vertex to align the tangents for. Has to > satisfy "0 < i < vertex_count - 1". > rel_scale_left (float, optional): The relative scale of the left > tangent. Defaults to 50%. > rel_scale_right (float, optional): The relative scale of the right > tangent. Defaults to 50%. > > Raises: > TypeError: When 'node' is not a SplineObject. > ValueError: When 'i' is out of bounds. > """ > if not isinstance(node, c4d.SplineObject): > raise TypeError("Expected SplineObject as input.") > > points = node.GetAllPoints() > # Out of bounds condition for the spline vertex indices. > if i < 1 or len(points) < i + 1: > raise ValueError("Index out of bounds.") > > # The three consecutive spline vertices that form the plane. p is > # the mid vertex for which we want to set the tangents and q and r > # are the vertices previous and next to it. > q, p, r = points[i-1:i+2] > # The normalized length of the tangents and the frame. > tlength_left, tlength_right, frame = construct_vertex_frame(p, q, r) > > # Constructing the tangents: > tangent_left = c4d.Vector(-tlength_left * rel_scale_left, 0, 0) * frame > tangent_right = c4d.Vector(tlength_right * rel_scale_right, 0, 0) * frame > > # Update the spline. > if node[c4d.SPLINEOBJECT_TYPE] is not c4d.SPLINETYPE_BEZIER: > node[c4d.SPLINEOBJECT_TYPE] = c4d.SPLINETYPE_BEZIER > node.SetTangent(i, tangent_left, tangent_right) > node.Message(c4d.MSG_UPDATE) > > # For visualization purposes we insert the frame of our vertex as a > # null object. SHOULD BE COMMENTED OUT. > null = c4d.BaseList2D(c4d.Onull) > null.SetMg(frame) > null.SetName("frame_for_vertex_" + str(i)) > doc.InsertObject(null) > > # Push the changes to Cinema. > c4d.EventAdd() > > > def main(): > """Entry point. > """ > # ALign the tangents of the second vertex of the selected spline object. > if op: > align_tangents(op, 1) > > > if __name__ == "__main__": > main()

      This was extremely helpful, thank you very much. My 3d geometry / Calc III is pretty rusty and seeing this really helped.