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

    Script not working anymore

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 205 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 14/06/2014 at 23:40, xxxxxxxx wrote:

      I put this script together to write the points and polys to a file to use again some place else. It worked a few times but not anymore. I tried it in a new python node but still not working.

      import c4d
      #Welcome to the world of Python
      obj = doc.SearchObject("Head")

      def All_Points() :
          
              
          obj_points = obj.GetAllPoints()
          obj_poly = obj.GetAllPolygons()
                  
          PointFile = "D:\Users\Carel\Desktop\Point.txt"
          Point_File = open('Point.txt','w')
            
          for i, line in enumerate(obj_points) :
                 
            point_Ind = i
            point_Ln = line 
                            
            Point_File.write("mypoly.SetPoint(" + str(point_Ind) + ",c4d." + str(point_Ln) + ")" + '\n')
                      
          Point_File.close()
          
          PolyFile = "D:\Users\Carel\Desktop\Poly.txt"
          Poly_File = open('Poly.txt','w')
        
          for i, line in enumerate(obj_poly) :
                 
            poly_Ind = i
            poly_Ln = str(line)
            Str_Line = poly_Ln.translate(None,"abcd:")
                                        
            Poly_File.write("mypoly.SetPolygon(" + str(poly_Ind) + ",c4d.CPolygon" + str(Str_Line) + ")" + '\n')
           
          Poly_File.close()
          
      def Selected_Points() :
              
              Pts_List = []
              Max_Pts = obj.GetPointCount()
              Sel_Pts = obj.GetPointS()
              
              PointFile = "D:\Users\Carel\Desktop\Sel_Points.txt"
              Point_File = open('Sel_Points.txt','w')
              
              for index, selected in enumerate(Sel_Pts.GetAll(Max_Pts)) :
                  
                  if not selected: continue
                   
                  else:
                      
                      Pts_List.append(index)
                       
              print Pts_List
              
              Point_File.write(str(Pts_List) + '\n')
          
      def main() :
          
          if Input1 == True:
              
             return All_Points()
                
          if Input2 == True:
              
             return Selected_Points()

      I don't get any errors, nothing.
      Please anyone 😢

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

        On 15/06/2014 at 06:40, xxxxxxxx wrote:

        Ok I got it working again. The red color is what needs changing:

        import c4d
        #Welcome to the world of Python
        obj = doc.SearchObject("Head")

        def All_Points() :
            
                
            obj_points = obj.GetAllPoints()
            obj_poly = obj.GetAllPolygons()
                    
            PointFile = "D:\Users\Carel\Desktop\Point.txt"
            Point_File = open(PointFile,'w')
              
            for i, line in enumerate(obj_points) :
                   
              point_Ind = i
              point_Ln = line 
                              
              Point_File.write("mypoly.SetPoint(" + str(point_Ind) +

        ",c4d." + str(point_Ln) + ")" + '\n')
                        
            Point_File.close()
            
            PolyFile = "D:\Users\Carel\Desktop\Poly.txt"
            Poly_File = open(PolyFile,'w')
          
            for i, line in enumerate(obj_poly) :
                   
              poly_Ind = i
              poly_Ln = str(line)
              Str_Line = poly_Ln.translate(None,"abcd:")
                                          
              Poly_File.write("mypoly.SetPolygon(" + str(poly_Ind) +

        ",c4d.CPolygon" + str(Str_Line) + ")" + '\n')
             
            Poly_File.close()
            
        def Selected_Points() :
                
                Pts_List = []
                Max_Pts = obj.GetPointCount()
                Sel_Pts = obj.GetPointS()
                
                PointFile = "D:\Users\Carel\Desktop\Sel_Points.txt"
                Point_File = open(PointFile,'w')
                
                for index, selected in enumerate(Sel_Pts.GetAll

        (Max_Pts)) :
                    
                    if not selected: continue
                     
                    else:
                        
                        Pts_List.append(index)
                         
                print Pts_List
                
                Point_File.write(str(Pts_List) + '\n')
            
        def main() :
            
            if Input1 == True:
                
               return All_Points()
                  
            if Input2 == True:
                
               return Selected_Points()

        😊😊

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