Set Edge Selection Tag

On 23/04/2018 at 10:18, xxxxxxxx wrote:

I have an Object plugin (a generator) in which I want to make and set a Selection Tag with the current edge selection of the active object.

Edges are set, but not the correct ones. What is wrong?

Here the code.

import c4d
from c4d import gui, utils
def main() :
    selected = op.GetEdgeS() # Returns a BaseSelect that'll tell us which edges are currently selected
    nbr = utils.Neighbor()          
    nrEdges = nbr.GetEdgeCount()
    tag = op.MakeTag(c4d.Tedgeselection)	#create edge selection tag
    tag_baseSelect = tag.GetBaseSelect()
    for i in range(nrEdges) : # For every edge index of the object...    
        if selected.IsSelected(i) : # if it's selected...
            tag_baseSelect.Select(i) # reflect that in the selection tag.
if __name__=='__main__':

On 24/04/2018 at 02:24, xxxxxxxx wrote:

I guess I do not fully understand how edges are stored.
I also I guess it has something to do with unique edges.
When I select one edge of a cube and I run below script, it tells me 2 edges are selected.

It looks like the edges are defined a-b and b-a.

So, how to get and set unique edges?

    selected = op.GetEdgeS() # Returns a BaseSelect that'll tell us which edges are currently selected
    print "Selected: ", selected.GetCount()

On 24/04/2018 at 02:29, xxxxxxxx wrote:

Hi Pim,

Do you want to create an edge selection tag from a generator based on an active object? This would be a strange workflow.

About the posted script, a BaseSelect content can be copied to another with the function CopyTo(). So there's no need to use Neighbor, a loop etc.
(The error in your code is all edges are selected before the loop.)

On 24/04/2018 at 02:30, xxxxxxxx wrote:

Ok, getting unique edges is working when using Neigbor()

    nbr = c4d.utils.Neighbor()          
    edgeSelection = op.GetSelectedEdges(nbr, c4d.EDGESELECTIONTYPE_SELECTION)
    print edgeSelection.GetCount()

Still have to figure out how to set the selection in the selection tag.

On 24/04/2018 at 02:40, xxxxxxxx wrote:

Ah, so simple.
Thank you.