Issue with the addSelectionFilter Method of SelectionCommandInput in C++

Issue with the addSelectionFilter Method of SelectionCommandInput in C++

jan_vokurka
Participant Participant
561 Views
4 Replies
Message 1 of 5

Issue with the addSelectionFilter Method of SelectionCommandInput in C++

jan_vokurka
Participant
Participant

Hello, 

while trying out Selection Events API Sample, I came across a problem with the addSelectionInput method of SelectionCommandInput. In the python version of the sample in MyCommandCreatedHandler class:

 

 

selectInput = inputs.addSelectionInput('SelectionEventsSample', 'Edges', 'Please select edges')
selectInput.addSelectionFilter(adsk.core.SelectionCommandInput.Edges)
selectInput.setSelectionLimits(1)

 

Selection Filters, in this case adsk.core.SelectionCommandInput.Edges are used as argument of the addSelectionFilter().

This works fine, however while working with the c++ sample, I found out that the equivalent approach:

 

bool result = selectInput->addSelectionFilter(adsk::core::SelectionCommandInput::Edges);

 

jan_vokurka4DDUA_0-1699954746087.png

returns false, hence no filter was set. Fortunately I can just use string instead and so avoid having to deal with this issue but I was curious if this is a bug or I'm missing something. 

Thanks


0 Likes
562 Views
4 Replies
Replies (4)
Message 2 of 5

pezidek
Participant
Participant

Hi,

mistake is in the used argument.

bool result = selectInput->addSelectionFilter(adsk::core::SelectionCommandInput::Edges);

The argument must be a string. In your case "Edges"

bool result = selectInput->addSelectionFilter("Edges");

 

Petr

Message 3 of 5

jan_vokurka
Participant
Participant

I realized I need to use string as an argument. I rather wanted to ask, if an equivalent approach that is showcased in the official c++ sample shouldn't work as well..and if not report a bug there 🙂

 

 

0 Likes
Message 4 of 5

pezidek
Participant
Participant

You are right that there is an error in the example, respectively the filter setting is not functional. The fact that it doesn't report any error is because the return value of the ->addSelectionFilter() method is bool. Thus, the filter setting does not take place but the script continues to run.

0 Likes
Message 5 of 5

jan_vokurka
Participant
Participant
Yes, I only traced the mistake after comparing the two samples.
0 Likes