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

    BaseSelect.GetAll() is confusing

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 354 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

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

      On 17/08/2011 at 15:42, xxxxxxxx wrote:

      I'm trying to make a script that will make any selected polygons double-faced (i.e two polygons created on the same set of points). This is useful for certain models for games (e.g. thin objects like butterfly wings etc).

      Anyway, the first step is to get the polygons that have been selected. So I used GetPolygonS() which gives you a BaseSelect object and then GetAll() which is supposed to return a list of the selected polygons. However, for me the results are odd.

      Here is the code so far.

      _import c4d
      from c4d import gui
      from c4d import documents
      from c4d import BaseSelect
      #Welcome to the world of Python

      def main() :
        doc = documents.GetActiveDocument()
        objects = doc.GetActiveObjects(False)
        numObjects = len(objects)
        #print numObjects
        if numObjects > 0:
            obj = doc.GetActiveObject()
            if type(obj) == c4d.PolygonObject:
                #First we get the selected polygons
                selectedPolys = obj.GetPolygonS()
                print selectedPolys.GetCount(), "Selected Polygons are..."
                print selectedPolys.GetAll(selectedPolys.GetCount())
               
            else:
                gui.MessageDialog('Object is not a polygon object. Make it editible!')
               
        else:
            gui.MessageDialog('No objects were selected')
       
        return True

      if __name__=='_main__':
        main()

      If I create a plane with 4 quads, make it editable and select all faces, the results of printing GetAll() are as follows.

      4 Selected Polygons are
      [1,1,1,1]

      I was expecting that BaseSelect.GetAll() would return the indices of the polygons, and since there are 4 quads, I was expecting [0,1,2,3] for the results (although not necessarily in that order).

      Any ideas what I am doing wrong? Thanks in advance.

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

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

        On 18/08/2011 at 11:28, xxxxxxxx wrote:

        GetAll returns a list with boolean values (selected or not | 1 or 0).

          
        x = bs.GetAll()   
        if x[polygon_index]:   
          # polygon with index 'polygon_index' is selected
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post