Hey folks,
could someone please tell me how to activate a maxscript pickbutton via a function?
Like, I dont want to start it by having the user click on the button (well, at least not at the time the line of code appears in my script), but rather by a line of code.
--------------------------------------------------------------------------
on pbtn_pick picked obj do
( if classof obj == line then ( pbtn_pick.text = obj.name ) --I do know about the automatic display settings
else
( if querybox "Please pick a closed spline! \nWant to change to ''shape selection mode''?" == true do
( SetSelectFilter 3 )
))
--------------------------------------------------------------------------
So after the "SetSelectionFilter 3" line I would like to automatically restart the picking mode.
Thanks in advance!
Replies
UIAccessor.PressButton <hwnd>
In your case:
UIAccessor.PressButton pbtn_pick.hwnd[1]
The [1] is needed since .hwnd returns the window pointer in an array.
thank you! i will do some more research after having slept, it's late already!
I tested it myself with 2014 and it work's like a charm.
Are you able to share your code?
It doesnt work specifically with the pickbutton, though.
I dont know what you would need the rest of the code for, as it is not relevant to the problem, I believe?
Just imagine a pickbutton, if you select geometry it pops up a window telling you to pick a spline and then it should reactivate the pickbutton. I am aware that I can code a filter for the pickbutton, but how it is set up now, depending on a dropdown list selection, you can either pick geometry or splines only.
I'm on 2015, so I do not see why it shouldnt work.
I guess it's one of those things where you have to use a dirty workaround, in this case a timer.
Don't set the timer interval too low or it won't work properly.
I call this dirty because timers can be dangerous if not handled right, always make sure to stop them,
remove the eventhandler and dispose them if they are used for "one time call" stuff.
Also make sure you declare the functions in the right order.
Here's a working example:
I used a checkbutton instead of a pickbutton, "outsource" the picking to a function. This way you can call the function from anywhere. I added another button to demonstrate. "mybutton" is optional parameter, so you can imitate the pressed button state. The filter function also checks for open/closed splines, so you don't have to check for that later. Have a look:
the week was hard, so I didnt get a chance to check back here.
I avoided the issue by using several pickbuttons, which are hid and unhid by the dropdown selection.
I am currently working through your comments to understand them, so thanks for sharing your knowledge!
edit: i like your style, monster! very clean and understandable code, perfect!