You cannot access moho in a function that doesn't have moho as an argument. Passing moho as an argument requires the calling function to have access to moho as well.
synthsin75 wrote: ↑Thu Sep 09, 2021 7:13 pm
You cannot access moho in a function that doesn't have moho as an argument. Passing moho as an argument requires the calling function to have access to moho as well.
Please correct my code wes. I do some things but error exist still.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
There's no easy way to do what you're asking. A SimpleDialog can't pass moho to its UpdateWidgets, HandleMessage, etc. functions. You can pass moho by defining d.moho = moho, but you can't then use that to do self.moho.layer without Moho crashing. This seems to be because that self.moho is an instance, not a reference to the actual ScriptInterface. This means that you need to define every individual object you may need to access. In your case, d.layer = moho.layer will allow you to print(self.layer:Name()) in your HandleMessage. The problem with this is that self.layer is only initialized when the DoLayout is invoked, and cannot be updated until it is reinvoked. So if you change layers, that self.layer will not be the currently layer. It's the layer that was selected the last time the tool's options were invoked. This only happens naturally when you switch between different layer types.
So you have to jump through a lot of hoops to get Moho to do this. Far too much for me to explain here, but you can look at how I handle this in my Switch Icons tools for ideas.
Thanks wes.i will try .
I succeed to combine bone select tool and bone transform tool. Also i added tween machine to keytools script.
Now i want compress some options into popup menu to add more options. In this case i want add tween machine to bone transform. But i need more room in tool bar.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
synthsin75 wrote: ↑Thu Sep 09, 2021 9:54 pm
There's no easy way to do what you're asking. A SimpleDialog can't pass moho to its UpdateWidgets, HandleMessage, etc. functions. You can pass moho by defining d.moho = moho, but you can't then use that to do self.moho.layer without Moho crashing. This seems to be because that self.moho is an instance, not a reference to the actual ScriptInterface. This means that you need to define every individual object you may need to access. In your case, d.layer = moho.layer will allow you to print(self.layer:Name()) in your HandleMessage. The problem with this is that self.layer is only initialized when the DoLayout is invoked, and cannot be updated until it is reinvoked. So if you change layers, that self.layer will not be the currently layer. It's the layer that was selected the last time the tool's options were invoked. This only happens naturally when you switch between different layer types.
So you have to jump through a lot of hoops to get Moho to do this. Far too much for me to explain here, but you can look at how I handle this in my Switch Icons tools for ideas.
Is this possible that i connect shy checkbox to a variable in other function?
Chage shy 》 change var ■■ change var》 change layer.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
davoodice2 wrote: ↑Thu Sep 09, 2021 10:06 pm
Thanks wes.i will try .
I succeed to combine bone select tool and bone transform tool. Also i added tween machine to keytools script.
Now i want compress some options into popup menu to add more options. In this case i want add tween machine to bone transform. But i need more room in tool bar.
By the time you have finished embedding one tool inside another, I don't think you are actually making the usage/process any more efficient.
I understand combining multiple tools to optimize their use, but you could end up with a less streamlined workflow, an inability to keyboard shortcut / macro tools and non-modular monolithic spaghetti code - if you over do it.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Thanks. But that way get same error too.
In my work flow of animating switching tools is boring.
I came from maya to moho. I like make moho work flow much faster .
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
davoodice2 wrote: ↑Thu Sep 09, 2021 10:06 pm
Also i added tween machine to keytools script.
Have you posted that one yet? I might have missed it.
davoodice2 wrote: ↑Thu Sep 09, 2021 10:10 pm
Is this possible that i connect shy checkbox to a variable in other function?
Chage shy 》 change var ■■ change var》 change layer.
I don't quite follow, but I think so. You can have the shy checkbox msg be global to the script, like daaaaaaaa.SHY = MOHO.MSG_BASE + 3 instead of popupDialog1Dialog.SHY = MOHO.MSG_BASE + 3. Then the tool options HandleMessage, that does have access to moho, will read it when it's invoked. Then it's just a matter of if the tool option HandleMessage is invoked when you need it to be (which in this case might be when the popupMenu is closed, I don't remember exactly). If you try to call the tool option HandleMessage from the popup dialog HandleMessage, it won't get moho.
Last edited by synthsin75 on Fri Sep 10, 2021 5:48 pm, edited 1 time in total.