BaseSelect updated, plus questions!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/07/2012 at 10:55, xxxxxxxx wrote:
So I was toying around with BaseSelect and except for this thread:https://developers.maxon.net/forum/topic/5803/5859_creating-selection-tags I couldn't find much information about it, so I did some tests and I figured I'd post what I learned up here so it could help somebody.
Here's the script:
import c4d from c4d import gui #Welcome to the world of Python def main() : obj = doc.GetActiveObject() #Get active object doc.SetMode(c4d.Mpoints) if obj == None: return c4d.CallCommand(12236)#Make the object editable obj = doc.GetActiveObject() #Get active object SelectedPoints = obj.GetPointS() #Creates an instance of the objects selection TotalPoints = obj.GetPointCount()#You need this to loop through and check all the points OriginalSelection = [] SecondSelection =[] ThirdSelection = [] print "Number of Points selected:",SelectedPoints.GetCount()#The number of points selected print "Point states at the beginning:" for id,state in enumerate(SelectedPoints.GetAll(TotalPoints)) :#prints out the id and the state of that point print "ID ",id,"State", state#The id of the point and whether it's selected or not if SelectedPoints.IsSelected(id) == True: OriginalSelection.append(id)#Creates a list of all the currently selected points Saving the current stat print "List of the selected points:",OriginalSelection #The points that are slection for id in range(TotalPoints) : if SelectedPoints.IsSelected(id) == False: SelectedPoints.Select(id)#Select point 0 in addition to the runs already selected SecondSelection.append(id) break print "Point states at the middle:" for id,state in enumerate(SelectedPoints.GetAll(TotalPoints)) :#prints out the id and the state of that point print "ID ",id,"State", state#The id of the point and whether it's selected or not print "List of the selected points:",SecondSelection #The points that are slection for id in OriginalSelection: SelectedPoints.Deselect(id)#Deselects the orginal selection #So the new point is what's selected SelectedPoints.ToggleAll(TotalPoints,0) #Swaps all the points to the opposite state, #The SDK is incorrect, the max goes first and then the min,ToggleAll(max,min) #SelectAll() has the same mistake, it should be SelectAll(max, min) print "Point states at the end:" for id,state in enumerate(SelectedPoints.GetAll(TotalPoints)) :#prints out the id and the state of that point print "ID ",id,"State", state#The id of the point and whether it's selected or not if SelectedPoints.IsSelected(id) == True: ThirdSelection.append(id) print "List of the selected points:",ThirdSelection c4d.EventAdd() if __name__=='__main__': main()
It's just run on an object and prints out some information on which points are selected. It doesn't actually do anything but select different points though. ToggleAll() and SelectAll() had me stumped for a bit because the SDK has incorrect information about them.
Anything I missed would be appreciated.
Daniel
Edit: So I've been trying to use BaseSelect to keep track of edges. Are edges stored as two separate 'id's in the BaseSelect? It doesn't seem to correspond with the points that form the line. Even if they don't correspond to the points is there a reason for which 'id's are used? GetCount() for BaseSelect also seems to double the number of edges that are actually selected, because it says two 'id's have the same edge.
import c4d from c4d import gui #Welcome to the world of Python def main() : obj = doc.GetActiveObject() edges = obj.GetEdgeS() edgecount = edges.GetCount() print "Number of edges selected", edgecount print edges.GetAll(50) if __name__=='__main__': main()
I need a way to select specific edges that works in both R13, and in R12.
Daniel -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/08/2012 at 09:23, xxxxxxxx wrote:
I think you should take a look at this interesting topic about BaseSelect and the edges of a mesh: https://developers.maxon.net/forum/topic/6226/6566_getedgecount--bug
I'll fix the documentation. Thanks for reporting these errors.