A function is defined to get a tuple. def searchObjectByRange(partObject, objectType, xRange, yRange, zRange): """In the partObject, search objects (edge, face, etc.) within the given region""" TOLERANCE_GLOBAL = 1.0E-6 INFINITE_RANGE = (-1.0E309, 1.0E309) tolerance = TOLERANCE_GLOBAL #Convert into list type xyzRange = [xRange, yRange, zRange] for i in range(len(xyzRange)): xyzRange[i] = list(xyzRange[i]) if len(xyzRange[i]) == 0: xyzRange[i] = INFINITE_RANGE else: if xyzRange[i][0] == None: xyzRange[i][0] = INFINITE_RANGE[0] if xyzRange[i][1] == None: xyzRange[i][1] = INFINITE_RANGE[1] if xyzRange[i][0] == xyzRange[i][1]: xyzRange[i][0] = xyzRange[i][0] - tolerance xyzRange[i][1] = xyzRange[i][1] + tolerance myObjects = [] #Find out the edges within the given region if objectType == 'EDGE': for edge in partObject.edges: ptsList = [] flag = 1 ptsList.append(edge.pointOn[0]) #Get the vertices on the edge for index in edge.getVertices(): ptsList.append(partObject.vertices[index].pointOn[0]) for ptCoords in ptsList: if (ptCoords[0] < xyzRange[0][0] or ptCoords[0] > xyzRange[0][1]): flag = 0 break if (ptCoords[1] < xyzRange[1][0] or ptCoords[1] > xyzRange[1][1]): flag = 0 break if (ptCoords[2] < xyzRange[2][0] or ptCoords[2] > xyzRange[2][1]): flag = 0 break if flag == 1: myObjects.append(edge) myObjects= tuple(myObjects) return myObjects
sub_1=searchObjectByRange(myModel.parts['Part-1'], 'EDGE', (), (), (0, 0)) #Getting EDGES has the same z-coordinate, and I 166 edges are obtained. myModel.parts['Part-1'].Set(edges=sub_1,name='sub_set') #I wish to get the set 'sub_set', but doen't work. The error shows "TypeError: edges; too many arguments; expected 0, got 166". Is there somebody can help me with that? Thanks. Baisong
-- http://mail.python.org/mailman/listinfo/python-list