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

    Polygon corresponding to a selection

    Cinema 4D SDK
    3
    5
    892
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KantroninK
      Kantronin
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by Cairyn

        You are mixing up polygon and polygon object interchangeably in your posts, so I'm not sure what you mean by "obtain a polygon corresponding to a selection". Assuming you mean exactly the stuff you're showing in the screenshots, you can use the high-level functionality instead of going poly by poly: take the selection tag, select the polys within, split off the selection with the fitting SendModelingCommand. You may need to delete the polys from the original, too.
        This is most likely faster than handling all polys in Python, as SendModelingCommand will execute the functionality in the native C++ code.

        KantroninK 1 Reply Last reply Reply Quote 0
        • KantroninK
          Kantronin @Cairyn
          last edited by

          @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.

          KantroninK 1 Reply Last reply Reply Quote 0
          • KantroninK
            Kantronin @Kantronin
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by

              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.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • First post
                Last post