On 20/10/2015 at 10:52, xxxxxxxx wrote:
FYI.
If you ever need to get the selection tag data values without actually selecting the object.
The BaseSelect class can tell you which object indexes are saved in selection tag.
The BS class is just an array states. And the selection tags only hold the enabled([1]) points/polygons.
So if you copy the tag's data into a BS. You can tell which object point/polygon indexes are saved in the tag using the index of the BS array.
Example:
#This example shows how to get the points stored in a point selection tag instead of from the object
#The selection tag cannot be accessed directly. We need to store it's data in a BaseSelect class instance
#Then use the BS instance to grab, select, and de-select the points or polygons that were stored in the selection tag
import c4d
def main() :
obj = doc.GetActiveObject()
tags = obj.GetTags()
for tag in obj.GetTags() :
if tag.GetType() == c4d.Tpointselection:
#This gets the number of saved points in the tag(not the object)
count = tag.GetBaseSelect().GetCount()
print count
#Since the data in the tag is not directly accessable
#we convert the tag's data (points in this case) to a BaseSelect so we can do something with them
PointS = tag.GetBaseSelect()
#Now that we have copied the tag's data to a BS
#We can see all of the selection state values for each point in the object
#The points that were saved in the tag will have an enabled state value in our BS instance
pntArray = PointS.GetAll(obj.GetPointCount())
print pntArray
#NOTES:
#At this point every point of the object is represented in this "pntArray" array
#The array's indexes match the object's indexes
#And each of the array's elements contain the selection state(enabled/disabled) for the points
#Note: We have never used the object itself to get the selected points
#Use this if you want to select the points on the object in the editor view
PointS.CopyTo(obj.GetPointS())
obj.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
if __name__=='__main__':
main()
-ScottA