Home Technical Talk

Loop/Ring Maxscript idea

I don't think this exists already.. but it may.

But if someone would be willing to script it, that would be very awesome :D

Basically what I am looking for is a way to select 2 edges, then loop/ring the edges only in-between those selected edges and not past them. This would allow me to isolate loops/rings and remove/adjust edges more quickly.

Thanks!

Matt

Replies

  • Yozora
    Options
    Offline / Send Message
    Yozora polycounter lvl 11
    syncviews has made something to do this in his illusion catalyst tools. Its called "span" http://www.illusioncatalyst.com/ic_shape_intro.php
  • mLichy
    Options
    Offline / Send Message
    Oh , cool. Yeah that works how I want. I wish I knew the programming behind it though. I'd like to just have that tool instead of all the others. But also learn more about how max script works.
  • j_bradford
    Options
    Offline / Send Message
    j_bradford polycounter lvl 17
    This is built into Polyboost / Ribbon modeling tools also. It's called StepMode and StepLoop. Works on edges, faces and verts. I use it all the time, big timesaver.
  • SyncViewS
    Options
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Matt, what would you like to know exactly? The idea behind the script is quite straightforward, its realization a little more complex for the lack of clever methods in 3ds Max code to get sorted edge loops/rings. The only thing you can query for is a BitArray filled with edge loop/ring indexes. For its very own nature it doesn't tell you anything about edge order or whatsoever. You therefore need to build your own functions to get loops/rings in a specified direction starting from one of the two edges limiting the span.

    According to my memory, steps are these:
    1. Get the two edges limiting the span
    2. Choose one limit edge and get every sorted loop/ring staring from it in every possible direction
    3. Look for the second edge limiting the span in each sorted edge list, if found store that list
    4. For each list stored, count how many edges are between the two limiting span and pick the one with the lower number; if more than one share the same count pick all of them
    5. Set the new edge selection

    Unfortunately working with editable poly (tris/quads/n-gons) doesn't allow to make many assumption about topology. Between two edges there can be more than one or two ways to connect them legally via loop or ring, so you must test everything. In example think about a subdivided cube.

    The trickier part of this script is making the functions to get sorted directional edge loops/rings. They must be optimized because involve the repeated use of many slow MaxScript methods, and even in that case, they are still much slower than coded through the SDK, which provides access directly to the geometry database at a lower level.
  • Playdo
    Options
    Offline / Send Message
    It's called StepMode and StepLoop

    I don't have Max in front of me but doesn't this only work for a loop and not for a ring?
  • mLichy
    Options
    Offline / Send Message
    Awesome, thanks alot guys. Yeah, that's what I was looking for more or less Sync. That was my thought process for some of it.

    I just need to learn the language/math so I can do some of this stuff. I've done scripting before, but it was in Torque, so I keep typing in stuff from that and getting confused.

    I found one good vid tutorial, but will search for more, and of course reference the help stuff. I'm more or less just wanting to learn about maxscript to make tools that I think of while working to help myself or others who might want them.


    edit: So that step loop is cool, but it doesn't seem to work with rings :(. I guess I'll either have to use the cat tools or script it myself.
  • SyncViewS
    Options
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hey Matt, if you want to learn MaxScript I can point you to the CG-Academy training series by Laslo Sebo, the author of well known Meshtools, and Borislav "Bobo" Petrov, who doesn't need introductions. Anyway the huge and sometimes messy Reference is still your best friend. If you need assistance and explanations, don't hesitate to ask here and I'll try to help, or even better on (sorry guys for the advertise of another board) MaxScript subforum at CGTalk. There you can find a handful of professionals willing to help, including Bobo.
  • mLichy
    Options
    Offline / Send Message
    Sweet, thanks for the info. I've been tinkering with the programming for a good part of the day already, but the way I need to use the code snippets is a little confusing.

    I setup a button to take 2 edges, and put them into a variable and print my selection in a pair, which was easy, but then I'm not sure how to choose 1 edge and do the ring/loop in every direction from that.

    I found this
    <float><EditablePoly>.getEdgeData <integer>edgeDataChannel <*integer>numberSelected <*bool>uniformData [edgeFlags:<DWORD>]

    But have no idea how to use it. I'll checkout CGTalk and Academy. I go to CGTalk alot, but forgot to check there. thanks :D
  • SyncViewS
    Options
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Every element is identified by a progressive integer, which means you got a number for each edge, vertex, face or polygon which identifies it uniquely until the topology changes, in other words until a vertex and consequently edges and faces aren't added or deleted.

    Speaking about loops, when you got an edge by index, you then should start finding its neighbour along the loop if it exists. Since an edge has always two vertexes as extremities, you can use one of them to define the direction to start looking for the loop.

    At this point is a matter of getting elements by elements, in other words you can query the geometry database asking what polygons share the edge you selected, or you can ask what edges start form the vertex defining the search direction. In the loop case I use this sequence:

    1. get edges from direction vertex (call this edgeSet_1)
    2. get faces from starting edge (call this faceSet_1)
    3. get edges from faceSet_1 (call this edgeSet_2)
    4. subtract edgeSet_2 from edgeSet_1 (call the result edgeSet_3)
    5. if edgeSet_3 is made by a single edge then it is the one we are looking for, store it
    6. get vertexes from edgeSet_3 and subtract the old starting vertex (call it vertSet_1)
    7. repeat the sequence with the new edge as starting edge, and the vertSet_1 as direction vertex

    This could give you an idea about the process. Edge data you found is another topic. Take a look at "Editable_Poly Methods" in the reference, in particular the paragraphs "Get A Using B" and "Get By Edge". You should have clear in mind how Arrays and BitArrays work in MaxScript, take a look at "Array Values" and "BitArray Values". If you need to know loop syntax "Controlling Program Flow in Scripts" and "For Loop". In this particular case I use a do...while, but a regular while can work too.
  • mLichy
    Options
    Offline / Send Message
    Thanks alot for all your help :). This should get me going on the right track I'm sure. Keep up the good work :D
  • Ghostscape
    Options
    Offline / Send Message
    Ghostscape polycounter lvl 13
    Playdo wrote: »
    I don't have Max in front of me but doesn't this only work for a loop and not for a ring?

    in 2010 at least there are stepring and steploop, I'm not sure if its called something else in Polyboost.

    Stepring doesn't work on poly-selection rings, though. I'm guessing because of the way it determines a poly-selection ring - stepringing would change the direction of the ring each time.
  • mLichy
    Options
    Offline / Send Message
    Where in 2010 is it? I saw stepLoop when in editablepoly with verts or edges selected, but not loop?

    I've been working on learning scripting most all day, and have alot better understanding of it now :). I followed these videos tuts I got, and went beyond what he showed, giving random rotations, and making the macroscript alot more fool proof.
Sign In or Register to comment.