Awesome! - thanks so much, Matt
This worked like a charm.  Somehow each of the objects came out half size, 
(maybe I had some odd scaling in the hierarchy? ) but that was a very easy fix 
and this problem is solved.  3500 button clicks reduced to about 10.


The hardest part of moving away from Soft for me will be leaving all the help 
and insight I get from this list.  I am more a designer than technical artist 
but I do love my ICE.  The help I get from this list really raises my abilities 
especially in the technical areas.  I just wish I could offer more in return 
for all I have received from everyone here.

Jeff


From: softimage-boun...@listproc.autodesk.com 
[mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Matt Lind
Sent: Tuesday, February 10, 2015 4:27 AM
To: softimage@listproc.autodesk.com
Subject: Re: merge parent and children through scripting?

Try this.

1) paste script into script editor (JScript)
2) Select parent polygon meshes
3) run script


main();
function main()
{
    var oObjects = SIFilter( null, siPolyMeshFilter, true, siQuickSearch );

    for ( var i = 0; i < oObjects.Count; i++ )
    {
        var oObject = oObjects(i);

        var oItems    = XSIFactory.CreateActiveXObject( "XSI.Collection" );
        oItems.Unique = true;

        oItems.Add( oObject );

        var oChildren = oObject.FindChildren2( "", siPolyMeshType );

        for ( var j = 0; j < oChildren.Count; j++ )
        {
            oItems.Add( oChildren(j) );
        }

        if ( oItems.Count > 1 )
        {
            // merge
            var oOperators     = ApplyGenOp( "MeshMerge", "", 
oItems.GetAsText(), siUnspecified, siPersistentOperation, siKeepGenOpInputs, 
null );
            var oMergeOperator = oOperators(0);

            oMergeOperator.Parameters( "tolerance" ).value = 1.00;
            oMergeOperator.Parameters( "blend"     ).value = false;

            //
            var oMergedObject = oMergeOperator.Parent3DObject;

            TransferallPropertiesAcrossGenOp( oMergeOperator.FullName, 
oMergedObject.FullName, null, true, true );

            FreezeObj( oMergedObject );

            // match the center
            var oTransform = oObject.Kinematics.Global.Transform;
            oMergedObject.Kinematics.Global.Transform = oTransform;

            try {
                DeleteObj( oItems );
            } catch(e) {
                LogMessage( "Cannot delete objects: " + e.description, siError 
);
            }
        }
    }

    return(0);
}




Matt




Date: Tue, 10 Feb 2015 01:35:28 +0000
From: Jeff McFall <jeff.mcf...@sas.com<mailto:jeff.mcf...@sas.com>>
Subject: merge parent and children through scripting?
To: softimage@listproc.autodesk.com<mailto:softimage@listproc.autodesk.com>

I have a large set of extruded poly objects which have their detached caps as 
children.
I need to merge these caps into the parent geometry.  There are several hundred 
of these and manually doing each is pretty daunting.  This is beyond my 
scripting abilities.

Anyone have any suggestions or know of a script they could point me to as 
reference to get started?


Many thanks
Jeff

Reply via email to