Notifications
Clear all

[Closed] random selected keys

To randomise keys value I use this command :
for i in $.pos.controller.X_Position.controller.keys do i.value = i.value + (random -1 1)

But how can I randomise only selected keys ?

Thank you

Arno
arno3d.blogspot.com

3 Replies
1 Reply
(@magicm)
Joined: 11 months ago

Posts: 0

Key values have a .selected property (boolean), so you can use the following to iterate through selected keys only:

for i in $.pos.controller.X_Position.controller.keys where i.selected do i.value = i.value + (random -1 1)

Martijn

I wrote this little macroscript :

macroScript Random_Pos
category:”- arno -“
toolTip:“random keys Position value for Kaj”
buttonText:“RdPos”

(
try (destroyDialog RandomPosRollout) catch()

rollout RandomPosRollout “Random_Position” width:128 height:200

(
checkbox chk1 “X_position” pos:[32,25] width:84 height:25
checkbox chk2 “Y_position” pos:[32,49] width:84 height:25
checkbox chk3 “Z_position” pos:[32,72] width:84 height:25
label lbl1 “Select Axis” pos:[12,8] width:104 height:14
spinner Param1 “Rand1:” pos:[20,110]Width:80 Height:16 Align:#Center Offset:[-20,0] Type:#float Range:[-100,0,0]
spinner Param2 “Rand2:” pos:[20,130] Width:80 Height:16 Align:#Center Offset:[-20,0] Type:#float Range:[0,100,0]
button Execute “Random !” pos:[32,160]

  on Execute pressed do
  (
      if chk1.checked ==true do
      ( 
          for i in $.pos.controller.X_Position.controller.keys do i.value =  i.value + (random Param2.value Param1.value)
      ) 
      
      if chk2.checked == true do
      ( 
          for j in $.pos.controller.Y_Position.controller.keys do j.value = j.value + (random Param2.value Param1.value)
      ) 
      
      if chk3.checked == true do
      ( 
          for k in $.pos.controller.Z_Position.controller.keys do k.value = k.value + (random Param2.value Param1.value)
      )

  )

)

createDialog RandomPosRollout style:#(#style_border,#style_resizing,#style_toolwindow,#style_sysmenu)
)

Arno
arno3d.blogspot.com

dank je wel

Arno
arno3d.blogspot.com