Notifications
Clear all

[Closed] 2 scripts in a single button?

Hi All,

I have a series of custom buttons to import/export data bewteen apps. in order to get this workflow woring in Max the ideal way I need to be able to allocate 2 scripts in a single button. My ideal senario is left click the button and one script fires up, rightclick and another scrits fires up instead.

Is there a way to get this right-click, or control+click, etc so I can add a second script to a button?

example:

I have a button that has this script:
importFile “C:\automated_files\Rhino\import-export\3dm.3dm”

I want to have a way to fire up an ‘ExportFile’ script using the same button with some kind of modifier or right-clicking.

Thanks,

4 Replies

Here’s a simple example on how to access the modifier keys within a macroscript:

macroScript FireUp
ButtonText:"FireUp"
category:"Blah blah Tools"
(

on execute do
(
  -- get shift/control state
  local shiftctrl = 0
  if keyboard.shiftpressed then shiftctrl += 1
  if keyboard.controlpressed then shiftctrl += 2

  case shiftctrl of
  (
    0: format "None pressed"
    1: format "SHIFT pressed"
    2: format "CONTROL pressed"
    3: format "SHIFT + CONTROL pressed"
  )
)

)

Hope this helps!

  • Martijn

thanks Mantijn,

what you posted does help, just to give me hope that it’s doable. However I know nothinig about Maxscript so I have no I idea what to do with what you sent me.

Here’s what I have:

button1 has a script that says:

macroScript Macro2
category:“DragAndDrop”
toolTip:””
(
importFile “C:\automated_files\Rhino\import-export\OBJ.obj” #noPrompt
true

)

Button 2 has a script that says:

macroScript Macro9
category:“DragAndDrop”
toolTip:””
(
exportFile “C:\automated_files\Rhino\import-export\obj.obj” #noPrompt selectedOnly:true
true
)

how do I combine those chunks of text with your script so I can past in all in one button, so if I click it acts like my button 1 script, and if I Control + Click it acts like my button2 script?

Sorry for making such a lame question,

Gustavo

Hi, using the <CTRL> key willnot work, BUT the <SHIFT> key will
so you script could look likethis

 
macroScript Macro2 
category:"DragAndDrop"
toolTip:""
(
if keyboard.shiftpressed then (exportFile "C:\\automated_files\\Rhino\\import-export\\OBJ.obj" #noPrompt selectedOnly:true)
else (importFile "C:\\automated_files\\Rhino\\import-export\\OBJ.obj" #noPrompt )
)

So when you press your button normally, it imports, and if you press<SHIFT> and click your button, it export.

Hi Zbuffer,

Wow!! I completely missed your reply until now. Thanks so much for your help, this does exactly what I was looking for