On 20/10/2015 at 07:03, xxxxxxxx wrote:
I have a spline with a Point Selection tag for one point on the spline.
How do i read out the index of that point from the selection tag in python?
BaseSelect class doesn't seem to have any methods for this.
Any help appreciated.
On 20/10/2015 at 07:29, xxxxxxxx wrote:
Hey Bonsak, you can iterate over every point index and stop at the first
selected index. That's the index you search. Cheers!
On 20/10/2015 at 07:40, xxxxxxxx wrote:
Do you mean Iterate over the selection tag and test for selected?
On 20/10/2015 at 07:53, xxxxxxxx wrote:
for index in xrange(op.GetPointCount()) :
if sel.IsSelected(index) :
print "Nothing selected."
On 20/10/2015 at 09:44, xxxxxxxx wrote:
On 20/10/2015 at 10:52, xxxxxxxx wrote:
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() 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.
#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
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()
#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())
#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
On 20/10/2015 at 11:01, xxxxxxxx wrote:
Didn't know you copy tag data to BaseSelect like that.