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
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. myosis
    3. Topics
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 14
    • Groups 0

    Topics

    • M

      Help Needed: Filtering Selected Edges by Length

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK windows python 2025
      2
      0 Votes
      2 Posts
      422 Views
      ferdinandF
      Hello @myosis, Welcome to the Maxon developers forum and its community, it is great to have you with us! Getting Started Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules. Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment. Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support. Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads. It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions. About your First Question All the methods you list simply do not exist (neither in C++ nor in Python), see c4d.utils.Neighbor for the type overview. I therefore must assume that you are using an AI, like, for example, ChatGPT, which hallucinated these methods. Please note that we reserve the right to refuse support when confronted with undisclosed AI gibberish, especially for beginner content. Always state when you used an AI to generate code. Something such as an edge does not exist concretely in our API and many other APIs, i.e., other than for points and polygons, there is no explicit data type for edges which would be stored. Edges are defined implicitly by CPolygon. To filter a selection for edges of a certain length, you would have to convert edge indices to polygon and point indices and then measure the distance between the relevant points. Cheers, Ferdinand Result [image: 1737027755224-074e2ada-a9ce-45b4-800a-acf7e060941a-image-resized.png] Code """Deselects all edges in the edge selection of the active object whose edge length exceeds MAX_EDGE_LENGTH. Must be run as a Script Manager script with an editable polygon object selected. """ import c4d doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. MAX_EDGE_LENGTH: float = 25.0 # The maximum length of an edge before to be considered too long. MAX_EDGE_LENGTH_SQUARED: float = MAX_EDGE_LENGTH ** 2 # The square of `MAX_EDGE_LENGTH`. def main() -> None: """Called by Cinema 4D when the script is being executed. """ if not op or not op.IsInstanceOf(c4d.Opolygon): raise ValueError("The selected object is not a polygon object.") # Get the edge selection of the object and turn it into a list of selected edges indices. Also, # get the points and polygons of the object. selection: c4d.BaseSelect = op.GetEdgeS() selectedEdges: list[int] = [i for i in range(op.GetEdgeCount()) if selection.IsSelected(i)] points: list[c4d.Vector] = op.GetAllPoints() polygons: list[c4d.CPolygon] = op.GetAllPolygons() def getPointByIndex(poly: c4d.CPolygon, index: int) -> c4d.Vector: """Returns the point of the polygon at the given index. CPolygon has no index access, so we fix that here. """ if index == 0: return points[poly.a] elif index == 1: return points[poly.b] elif index == 2: return points[poly.c] elif index == 3: return points[poly.d] # Iterate over the edges and find the one's that are longer than MAX_EDGE_LENGTH. An edge index # is defined as: # # "The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is # the edge index between 0 and 3." # # So, we must revert that here, then measure the edge length, and collect all too long edges. tooLongEdges: list[int] = [] for edgeIndex in selectedEdges: polygonIndex: int = edgeIndex // 4 edgeInPolygonIndex: int = edgeIndex % 4 poly: c4d.CPolygon = polygons[polygonIndex] pointA: c4d.Vector = getPointByIndex(poly, edgeInPolygonIndex) pointB: c4d.Vector = getPointByIndex(poly, (edgeInPolygonIndex + 1) % 4) # Getting the length of a vector is quite expensive, so we compare the squared lengths. edgeLengthSq: float = (pointA - pointB).GetLengthSquared() if edgeLengthSq > MAX_EDGE_LENGTH_SQUARED: tooLongEdges.append(edgeIndex) # Print the indices of the edges that are too long. print("The following edges are too long:", tooLongEdges) # Deselect all edges in the object's edge selection that are too long. for edgeIndex in tooLongEdges: selection.Deselect(edgeIndex) # Push an update event to Cinema 4D to redraw the object. c4d.EventAdd() if __name__ == '__main__': main()
    • M

      Render to texture transfer for C4D

      Watching Ignoring Scheduled Pinned Locked Moved General Talk
      1
      2 Votes
      1 Posts
      1k Views
      No one has replied
    • M

      Hide Layers

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      2
      0 Votes
      2 Posts
      675 Views
      r_giganteR
      Hi @myosis, thanks for reaching out us. With regard to your question, I'm not aware of any mean to hide a layer from the LayerManager nor any function in Cinema that has been designed to achieve this functionality. Cheers, R
    • M

      Grayed out or disabled X button

      Watching Ignoring Scheduled Pinned Locked Moved Cinema 4D SDK
      8
      0 Votes
      8 Posts
      1k Views
      M
      @mp5gosu This sounds like the solution I was looking for Thanks a lot! Ps, yes im a noob...
    • M

      How to access ‘Freeze View function’ with Python ?

      Watching Ignoring Scheduled Pinned Locked Moved General Talk
      7
      0 Votes
      7 Posts
      2k Views
      M
      Hi Unfortually this is not exposed, since it retrieve automatically the size of the view. Cheers, Maxime.
    • M

      Applying outline selection by script ?

      Watching Ignoring Scheduled Pinned Locked Moved General Talk
      5
      0 Votes
      5 Posts
      1k Views
      ferdinandF
      Hi, I am glad it does help you. I forgot to mention one thing, which is worth pointing out, when somebody stumbles over this thread, searching for performing edge selections. The way I treat edge selections in this script only works because of the specific scenario - selecting edges that are only associated with one polygon. In all other cases you have to select two edge ids (one for each polygon) for each edge or use the convenience methods of c4d.BaseSelect for that. Otherwise you will end up with a corrupted edge selection. Cheers zipit
    • M

      Render to texture for Cinema 4D

      Watching Ignoring Scheduled Pinned Locked Moved General Talk
      2
      0 Votes
      2 Posts
      1k Views
      a_blockA
      Hi, congratulation to your first plugin. Looks nice! Cheers, Andreas