Re-Connect loops of quads

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re-Connect loops of quads

Post by mc_axe » 29 Oct 2016, 03:01

Hello, i just figured a way to reconnect polygons that look like "dissolved loops of quads" , to save some clicking time with the add edge tool (Since it takes a significant amount of time), so since i figured, i recorded something from the log and changed it slightly, is on JScript. It actually works for multiple loops but with lots limitations.

Image

I have no idea on scripting so:limitations,
-First i used a method from mCleaner to select NGons so you need mCleaner.
2)It works only if the mesh is named cube :p and its better when you have nothing in operator stack cause if you have something used in script the script might use a previous operator.
3)For fast undo delete the operators, freeze after use if you plan to use it more than once.
4)Dosn`t work for parallel loops that are touching or nested loops etc, or complex shapes of dissolved stuff.
5)Outside of dissolved loops it needs a mesh with quads or triangles, other Ngons will possibly end up like holes or some monstrocity.
6)Extreme dissolves (like for example a dissolve of almost an entire loop around a cylinder) might give probs with welding, so split in more parts with a polygon in between and freeze again before use.

Corespondent edges will weld at some point adjust weldedgesop.distance", 1 to something else if distance is the prob.

Code: Select all

var Sel= Selection;
mSelNgons();
SelectFilter("Polygon");
DuplicateMeshComponent();
//Translate(null, 0, 0.2, 0, siRelative, siLocal, siObj, siXYZ, null, null, null, null, null, null, null, null, null, 0, null);
SelectAdjacent(null, "Edge", false);
ActivateRaycastPolySelTool(null);
ApplyTopoOp("DeleteComponent",null, siUnspecified, siPersistentOperation, null);
ActivateRaycastEdgeSelTool(null);
ApplyTopoOp("WeldEdges", null, siUnspecified, siPersistentOperation, null);
SetValue("cube.polymsh.weldedgesop.distance", 1, null);
SelectAdjacent(null, "Point", false);
ActivateRaycastEdgeSelTool(null);
ApplyTopoOp("DissolveComponent", null, siUnspecified, siPersistentOperation, null);
ActivateVertexSelTool(null);
ApplyTopoOp("Collapse", null, siUnspecified, siPersistentOperation, null);
Last edited by mc_axe on 29 Oct 2016, 17:17, edited 2 times in total.

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Re-Connect Dissolved loops of quads

Post by mc_axe » 29 Oct 2016, 17:11

And here is another use
Image

Can anyone help me make it work for any object name? thx

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Re-Connect loops of quads

Post by myara » 31 Oct 2016, 05:18

With this script the vertex indexes may change so although it isn't a solution for every situation I think it is a clever combination of XSI default tools to achieve the result you wanted.

To make it work with any object you will have to put your selection in a variable, and replace the 'cube' with this variable.

I'm using Sel = GetValue('selectionlist') to get the selection because it is an easy way to get the selection. This variable won't change even if you change your selection.
If you use Sel = Selection, the Sel value will change everytime your selection changes.

I added a loop too, so it can be used in multiple objects.
Since your script need to change the selection multiple times, I added a line to select the object in every iteration.

And last, I added an Undo Command (available since SI 2012) to undo everything. If you need to use it in a previous SI version, delete those lines.

Also added a FreezeModeling command.

Code: Select all

//JScript
function main(){

    OpenUndo('Re-Connect loops of quads')

    var Sel= GetValue('selectionlist')

    for ( var i=0; i < Sel.Count; i++ ) {
        var obj = Sel(i)
        SelectObj(obj)

        mSelNgons();
        SelectFilter("Polygon");
        
        if (Selection.Count==0) continue
        
        DuplicateMeshComponent();
        //Translate(null, 0, 0.2, 0, siRelative, siLocal, siObj, siXYZ, null, null, null, null, null, null, null, null, null, 0, null);
        SelectAdjacent(null, "Edge", false);
        ActivateRaycastPolySelTool(null);
        ApplyTopoOp("DeleteComponent",null, siUnspecified, siPersistentOperation, null);
        ActivateRaycastEdgeSelTool(null);
        ApplyTopoOp("WeldEdges", null, siUnspecified, siPersistentOperation, null);
        SetValue( obj + ".polymsh.weldedgesop.distance", 1, null);
        SelectAdjacent(null, "Point", false);
        ActivateRaycastEdgeSelTool(null);
        ApplyTopoOp("DissolveComponent", null, siUnspecified, siPersistentOperation, null);
        ActivateVertexSelTool(null);
        ApplyTopoOp("Collapse", null, siUnspecified, siPersistentOperation, null);

        FreezeModeling( obj )
    }
    SelectObj( Sel )
    
    CloseUndo()
}

main()
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Re-Connect loops of quads

Post by mc_axe » 31 Oct 2016, 16:22

Thanx alot myara for your time \m/ you rockz!

Iv tried to put a 'Sel' variable my self but failed miserably.
With your additions it became much less frustrating and easy to use multiple times, plus the functionality for multiple objects awesome!

But the freeze and undo combo is best addition i believe due to the fact that still has many limitations.
So now it is now more like a trial and error tool: try, undo, adjust, till it works. I usualy add few edges here and there in areas that produce 'bugs' (or i adjust the weld distance) and at some point it just works! Happy days :D

User avatar
gaboraa
Posts: 314
Joined: 16 Apr 2010, 23:14

Re: Re-Connect loops of quads

Post by gaboraa » 01 Nov 2016, 10:25

You are the awesome Martin ^:)^

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests