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

    select a polygon

    PYTHON Development
    0
    19
    1.3k
    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
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 27/03/2012 at 09:00, xxxxxxxx wrote:

      an external editor is the best way, but for the beginning i would stick with the builtin editor, 
      as you will have to execute the scipt often to find your syntax errors. i am using sublimetext2 ,
      another popular choice would be notepad++.

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 27/03/2012 at 09:05, xxxxxxxx wrote:

        there is that for MAC? is the code ready to use for C4D (i mean if i code the script, when i run c4d i've to update the code?)

        How can i select the front polygon face of the cube created by the code you have indicated all i can see is code to select the edge but not the full polygon (made by 2 edges)?

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 27/03/2012 at 09:30, xxxxxxxx wrote:

          selections are references in python, so you will set a polygon selection this way :

              sel =  obj.GetPolygonS()
              sel.Select(2)     
          

          changing the baseselect you got returned from GetPolygonS will also change the actual selection.

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 27/03/2012 at 13:28, xxxxxxxx wrote:

            i've tried to do this:

            import c4d
            from c4d import gui, utils

            def main() :
              obj = c4d.BaseObject(c4d.Ocube)
              obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(30,30,100)
              res = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                              list = [obj],
                                              mode = c4d.MODELINGCOMMANDMODE_ALL,
                                              bc = c4d.BaseContainer(),
                                              doc = doc)[0]
              doc.InsertObject(res)
              c4d.EventAdd()
             
              doc.SetActiveObject(res)
              sel =  res.GetPolygonS()
              sel.Select(2)
              c4d.EventAdd()

            if __name__=='__main__':
              main()

            but i've two problem:

            1. i do execute button but nothing happen
            2. i try to select the node the unselect and click execute and it create 2-3 cubes once
            3. no polygons are selected 😞
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 27/03/2012 at 14:34, xxxxxxxx wrote:

              doc.SetActiveObject(res)
              

              doesn't work, res is the variable containing the result returned by utils.SendModelingCommand and not a reference to the object in your object manager.

              def main() :  
                  obj = c4d.BaseObject(c4d.Ocube)  
                  obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(30,30,100)  
                  res = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,  
                                                  list = [obj],  
                                                  mode = c4d.MODELINGCOMMANDMODE_ALL,  
                                                  bc = c4d.BaseContainer(),  
                                                  doc = doc)[0]
                  sel =  res.GetPolygonS()  
                  sel.Select(2)
                  doc.InsertObject(res)  
                  c4d.EventAdd()
              

              this would be the shortest way. even if doc.SetActiveObject(res) would be a propper statement, it would have no impact on your further code as selecting an object does not have any impact on your further python code. Baseodocument.SearchObject() would be the method you would use to get an object from the objectmanager. it returns an baseobject you could modify.

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 27/03/2012 at 22:28, xxxxxxxx wrote:

                Btw, nice Editor Ferdinand! I guess this will be my favorite editor in the future. 😉
                Thanks!

                -Niklas

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 28/03/2012 at 06:22, xxxxxxxx wrote:

                  how can i do a selection for one face of the cube using c4d.utils.SendModelingCommand(command = c4d.ID_MODELING_LIVESELECTION,...

                  i can't figure it out

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 28/03/2012 at 06:42, xxxxxxxx wrote:

                    just use the last snippet i have posted, it will create a cube, scale it, convert it and select the face 
                    with the index 2. please read the sdk, the python sdk is relative easy to understand despite some
                    weaknesses of it. i have explained the way selections are used within python, but you have actually
                    try to understand what i try to explain.

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 28/03/2012 at 07:37, xxxxxxxx wrote:

                      Littledevil, i always thanks you for your interest on my issue but using this code:

                      sel =  res.GetPolygonS()  
                          sel.Select(2)
                      
                          doc.InsertObject(res)  
                          c4d.EventAdd()
                      

                      but I get this error:
                      c4d.BaseObject' object has no attribute 'GetPolygonS'
                      Infact i've searched in SDK and BaseObject has not that function 😞

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 28/03/2012 at 10:07, xxxxxxxx wrote:

                        it is a member of c4d.polygonobject which inherits from c4d.baseobject. res in my given example
                        is always a polygonobject, so we don't have to check. but if you just allocate some baseobject
                        it won't work, just as you couldn't select a polygon on a parametric object within c4d.

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

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 29/03/2012 at 00:37, xxxxxxxx wrote:

                          so do I need to type casting it? If so this doens't work:

                          poly_obj = c4d.PolygonObject(res)

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

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 29/03/2012 at 02:35, xxxxxxxx wrote:

                            Finally i'm been able to make my script works!!!
                            I'm very happy. The only problem i've is just when i click on "Execute" button the main function is called twince! why?

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

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 29/03/2012 at 05:32, xxxxxxxx wrote:

                              Originally posted by xxxxxxxx

                              so do I need to type casting it? If so this doens't work:

                              poly_obj = c4d.PolygonObject(res)

                              the constructor of PolygonObject doesn't accept BaseoObjects as paramters, its parameters
                              are PolygonObject(pcnt, vcnt). but apart this fact we are meant to use BaseObject(type) 
                              to allocate objects in c4d. a new polygon object should be created this way :

                              myPolygonObject = c4d.BaseObject(Opolygon)

                              read the c++ sdk baseoject description, it includes an extensive list of allocatable types in c4d. 
                              and post your code or nobody will be able to help you.

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

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 29/03/2012 at 06:48, xxxxxxxx wrote:

                                It's very difficult to try to understand the sdk becouse is very little described and google/forum have very poor information about that and no examples around the net, but i'm understanding with big difficult and little by little.
                                Thanks

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