Hot Ket to Cycle through Snap Positions

Started by TheGUmmer

TheGUmmer Lv 1

In the selection interface would it possible to have a hot key to cycle through a segments sidechain snap positions. Sometimes I have a hard time trying to move the longer sidechains into the position I would like.

TheGUmmer Lv 1

Never mind. It has benn point out to me that it is already there. Ctrl key and the left and right movement (arrow) keys.

Crashguard303 Lv 1

@photoelectric:
If you want to do it by script, use the

do_sidechain_snap(segment index, snap index)

function. with

get_sidechain_snap_count(segment index)

you get the number of snaps (rotamers) for the selected segment index.

Crashguard303 Lv 1

For example,

l=get_sidechain_snap_count(1)
if l>0 then
for k=1,l do
do_sidechain_snap(1,k)
end – k
end – l

will cycle through all possible rotamers of the very first segment.

Tlaloc Lv 1

A couple of notes, though:

1) The hot keys to cycle only works in the new interface

2) There is no need for the 'if' in the code above. You can just write it like this:

local segment = 1
for i=1, get_sidechain_snap_count(segment)
    do_sidechain_snap(segment, i)
end

A 'for' loop will be skipped if the number returned from get_sidechain_snap_count() is zero. Lua only executes the get_sidechain_snap_count() once, too.

3) Be warned, though, if you do anything that manipulates the backbone inside the loop (wiggle all, for example), it can change the number of possible snap positions. If this reduces the number of snap positions, your code will break. For example, this code will periodically cause runtime errors, in a non-deterministic way:

local segment = 1
for i=1, get_sidechain_snap_count(segment)
    do_sidechain_snap(segment, i)
    do_global_wiggle_all(1)
end

Crashguard303 Lv 1

To prevent this error, I would do it this way:

local segment = 1
for i=1, get_sidechain_snap_count(segment)
if i<=get_sidechain_snap_count(segment) then
do_sidechain_snap(segment, i)
do_global_wiggle_all(1)
end
end