DreamWall-Animation / dwpicker

Animation picker.
MIT License
169 stars 36 forks source link

Can we have Selection and command working together #73

Closed bhagtani closed 9 months ago

bhagtani commented 10 months ago

Hi, Love the Picker thanks for helping the animation community with this great tool Can we get one feature where we can have selection and command working together. currently if we add a selection then the command stops working. Actual need for this request is when we select a control i want to hide all the other controls so the whole view port becomes clutter free. we have written a small script to do that but now we have to click twice once to select the control in the picker and then a command button with that script to hide all the controls other than once selected in the picker. So would be great if we can open both the functionally which is already there in the picker but is a either or at the moment. we should still be able to disable the command by making it false. but making both work together would be nice .

Thanks a lot Regards, Jeetendra Bhagtani FeatureRequest

luckylyk commented 10 months ago

Hi bhagtani, Thanks for the support. As far as I remember, and after looking briefly to the code, execution is supposed to happend right after selection.

        elif self.clicked_shape is detect_hovered_shape(self.shapes, cursor):
            if self.mode_manager.right_click_pressed:
                self.call_context_menu()
            elif self.clicked_shape.targets():
                self.clicked_shape.select(selection_mode)
            if interact:
                self.clicked_shape.execute(
                    left=self.mode_manager.left_click_pressed,
                    right=self.mode_manager.right_click_pressed)

However, as in your case, it is obviously not work, I assume it is Maya failing to evaluate the selection in the code execution. I suggest that you try to put your function in the maya evaluation queue: cmds.evalDeferred(your_post_selection_function, lowestPriority=True)

Have a nice day ! Lio

bhagtani commented 10 months ago

Thank for the quick response, But sorry for my limited Knowledge of scripting don't know how to do this, tried couple of ways as per my knowledge but it didn't work. The selection and display toggle script didn't work together. I still had to click the command button to execute the command separately Attaching what i tried. I also tried the same in the Script editor but same results

Regards, Jeetendra Bhagtani Demo

bhagtani commented 10 months ago

Is it possible for you to try a simple command -> print ("hello world") with any selection of an object or control at the same time in one button and see if it's working on your end.

Thank you thank you

luckylyk commented 10 months ago

like this it is working fine image

bhagtani commented 10 months ago

My bad I was on a older version

VERSION = 0, 6, 1 # Version, Feature, Hotfix RELEASE_DATE = 'September 16th 2022'

It's working in the latest version. but either i have to make def -> Class so it gets recognized as a global function Or i had to change it to mel with -> python(myfunction) Or Like you suggested to write the def fuction in the command button

Either ways it's working now

image image image image

Thank you thank you for all the help and resolving the issue

but this can be a great feature to add in the picker where we can have the controls selected visible and all the other controls switched off to unclutter the viewport with the option of filters to add to selection or only show the selected controls

Regards, Jeetendra Bhagtani

krisBorghs commented 9 months ago

I ran in to the same issue, got it solved as well:

For MEL users:

Updating to the latest version, in combination with using evalDeferred ("youcode") -lowestPriority;

seems to work like a charm!