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

    Remove NGons

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 819 Views
    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.
    • H Offline
      Helper
      last edited by

      On 26/12/2017 at 06:19, xxxxxxxx wrote:

      I tried to remove Ngons of a polygonal object but this script has no influence over the geometry.

        1. import c4d
        2.   
        3. def main() :
        4.   
        5.     op.GetPolygonS().SelectAll(op.GetPolygonCount())
        6.     res = c4d.utils.SendModelingCommand(command = c4d.ID_NGON_REMOVE_MENU,
        7.                                         list = [op],
        8.                                         mode    = c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
        9.                                         doc = doc)
        10.     c4d.EventAdd()
        11. if __name__=='__main__':
        12.     main()
      
      

      Sometimes I'm getting this error: A problem with this project has been detected: Object "Plane" - Polygon selection out of bounds. Please save and contact MAXON Support with a description of the last used commands, actions or plugins.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 26/12/2017 at 09:33, xxxxxxxx wrote:

        I never used this command but some SendModelingCommand return the object modified. Then you need to insert it into your document.

        Anyway print res.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 26/12/2017 at 10:00, xxxxxxxx wrote:

            1. import c4d
            2.   
            3. def main() :
            4.     
            5.     if op:
            6.         res = c4d.utils.SendModelingCommand(command = c4d.ID_NGON_REMOVE_MENU,
            7.                                             list = [op],
            8.                                             mode    = c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
            9.                                             doc = op.GetDocument())
            10.         **print res**
            11.         c4d.EventAdd()
            12. if __name__=='__main__':
            13.     main()
          
          

          for some reason, this code returns False
          I have selected polygonal object that has NGon lines.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 26/12/2017 at 10:13, xxxxxxxx wrote:

            Hi,

            ID_NGON_REMOVE_MENU is a menu command ID, not a modeling command ID so it must be used with CallCommand() instead of SendModelingCommand().
            Also, the command processes the selected Ngons. The code can be converted to:

            import c4d
              
            def main() :
                sel = c4d.BaseSelect()
                op.GetSelectedNgons(sel)
                sel.SelectAll(op.GetNgonCount())
                
                c4d.CallCommand(c4d.ID_NGON_REMOVE_MENU)
                c4d.EventAdd()
              
            if __name__=='__main__':
                main()
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 26/12/2017 at 10:24, xxxxxxxx wrote:

              is it possible to use CallCommand() in python generator or in generator plugins? or it can be used only as a script?

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 26/12/2017 at 10:30, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                is it possible to use CallCommand() in python generator or in generator plugins? or it can be used only as a script?

                CallCommand() is only allowed from the main thread so it's forbidden from generators. Sorry.

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