Download Version 1.0: jj_loop.pl

JJ_Loop is an extension to modo's already excellent loop handling capabilities. It tries to fill in the gaps where modo's tool doesn't quite behave as expected and adds a few extras of its own. It can be bound to hot keys or used from a form.

Here are some of the key features:

  • Works with both polygon and edge loops. (May add point support in future but edges do the same job.)
  • Lets you select previous/next loops (similar to modo's left/right arrow keys) but at a step size you choose i.e. every second loop, every third loop etc.
  • Lets you manually specify step and count values so that you can grab, say, 6 loops spaced 5 apart.
  • Lets you shift select loops to add loops to an existing selection (like modo's tool) but, again, at any step size you choose.
  • With shift selections (i.e. where you add to the loop selection) it adds an option to go in both previous/next directions at the same time so that you can 'grow' a loop selection outwards (again at a step size you choose). If you use modo's native grow on a set of edge loops you'll get all the traversing edges as well.
  • Lets you select every nth loop on a piece of geometry in both directions i.e. if you have a grid of 400 edge loops it will grab every nth one and let you delete it (great for geometry reduction) or for grabbing every nth loop along a long piece of geometry so that you can corrugate it etc.
  • Lets you translate loop selections along. Hard to explain but if you have, say, five loops selected you can move them all along collectively in previous/next directions.
  • Unlike modo's tool, it will work on multiple loop components per layer i.e. if you have two edge loops selected on a single layer, modo's tool will drop one of them and then proceed to move or add to only one of them. This tool will treat them all as independent items (within a layer and across layers). The only exception to this rule is the Quick Add tool which sacrifices compatiblity (and error checking) with components on the same layer in order to provide speed. The Slow Add tool does the job properly but is......slower.


    Julian Johnson
    julian@exch.demon.co.uk

modo's Native Tool
Here, I've selected five loop components on the same layer. Using modo's native next loop all the loops get dropped, except one..


Shift
With JJ_Loop, all the loops are shifted over by 1..

Arguments:
jj_loop.pl 1 shift next


Shift with Step of 3
But, obviously, unlike modo's tool, you're not restricted to a step of 1. Here all the loops are moved along by 3.

Arguments:
jj_loop.pl 3 shift next

Shift with Step of 3 on Polygons
Here, the same operation is applied to some polygon loops..

Arguments:
jj_loop.pl 3 shift next

Shift with Poly Blocks
Again, unlike modo's tool, you can shift whole 'blocks' of loops along with no problem..(modo's tool would drop all of the loops except one).

Arguments:
jj_loop.pl 3 shift next

Shift with Edge Blocks
Here, some edge loops are all shifted along by 5.

Arguments:
jj_loop.pl 5 shift next

Shifting Big Blocks
You can shift huge blocks of loops along by any step setting - here I've shifted this block along by 4..

There's an important note about contiguous blocks of polygon loops further down this page - you may have to toggle the dominance switch so that jj_loop knows which is the dominant loop direction. In the image opposite, do the loops run vertically or horizontally? You decide :-)

Arguments:
jj_loop.pl 3 shift next

Quickadd
Like modo's tool, jj_loop can add to loop selections but can also go in both directions at once. Here at a step setting of 1...

jj_loop.pl 1 quickadd both

Quickadd 2
...and here at a step setting of 3.

Arguments:
jj_loop.pl 3 quickadd both


Quickadd 3
...so, obviously, you can grow selections outwards like this..

Arguments:
jj_loop.pl 1 quickadd both

Quickadd 4
...and here at a step setting of 3.

jj_loop.pl 3 quickadd both

Slowadd
Here there are two discrete 'blocks' of loops. If you used 'quickadd' then jj_loop won't sort into loop 'blocks' and you'll get erratic results.

This is where 'Slowadd' comes in. It intelligently selects loop 'blocks' and expands them all. Using slowadd you can add to each block. (Again, in this instance, modo's tool would only go in one direction and would only add a loop to one of the selected loops).

Slowadd is a lot slower than Quickadd (as you'd expect) but can cope with more complex situations.

jj_loop.pl 1 slowadd both

Slowadd 2
Here there are two discrete 'blocks' of loops but this time they're already stepped by 2. JJ_loop looks at the step setting and determines whether the blocks are more than the step setting apart. If they are, then it treats the blocks seperately and can add to them individually. If, in this instance, you set the step size to 1, then the script would add 1 to all the loops but because it's set to 2 or greater it will only add to the outer edges of each block.

jj_loop.pl 2 slowadd both

Slowadd 3
Provided the step setting is equal to or higher than the gaps between the loops you can increment the step manually and add to the selection increasing the step size (if you really want to!).

jj_loop.pl 'n' slowadd both

Range
Using 'Range' you can specify a step setting and the number of loops you want to select in any direction. Here, I've set a Range of 5 and Step of 2 in one direction..

You can also go in both directions. Range is useful if you know the exact step and count setting for the number of loops you want to select.

Arguments:
jj_loop.pl 3 5 next

(Range does not have a special argument keyword as it's the default state but does require the step to be in slot 1 and the count to be in slot 2).

Using Infinite
With the 'Infinite' command you can select every nth loop on some geometry in any direction, including both. Here, I've selected every second loop. The script only stops when it can't find any further valid loops...great for reducing the poly count of geometry in a regular fashion.

Arguments:
jj_loop.pl 2 infinite both


Using Infinite 2
Using Infinite on a sphere there's no need to select both directions as the loop will terminate when it starts to double up..here every 4th loop has been selected.

Arguments:
jj_loop.pl 2 infinite prev

Using Infinite Across Layers
Here, the four cylinders are on different layers, but jj_loop will still work correctly. Infinite loops with a step of 2 in both directions...plus a smooth shift at the end to show how useful this is for corrugations.

Arguments:
jj_loop.pl 2 infinite both


How to Install JJ_Loop with the Form




There are currently two components to jj_loop - the script itself, and a configuration file to set up the form. Using the inbuilt arguments you can use the script from a key without having to install the form if you want.

jj_loop.pl - the perl script itself
jj_loop.cfg - the file that creates the form.

Option 1
The way the form is configured at the moment means that if you place it directly into your modo resrc folder (on OSX you'll need to open the modo package contents and place it in the Resources folder), the form will become available to you next time you launch the application. This relies on modo's default behaviour but can result in a very cluttered resrc directory. If you then place the script itself in the same directory as modo.app/modo.exe it will be available to the form without any further alterations being required.

Option 2
Alternatively, you can create your own location to store both the script and config file but will need to adjust the path locations in the jj_loop.cfg file. The benefit of this approach is that you have control over where you keep your external files and they won't get overwritten should you update modo.

It doesn't really matter where you put them so long as you make sure you have correct paths in the relevant files.

Once you've chosen a location for both files then you need to open up the jj_loop.cfg file in a text editor and put in the relevant path to the actual script using search and replace so that every time the script is called it has the correct path. Here's an example of how a single entry should look (but, remember, every entry for the script should be changed to the correct path using a single search and replace).

On a Mac:

<list type="Control" val="cmd @{/Users/julianjo/Desktop/current pbs/jj_loop.pl} user">
<atom type="Label">jj_loop</atom>
<atom type="Hash">54409416674:control</atom>
</list>

On a PC:

<list type="Control" val="cmd @{C:\Directory with Spaces\subdirectory\jj_loop.pl} user">
<atom type="Label">jj_loop</atom>
<atom type="Hash">54409416674:control</atom>
</list>


If the path has a space in it then the script needs to enclosed in curly brackets e.g.

@{/Users/julianjo/folder with spaces/jj_loop.pl}

It's easy to mistakenly delete a quote mark or a space, so make sure you find and replace just the path.

Once you've configured the path in the config file you're nearly ready to roll. Fire up modo, go to File:Config Import and import the jj_loop.cfg file you've just amended. This tells modo to load that file (i.e. the menu for Loop Hop), every time you launch modo.

For ease of access to the form simply assign the form to a key.

When The Script Runs I Get Bombarded With an Error Message

The 'General Failure' message is a known issue with modo and can be easily fixed.



Luxology themselves have released a patch for this error message on Vertex Monkey:

http://www.vertexmonkey.com/scripts_bugfix.php

Alternatively, you can just set the 'In the future' drop down to let modo know you don't want to see this message again. The error sounds dramatic but isn't, it's totally inconsequential. Luxology's bugfix script does simply that - it turns off that specific error message.


Important Note About High Polygon Counts

If you're using jj_loop on an extremely high poly count object there's a chance the script will hang or crash. There is currently a bug in modo when processing a large number of points/polys via scripts. In 'normal' usage, you shouldn't have any problems - it's just when you use one of the add tools to an already high 'block' of loops or when you use infinite and it has to traverse 1000+ edges. However, there are a couple of workarounds. The first one is to fire off the script from a Layout window - the instructions to set up a form within a window are set out below. This removes the problem completely. Alternatively, there's a command on the 6th line of the script called #&step; - if you remove the hash at the beginning of this line in a text editor and resave the script the script will always pop up a confirm dialog box like the one below and, again, this will remove the problem. It may be sensible to have two versions of the script saved - one with the dialog and one without but it really depends on how you use the script. For simple shifts and adds, it's going to work fine anyway. My preference is to bind some of the simple functions to keys and then use the form within a Layout window for bigger jobs.



I Hate The Way the Form is a Popover and Vanishes if I Move My Mouse Too Much

To get a permanent window with the wrap form as above:

1. Go to Layout:New Window
2. Set the window to Form View by LMB clicking on the right hand arrow.
3. RMB on the Form View header and select JJ Wrap. Now you have a window.

Dominant Loops


When you have a block of contiguous poly loops the script has to look at each poly and work out how many viable loops it 'could' have. It then chooses the largest of those loops and adds it to the loop list. If you grow a poly selection outwards at some point the horizontal loops will become larger than the vertical ones - at this point the script will not add any more. In order to continue to add in these situations you need to change the dominance - this tells the script to treat the loops with the smallest number of polygons as the correct loops. Would be nice to think of a better way to do this!


Known Issues

1. When you first use the form, the values for each of the fields don't exist and the form looks corrupted. You need to run the script once so that modo is aware of the existence of the form fields etc. You can do this by using F6 to navigate to the script and firing it off once.

2. When working across layers and mostly with spheres, sometimes modo's internal loop direction (i.e. next/prev) can either go in opposite directions on each layer or can start oscillating between next/prev depending up your geometry. Once I've figured out exactly how loop behaves internally I'll nail this one but at the moment the way next/prev loop works seems on the surface quite erratic - it can change direction quite oddly. Most of the slowness and error checking in this script is to determine which way the loop is travelling at any given moment. A quick example: when an edge loop hits the end of a rectangle the whole outer square of the rectangle is selected as a loop and the direction of the loop changes and starts 'reversing'. Identifying these situations and accommodating them in the script has been a pain in the arse. My guess is that the next/prev loop tool is working properly to a given set of rules but I just can't figure out exactly what those rules are.


Versions

Version 1.0:
jj_loop.pl
- Original version 24.12.2005


Julian Johnson
julian@exch.demon.co.uk