Home Technical Talk

script idea: Loop selection controlled by mouse movement

polycounter lvl 15
Offline / Send Message
CodeFather polycounter lvl 15
Hey all, I have been thinking of a selection improvement lately:

What about a script that shrinks and grows the selection on a loop (or a ring) by moving the mouse up or down. So basically, when you move the mouse up, it starts to expand the loop selection in one direction, while if you move the mouse downwards, the loop expand the other way, something similar to the video below, but controlled by mouse movement:

http://www.vimeo.com/8030056

ShrinkGrowsLoop_MouseUp.jpg

ShrinkGrowsLoop_MouseDown.jpg

Replies

  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Ooooh yeah more tool ideas!!

    On top of this awesome concept, something that would complement it very nicely would be the ability to select a certain 'rhythm' of edges along a loop (like : 1edge on, 2 edges off, 2 edges on, 1 edge off) and have the 'increase along loop' tool respect that rhythm for the rest of the selection. It would help alot for tires, screw paths, futuristic tubes and whatnot... Same with faces and verts too. I think Modo has that but I am unsure.

    Exciting!!
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    So many ideas to develop... You don't want me to start modeling at all! :D
    This is quite easy to achieve, the pior step is a small incerment in difficulty, but I think I already got all functions coded and debugged for this.

    To make it more general it should be split into two, one for loops selection and the other one for rings, working on every kind of sub objects. For verts and faces it would require at least a two elements selection, while for edges one would be enough. This isn't a promise, but I think I'll give it a shot.
  • Yozora
    Offline / Send Message
    Yozora polycounter lvl 11
    hmm thats a pretty cool idea, but wont it be quicker/more accurate if you just needed to select 2 edges? Especially if the object is more complicated and you are trying to access a much bigger loop that is difficult to find a viewing angle that fits the entire region that you want to select.

    I assume if you did it this way, then once the script is activated you wouldnt be able to navigate the viewport until you've finished the selection.

    So instead you can make it work like in roadkill and I'm sure some other 3d software must do it, where you can select 1 edge and then select another edge and the script will find and select the shortest path in between the 2 selected edges.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Yozora, the action you're describing is already available in IC.Shape 2.0, and is called "Span", in "Select" rollout. I think to use the same method employed for latest IC.ExtendSurface, where you make your first starting selection, activate the command, then increase or decrease the loop/ring dragging, while after release you are free to rotate the model as you like, then by right clicking exit the command, or drag again to modify the selection further.
  • PixelGoat
    Offline / Send Message
    PixelGoat polycounter lvl 12
    pior wrote: »
    Ooooh yeah more tool ideas!!

    On top of this awesome concept, something that would complement it very nicely would be the ability to select a certain 'rhythm' of edges along a loop (like : 1edge on, 2 edges off, 2 edges on, 1 edge off) and have the 'increase along loop' tool respect that rhythm for the rest of the selection. It would help alot for tires, screw paths, futuristic tubes and whatnot... Same with faces and verts too. I think Modo has that but I am unsure.

    Exciting!!

    Indeed, Modo has it natively ;)

    *spreading the Modo Gospel*
  • CodeFather
    Offline / Send Message
    CodeFather polycounter lvl 15
    pior wrote: »
    Ooooh yeah more tool ideas!!

    On top of this awesome concept, something that would complement it very nicely would be the ability to select a certain 'rhythm' of edges along a loop (like : 1edge on, 2 edges off, 2 edges on, 1 edge off) and have the 'increase along loop' tool respect that rhythm for the rest of the selection. It would help alot for tires, screw paths, futuristic tubes and whatnot... Same with faces and verts too. I think Modo has that but I am unsure.

    Exciting!!


    Pior, that's a nice suggestion ! :) Modo has that built in, also there is such feature in the polyboost toolset.I was thinking also about something like 2 dimensional selection, again based on the mouse movement direction.What I mean is a two step selection, where first you move the mouse up or down to expand the loop in one direction, then you click to stop that and move the mouse left or right to expand the selected edges this time as ring selection, and again click once to stop. Something like this:

    2dgrow_step1.jpg
    2dgrow_step2.jpg
    2dgrow_step3.jpg

    Also the other way- define ring selection first than expand that selection as loops on the desired side you choose. And of course if you don't want to have 2d selection you can click two times, once you have your first selection defined...or something like this.
    What do you think guys ?
  • mLichy
    I think that's a pretty cool idea, you could toggle it on via button or shortcut, then move your mouse to grow/move the loop/edge selection.
  • CodeFather
    Offline / Send Message
    CodeFather polycounter lvl 15

    Some cool guy at cgtalk, wrote this:

    macroScript selectBymouse
    category:" CGtalk "
    (
    selectedEdges = polyop.getedgeselection $ 
    tool mouseLoops 
    (
    	local oldpos = mouse.screenpos
    	local refPoint = mouse.screenpos
    	local dist = 2
    	
    
    fn getDirection dist = 
    	(
    		
    		newPos = mouse.screenpos
    		
    		if newpos[2] < refPoint[2] and newpos[2] < oldpos[2] and (abs(newpos[2] - abs(oldpos[2])) >= dist ) do $.setLoopShift -1 false true 
    		if newpos[2] < refPoint[2] and newpos[2] > oldpos[2] and (abs(newpos[2] - abs(oldpos[2])) >= dist ) do $.setLoopShift 1 false false 
    		if newpos[2] > refPoint[2] and newpos[2] > oldpos[2] and (abs(newpos[2] - abs(oldpos[2])) >= dist ) do $.setLoopShift 1 false true
    		if newpos[2] > refPoint[2] and newpos[2] < oldpos[2] and (abs(newpos[2] - abs(oldpos[2])) >= dist ) do $.setLoopShift -1 false false
    		if newpos[2] > refPoint[2]  and  (abs(newpos[2] - abs(refPoint[2])) < dist ) do polyop.setedgeselection $ selectedEdges
    		if newpos[2] < refPoint[2]  and  (abs(abs(refPoint[2]) - newpos[2]) < dist ) do polyop.setedgeselection $ selectedEdges
    		oldpos = newpos
    		
    			--redrawviews()
    	)
    	
    	on freemove do (if Selection != undefined and classof selection[1] == Editable_Poly and subobjectlevel == 2 do getDirection dist)
    		
    	)
    starttool mouseLoops
    	
    )
    
    
    



    It doest the job, but has some sort of strange abnormal behavior, I don't know if this could be polished, though.
  • miauu
    Offline / Send Message
    miauu polycounter lvl 14
    And this is script that allow you to select entire edge loop with double click with LMB and edntire edge ring with holding dowun Shift and double click. :)

    I use this script for a long time and its verry useful.

    http://www.scriptspot.com/3ds-max/scripts/mouse-loop-ring
  • CodeFather
    Offline / Send Message
    CodeFather polycounter lvl 15
    miauu wrote: »
    And this is script that allow you to select entire edge loop with double click with LMB and edntire edge ring with holding dowun Shift and double click. :)

    I use this script for a long time and its verry useful.

    http://www.scriptspot.com/3ds-max/scripts/mouse-loop-ring

    Thank you for this script, I will try it; however after installing the Track Pack I can't find the Mouse Loop-Ring script(it is not under the Track catergory)? Any clues ?
  • Spatz
    Offline / Send Message
    Spatz polycounter lvl 13
    miauu wrote: »
    And this is script that allow you to select entire edge loop with double click with LMB and edntire edge ring with holding dowun Shift and double click. :)

    I use this script for a long time and its verry useful.

    http://www.scriptspot.com/3ds-max/scripts/mouse-loop-ring

    can you please give me the srcipt ... it is no more available on his site...
  • miauu
    Offline / Send Message
    miauu polycounter lvl 14
    The script is built in TrackScript. When you install TracjScript you have to install Startup Scripts. I forgot the exactly how to do this, because I do this a long time ago. So, first, windows has a 0,5 sec time to preform double click. This is a too long time for me, so I change it to 0,190 sec. First, try the script and if you like it, then if you want do this:
    P.S. If someone wants to change the mouse double clicking time in WIndows XP - see how to do this here: http://www.liutilities.com/products/registrybooster/tweaklibrary/tweaks/...
    You have to reбоот your PC.
    And here you can see how fast is your double mouse click:
    http://www.emanueleferonato.com/2006/06/04/javascript-chronometerstopwatch/
    Just execute double LMB click and see the result.

    Here the script:
    -- global toolBarButtonSave
    tool mouseRings --numPoints:1
    (
    on mousePoint clickno do
    (
    ((modPanel.getCurrentObject()).buttonOp #SelectEdgeRing)
    -- try( toolmode.commandmode = toolBarButtonSave)catch()
    #stop
    )
    on freemove do #stop
    )
    tool mouseLoops --numPoints:1
    (
    on mousePoint clickno do
    (
    ((modPanel.getCurrentObject()).buttonOp #SelectEdgeLoop)
    -- try( toolmode.commandmode = toolBarButtonSave)catch()
    #stop
    )
    on freemove do #stop
    )

    fn CallbackFn1 ev nd=(
    if selection.count == 1 and mouse.mode != 2 and (Filters.Is_This_EditPolyMod (modPanel.getCurrentObject()) or Filters.Is_EditPoly()) and(Filters.Is_EPolySpecifyLevel #{3}) do
    -- setToolBtnState
    -- if not getToolbtnState #select do toolBarButtonSave = toolmode.commandmode
    -- toolmode.commandmode = #select
    -- updateToolbarButtons()
    if keyboard.shiftPressed then starttool mouseRings
    else starttool mouseLoops

    try(destroyDialog doubleClick)catch()
    rollout doubleClick "doubleClick"
    (
    timer tm_click interval:500 active:true
    on tm_click tick do (
    if keyboard.shiftPressed then stopTool mouseRings
    else stopTool mouseLoops
    -- try( toolmode.commandmode = toolBarButtonSave)catch()
    destroyDialog doubleClick
    )
    )
    CreateDialog doubleClick 0 0 -10 0
    )

    NodeEventCallback mouseUp:true subobjectSelectionChanged:CallbackFn1 ---callbackBegin:callbackMouseBegin

    txt = "if selection.count == 1 and (Filters.Is_This_EditPolyMod (modPanel.getCurrentObject()) or Filters.Is_EditPoly()) then(n"
    txt += "callbacks.removeScripts id:#SelectionChangedn"
    txt += "fileIn ((GetDir #startupScripts) + "startupMouseLoopRing.ms")n"
    -- txt += "sleep 0.01"
    txt += ")"
    callbacks.addScript #selectionSetChanged txt id:#SelectionChanged
    Some times, script stop working and I have to reload it manualy, but MaxScript - Run SCript - navigate to Startup Folder is to slow for me I do this:
    With this script I create another Menu in my Menu Bar, and now with 2 click i reload MouseLoopRing:
    --- MouseLRmenu -- v.0.1 -- (c)2005 - andrei kletskov (111) - http://andklv.narod.ru

    -- description:
    -- this script scans a folder you define (see below) and creates a menu with found scripts
    -- place this script in your "....scriptsstartup" folder to update menu each time you run 3dsmax

    -- history:
    -- v0.1 (28 january 2005) - initial version

    (

    defining a folder to scan
    ---IMPORTANT!
    modify the wildcard path below to find your files
    -- |
    -- |
    -- v
    files = getFiles "CHANGE THIS -D:3DStudio MAX 2009 SP1ScriptsMouseLR*.ms"
    sort files

    deleting previous menu
    if ((menuMan.findMenu "MouseLR") != undefined) then
    (
    menuMan.unRegisterMenu (menuMan.findMenu "MouseLR")
    menuMan.updateMenuBar()
    )

    creating menu
    mainMenuBar = menuMan.getMainMenuBar()
    subMenu = menuMan.createMenu "MouseLR"

    creating run-maroscripts and populating menu
    ii = 0
    for i in files do
    (
    ii = ii + 1
    str = "macroscript MouseLRmenu" + (ii as string) + " category:"MouseLRmenu" buttontext:"" + (getFilenameFile i) + "" (execute (openFile "" + i + ""))"
    execute str

    testItem = menuMan.createActionItem ("MouseLRmenu" + (ii as string)) "MouseLRmenu"
    subMenu.addItem testItem -1
    )

    updating menu
    subMenuItem = menuMan.createSubMenuItem "Test Menu" subMenu
    subMenuIndex = mainMenuBar.numItems() - 1
    mainMenuBar.addItem subMenuItem subMenuIndex
    menuMan.updateMenuBar()

    )
    cHANGE THIS - Create a new folder, rename it to MouseLR (or something else) and put inside a copy of MouseLoopRingScript. With start of 3dsMax Mouseloopring will be loadet from Script/Startup and if it stop work you can load with this menu:
    mouselr.png

    I hope this will help you. I'm going on vacation for a couple of days, so if you have more questions I can answer them after few days.

    Don't forge to go in Scriptspot and vote for script. The author deserve it.
  • Spatz
    Offline / Send Message
    Spatz polycounter lvl 13
    thanks man...have a nice holiday...
Sign In or Register to comment.