Maya bakepivot on keyrelease - maya

In Maya 2018 I'm trying to do a script that replaces the hotkey D for orienting the pivot with one that does the same thing and but also automatically bakes the pivot on release.
So I'm leaving the onpress command of the hotkey as normal but on release I do,
ctxEditMode -buttonUp;
BakeCustomPivot;
except I get an Error:
Invalid object or value: BakeCustomPivot //
I also tried doing this instead:
EnterEditModeRelease
BakeCustomPivot;
in the script editor I see that BakeCustomPivot; is fired before ctxEditMode -buttonUp; and the pivot isn't baked.
Any way to do this?

Related

AppleScript not looping all numbers when using repeat

I am using this script to close all "Alerts" in my notification bar:
tell application "System Events"
tell process "NotificationCenter"
set numwins to (count windows)
repeat with i from numwins to 1 by -1
click button "Close" of window i
end repeat
end tell
end tell
However this doesn't close them all, even when there are no "Alert without Close button".
try catch didn't help. What's wrong?
I tested your script and it seemed to run correctly on my machine, but there is always a potential for problems when you use a repeat loop on a mutating list: in other words, a list that changes as the repeat loop progresses. Each time you close a window Notification Center changes its window list and updates the properties of the remaining windows; the script can simply lose track. I'm a little surprised it doesn't throw errors when this happens, but...
You can try this code and see if it works. rather than referring to windows by index it repeatedly tries to close the last window, ignoring any errors, and keeps on until the window count is zero or it loops 100 times (that last is to prevent an endless loop in case something goes wrong).
tell application "System Events"
tell process "NotificationCenter"
repeat 100 times
try
tell last window
click button "Close"
end tell
end try
if (count of its windows) = 0 then
exit repeat
end if
end repeat
end tell
end tell
EDIT
Per comments, the above doesn't work quite as advertised, so let's switch it over to AppleScriptObjC:
use framework "Foundation"
property NSUserNotificationCenter : class "NSUserNotificationCenter"
NSUserNotificationCenter's defaultUserNotificationCenter's removeAllDeliveredNotifications()
This seems to do the trick on my machine. Of course, NSUserNotificationCenter is deprecated as of 10.14, so this won't work forever — eventually you'll have to shift over to the notification's framework — but it should work for a few more OS versions.
EDIT 2
Per another comment, anyone working on os 10.14 or later (Mojave and Catalina, to date) can do an equivalent AppleScriptObjC routine using the UserNotifications framework, like so:
use framework "UserNotifications"
set notificationCenter to class "UNUserNotificationCenter"'s currentNotificationCenter
notificationCenter's removeAllDeliveredNotifications()
Note that I've used a slightly different syntax (merely calling class "UNUserNotificationCenter" rather than setting up a property). Both work; the property syntax is only preferable when you need to pass the class to handlers.

Drop Down Parameter Not Returning a Value For a Query

I have a database set up which includes a query and a form, which are causing me problems. In the form, I have a drop down menu which allows you to select from a list of ID values (e.g. 1, 2, 3, ...). Once you have selected a value, you then click a button and it runs the query with a parameter of the ID number from the drop down ([Forms]![KitInfoRetrievalForm]![DropDown]).
The problem here though, is that when I select something from the drop down menu and click the button to run the query, it gives a pop up box asking for a value to substitute in for [Forms]![KitInfoRetrievalForm]![DropDown]. This leads me to believe that either the drop down menu is a null value for some reason or my pathing to it is incorrect.
This was working at one point and then stopped after a series of weird error messages from something else entirely (in the same Access project). Any help you can give me would be much appreciated.
I would recommend to replace reference to dropdown in query by function. It should eliminate this problem and also this is a workaround for old bug in Access, which exists in all recent versions: if the form/subform is in datasheet mode and you applied filter (quick filter thru user interface or using VBA), it stops reading variables with references to controls or just parameters and uses last used value.
I'm using this function for reading form/subform control value:
Public Function GetControlValue(strFormName As String, strControlName As String, Optional strSubFormControlName As Variant) As Variant
On Error Resume Next
If IsMissing(strSubFormControlName) Then
GetControlValue = Forms(strFormName).Controls(strControlName).Value
Else
GetControlValue = Forms(strFormName).Controls(strSubFormControlName).Form.Controls(strControlName).Value
End If
End Function
In your case replace [Forms]![KitInfoRetrievalForm]![DropDown] by
GetControlValue("KitInfoRetrievalForm","DropDown")

How to Loop a script in gamemaker

cantSee = collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true)
canSee = !(collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true))
Define the loop as the following:
if cantSee {
cantSeeTimer = cantSeeTimer +1
}
if cantSeeTimer >60 {
speed=0
stopped=true
} else {
mp_potential_step(obj_player.x,obj_player.y,5,false)
}
}
if stopped=true && canSee {
mp_potential_step(obj_player.x,obj_player.y,5,false)
loop()
}
I know the language is bad, but I just want to create a loop command to summon at will.
Thanks, Finn.
so you haven't specified which object in your game currently has this code but it shouldn't matter too much.
So in Game Maker or Game Maker Studio there are a series of events an object can have and one of them is called a "Step" event. A step event is basically a loop that will cycle the amount of times the room speed is per second. Eg: If the room speed of a room is 30 the step event will loop 30 times per second.
I think I can see what you are trying to do and I think I have a solution for you.
Since you can write GML code I am going to assume you understand how to use the GMS or GM IDE.
We want to create a new object called obj_control (or you can choose a custom name). Also don't give this object a sprite as we don't want the player to see it.
Now we want to add an event to our new object so make sure you still have the windows for obj_control (or whatever u called it open). and click on the 'Add Event button' shown in this image: http://imgur.com/A7szwFO
Once you click on it, click on 'Step'. http://imgur.com/s0ksiyD
Now select 'Step' again. ('Begin Step' and 'End Step' don't do what we want so let's just ignore them)
Now we need to add your code to the step event we just created. So make sure you are on the 'Control' tab and find the script editor (you should know where to find it) and drag one into the 'Actions' for the step event.
http://imgur.com/de3gE01
Now a script editor should pop up automatically but if it doesn't just double click the "Execute piece of code". Now we just need to copy and paste all of your code into the script editor.
http://imgur.com/sNBOCFu
Now click on the green tick on the top left corner of the window to save the code.
Now before we are done let's make sure we define the variables in a create event. So make a create event and add this code:
cantSee = collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true)
canSee = !(collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true))
After you have added that create event and inserted that code into it save all changes to the object.
All that is left is to add this object we created to every room of the game so it can function.
Hopefully this helped and if it didn't just let me know and we can get it sorted.

In there a convenient way to have multiline input in libedit/editline

Using libedit/editline, and trying to figure out a good way to do multiline input/editing. The target is an SQL client, where queries will often span multiple lines and terminate with ;.
I can call el_gets, and process each line of input, stopping when I see the terminating ;. I can even concatenate those and store them as a single entry in el_history - and it will correctly access them when using the arrows to scroll through history.
However, when entering the command and after starting a new line, I can no longer use the arrows to move up and edit the previous line. E.g.:
prompt> SELECT * FROM table
WHERE 🀫
At that point, I'd like to be able to use the up-arrow, to move up and edit the text already entered on the first line. Is this possible? How would one do so? I assume that using el_gets isn't correct in this case, since it would remove the line from the editline buffering, yet I don't see an alternative API that would work.
Thoughts?

Vim - Show data type

I typically code most of my C projects in Vim. I am comfortable with navigation, search and replace, and indexing via Ctags/Cscope.
One feature I would like to have, if possible, is a keymapping that will show the datatype for a variable under the cursor on screen.
For example, if my cursor is on a variable, "test123" (ie: int test123 = 0) is there a way to have the type (int) and some other details about the variable shown in another tab within Vim?
Also, is there something similar that would do the same for a struct variable, and show a list of all its members in the descriptive tab as well as the type (ie: struct)?
I've also noticed that sometimes while coding, I have a tab titled "[Scratch][Preview]" at the top of Vim that appears to fulfill this requirement, but I have no idea what triggers it (searches and Ctag searches don't seem to trigger it). It looks like so:
name: myStruct::instanceOfStrct| 2 cmd: /^ int instanceOfStrct;$/
.. (up a dir) | 3 kind: m
</code/test/test.c | 4 struct: myStruct
|+config/ | 5 access: public
|+lib/ | 6 filename: /code/test/test.c
I think this is something that already exists in Vim to some extent, but I have not idea how to work with it.
Thank you.
I do not know of any plugin that does what you want, however it should be quite possible using libclang. There is a fork of clang_complete that adds 'go to definition' functionality which is close to what you want. However development on that plugin seems to have stagnated.
Also the scratch buffer appears when doing autocompletion to give more information about a specific completion. It can be enabled and disabled using the completeopt setting.

Resources