Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '-----------------------------------------------------------------------------------------------------------------'
- 'This script is pretty much the same as my other Cloned Symmetry script, but without the slice polygons / gator 'ops. It will duplicate the selected polygon mesh(s), leaving the original hidden but otherwise untouched. If the 'polygon mesh's center is not exactly on the cut line, you may need to adjust it, Generally I just hold control to 'enable snapping(with all objects and points enabled) and drag the center along it's X-axis until it snaps to one 'of the centerline points.
- 'Next the new duplicate mesh(*-Modelling) is cloned(*-ClonedHalf) and expressions put in place linking it to the 'Modelling half, with the x axis expression being multiplied by -1, then both halves are merged.
- 'The merged mesh(*-MergedMesh) then gets it's selectability disabled, and expressions added to link it's 'subdivision levels to a newly created cube(*-SubdCtrl) that is parented to the modelling mesh. If you want to 'control the MergedMesh's subd levels directly just delete the SubdCtrl cube. To re-enable Selectability on the 'MergedMesh either open up its visibility settings and tick the selectability box, or select the MergedMesh from 'explorer and click "Select-Selectability-Toggle Selected Objects".
- 'To view the Modelling half as a proper mesh instead of a wireframe, re-enable override object properties for the 'camera viewport, and to undo everything just branch select the Modelling mesh and delete it, then unhide the 'original.
- 'I have also added expressions linking the final result (-MergedMesh) to the modelling half since I noticed if you 'were using the modelling object to move things around the center of MergedMesh was staying at zero. If this 'causes any problems you could just remove all animation for mergedmesh, otherwise when you are finished modelling 'freeze MergedMesh's modelling stack, branch select -Modelling and delete, you should have a final mesh to work 'with then that has no expressions but its SRT will be where you'd expect :)
- 'And finally, if the mesh you have selected ends with one of the naming conventions I have used (e.g. sphere-'Modelling), or versions already exist that end like that, then it will try and undo things that may have been put 'in place by my script previously, and run through a simple loop checking incrementally for the next available 'name. This lets you create new copys of either the original object or the finished result quickly without having 'the names get all messy.
- '-----------------------------------------------------------------------------------------------------------------'
- dim oCol, oSelection, oSelecto, oFinalSelect, BP, ScriptCancel, oDupe, oClone, oMerge, oGenOp, oSubdCtrl
- dim oModelo, oSelName, oSubdCtrlCheck, AfterDashCheck, oSelectoSubdOgl, oSelectoSubdRdr
- dim oMergeScale, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax, CtrlXtrans, CtrlYtrans, CtrlZtrans, CtrlScale
- dim oDupeScaleX, oDupeScaleY, oDupeScaleZ, oSelTest3
- dim oDupeRotX, oDupeRotY, oDupeRotZ, oSelTest4
- dim oDupePosX, oDupePosY, oDupePosZ, oSelTest5
- dim regEx, oModellingCheck, oModellingCheck2, Match, Matches, NumberCheck, objNumber, JustIncaseAbort, oSelTest
- dim oExpExist, ExpStr, oExpCheck, oSelTest2, WereRenamed, oShrinkWrapCheck, SWStr
- 'Set up a regExp for later use
- set regEx = New RegExp
- 'Define a collection(oCol) for adding objects to
- Set oCol = CreateObject( "XSI.Collection" )
- 'Check if something is selecteds
- if Application.Selection.count > 1 Then
- 'Add the application selection to oCol
- Set oSelection = Application.Selection
- for i = 0 to (oSelection.Count - 1)
- 'Set a new Regex pattern that finds any letters after - at the end of its name
- regEx.Pattern = "-[a-zA-Z]+$"
- 'Reset oSubdCtrlCheck
- oSubdCtrlCheck = "Nothing"
- 'Execute the regex on the selection
- Set Matches = regEx.Execute(oSelection(i))
- For Each Match in Matches
- oSubdCtrlCheck = Match.Value
- Next
- 'If the selection doesnt end in -SubdCtrl then add it to the oCol Collection.
- if oSubdCtrlCheck <> "-SubdCtrl" then
- Logmessage oSelection(i) & " smells of roses, added to oCol"
- oCol.add oSelection(i)
- else
- Logmessage oSelection(i) & " smells of cheese, totally rejected!"
- end if
- next
- elseIf Application.Selection.count = 1 Then
- oCol.add Application.Selection(0)
- else
- 'If no object is selected, start a picksession
- LogMessage "Select a polymesh"
- PickObject "Select a polymesh", " ", oSelecto
- 'Add Picksession object to oCol
- oCol.add oSelecto
- end if
- 'Create a collection to add objects to for selection at the end
- Set oFinalSelect = CreateObject( "XSI.Collection" )
- for i = 0 to (oCol.count-1)
- set oSelecto = oCol(i)
- 'Make sure the oSelecto is a Polymesh, if it isn't then give the user one last try to select one
- set oSelecto = Dictionary.GetObject( oSelecto, false )
- if oSelecto.Type = "polymsh" then
- ScriptCancel = "no"
- else
- LogMessage oSelecto & " is a " & oSelecto.Type & ",not a polymsh"
- BP = XSIUIToolkit.Msgbox( oSelecto & " is not a polymsh, do you want to select something else?", 4, "No Polygon Mesh Selected" )
- if BP = 6 then
- PickObject "Please select a polygon mesh", " ", oSelecto
- if oSelecto.Type = "polymsh" then
- ScriptCancel = "no"
- else
- XSIUIToolkit.Msgbox "Bah, I give up.. " & oSelecto & " is a " & oSelecto.Type & " !", 1, "No Polygon Mesh Selected"
- Logmessage "Script Cancelled - Next time select a Polygon Mesh instead of a " & oSelecto.Type & "! :)"
- ScriptCancel = "yes"
- end if
- else
- LogMessage "Script Cancelled - " & oSelecto & " isn't a polygon mesh"
- ScriptCancel = "yes"
- end if
- end if
- if ScriptCancel = "no" then
- 'Set a new Regex pattern that finds any letters after - at the end of its name
- regEx.Pattern = "-[a-zA-Z]+$"
- 'Reset AfterDashCheck
- AfterDashCheck = "Nothing"
- 'Execute the regex on the selection
- Set Matches = regEx.Execute(oSelecto)
- For Each Match in Matches
- AfterDashCheck = Match.Value
- Next
- 'Reset SliceAway
- SliceAway = "no"
- 'If the selection ends in -MergedMesh ask the user if they want to cut it
- if AfterDashCheck = "-MergedMesh" or AfterDashCheck = "-Gator" then
- LogMessage oSelecto & " looks like a merged result, should I cut ?"
- BP = XSIUIToolkit.Msgbox( oSelecto & " looks like a merged result, do you want to cut it ?", 3, "Merged Mesh Detected" )
- if BP = 6 then
- LogMessage "OK, slicing " & oSelecto & ", gonna slice him up real good!"
- SliceAway = "yes"
- elseIf BP = 7 then
- LogMessage "Alrighty, no slice and dice for " & oSelecto & ", sorry for bothering you ! :)"
- SliceAway = "no"
- else
- LogMessage "Skipping " & oSelecto & " completely"
- ScriptCancel = "yes"
- end if
- end if
- if ScriptCancel = "no" then
- 'Store the original object's subdivision levels for later use
- set oSelectoSubdOgl = Dictionary.GetObject( oSelecto & ".geomapprox.gapproxmosl", false )
- set oSelectoSubdRdr = Dictionary.GetObject( oSelecto & ".geomapprox.gapproxmordrsl", false )
- oSelectoSubdOgl = oSelectoSubdOgl.Value
- oSelectoSubdRdr = oSelectoSubdRdr.Value
- 'Duplicate original mesh
- set oDupe = Duplicate (oSelecto, , 2, 1, 1, 0, 0, 1, 0, 1, , , , , , , , , , , 0)
- 'Remove any animation on gemoetry approximation (incase the input object had any)
- RemoveAnimation oDupe & ".geomapprox.gapproxmosl", 10
- RemoveAnimation oDupe & ".geomapprox.gapproxmordrsl", 10
- 'Set oDupe's subdivision levels to the same value as the input object
- SetValue oDupe & ".geomapprox.gapproxmosl", oSelectoSubdOgl
- SetValue oDupe & ".geomapprox.gapproxmordrsl", oSelectoSubdRdr
- if SliceAway = "yes" then
- 'Slice the duplicate in half, set the reference plane to local, and delete -x polys
- ApplyTopoOp "SlicePolygons", oDupe, siUnspecified, siPersistentOperation
- SetValue oDupe&".polymsh.slicepolygonsop.planeref", 1
- SetValue oDupe&".polymsh.slicepolygonsop.sliceaction", 3
- end if
- 'Create a clone of the duplicate
- set oClone = Clone (oDupe, , 1, 1, 0, 0, 1, 0, 1)
- 'Merge the duplicate and clone, transfer all properties
- oGenOp = ApplyGenOp ("MeshMerge", , oDupe &","& oClone, 3, siPersistentOperation, siKeepGenOpInputs)
- oMerge = replace (oGenOp, ".polymsh.mergemesh", "")
- TransferAllPropertiesAcrossGenOp oGenOp, oMerge, , True, True
- 'Set the Merge tolerance to 0.1
- SetValue oGenOp & ".tolerance", 0.1
- 'Create a cube named SubdCtrl to control the merged mesh's subdivision levels via expressions
- Preferences.SetPreferenceValue "Interaction.autoinspect", false
- set oSubdCtrl = CreatePrim ("Cube", "MeshSurface", "SubdCtrl")
- Preferences.SetPreferenceValue "Interaction.autoinspect", true
- 'Make SubdCtrl and mergedmesh's geometry approximation local
- MakeLocal oMerge & ".geomapprox", siDefaultPropagation
- MakeLocal oSubdCtrl & ".geomapprox", siDefaultPropagation
- 'Link MergedMesh's geometry approximation to SubdCtrl via expressions
- SetExpr oMerge & ".geomapprox.gapproxmosl", oSubdCtrl & ".geomapprox.gapproxmosl"
- SetExpr oMerge & ".geomapprox.gapproxmordrsl", oSubdCtrl & ".geomapprox.gapproxmordrsl"
- 'Match SubdCtrl's subdivision levels to the original object
- SetValue oSubdCtrl & ".geomapprox.gapproxmosl", oSelectoSubdOgl
- SetValue oSubdCtrl & ".geomapprox.gapproxmordrsl", oSelectoSubdRdr
- 'Give SubdCtrl the same material as the merged mesh
- AssignMaterial oMerge & ".*," & oSubdCtrl, siLetLocalMaterialsOverlap
- 'Set SubdCtrl's Visibility options
- SetValue oSubdCtrl & ".visibility.rendvis", False
- SetValue oSubdCtrl & ".visibility.primray", False
- SetValue oSubdCtrl & ".visibility.scndray", False
- SetValue oSubdCtrl & ".visibility.shdwcast", False
- SetValue oSubdCtrl & ".visibility.shdwrecv", False
- SetValue oSubdCtrl & ".visibility.trnscast", False
- SetValue oSubdCtrl & ".visibility.trnsvis", False
- SetValue oSubdCtrl & ".visibility.globcast", False
- SetValue oSubdCtrl & ".visibility.globvis", False
- SetValue oSubdCtrl & ".visibility.causvis", False
- 'Set the clone's visibility options
- SetValue oClone & ".visibility.viewvis", False
- SetValue oClone & ".visibility.rendvis", False
- SetValue oClone & ".visibility.primray", False
- SetValue oClone & ".visibility.scndray", False
- SetValue oClone & ".visibility.shdwcast", False
- SetValue oClone & ".visibility.shdwrecv", False
- SetValue oClone & ".visibility.trnscast", False
- SetValue oClone & ".visibility.trnsvis", False
- SetValue oClone & ".visibility.globcast", False
- SetValue oClone & ".visibility.globvis", False
- SetValue oClone & ".visibility.causvis", False
- 'Set oClone's subdivision levels to 0
- SetValue oClone & ".geomapprox.gapproxmosl", 0
- SetValue oClone & ".geomapprox.gapproxmordrsl", 0
- 'Set the duplicate's Visibility options
- SetValue oDupe & ".visibility.viewvis", True
- SetValue oDupe & ".visibility.rendvis", False
- if AfterDashCheck <> "-Modelling" then
- 'Set the duplicate's Display options (0 is wireframe, 5 is bounding box)
- MakeLocal oDupe & ".display", siDefaultPropagation
- SetValue oDupe & ".display.staticsel", 0
- SetValue oDupe & ".display.intsel", 0
- SetValue oDupe & ".display.playbacksel", 0
- SetValue oDupe & ".display.staticunselnear", 5
- SetValue oDupe & ".display.intunselnear", 5
- SetValue oDupe & ".display.playbackunselnear", 5
- SetValue oDupe & ".display.staticunselfar", 5
- SetValue oDupe & ".display.intunselfar", 5
- SetValue oDupe & ".display.playbackunselfar", 5
- end if
- 'Disable the merged mesh's Selectability
- SetValue oMerge & ".visibility.selectability", False
- 'Disable Camera's override object properties option
- SetValue "Camera.camdisp.mixviewmode", False
- 'Change the duplicate's wireframe display colour
- SetValue oDupe & ".display.wirecolorr", 0.12
- SetValue oDupe & ".display.wirecolorg", 0.14
- SetValue oDupe & ".display.wirecolorb", 0.18
- 'Set the clone's scale expressions linking it to the modelling half
- SetExpr oClone & ".kine.local.sclx", oDupe & ".kine.local.sclx*-1"
- SetExpr oClone & ".kine.local.scly", oDupe & ".kine.local.scly"
- SetExpr oClone & ".kine.local.sclz", oDupe & ".kine.local.sclz"
- 'Set the clone's rotation expressions linking it to the modelling half
- SetExpr oClone & ".kine.local.rotx", oDupe & ".kine.local.rotx"
- SetExpr oClone & ".kine.local.roty", oDupe & ".kine.local.roty"
- SetExpr oClone & ".kine.local.rotz", oDupe & ".kine.local.rotz"
- 'Set the clone's translation expressions linking it to the modelling half
- SetExpr oClone & ".kine.local.posx", oDupe & ".kine.local.posx"
- SetExpr oClone & ".kine.local.posy", oDupe & ".kine.local.posy"
- SetExpr oClone & ".kine.local.posz", oDupe & ".kine.local.posz"
- 'Store oDupe's SRT to use for matching up oMerge's Center
- oDupeScaleX = GetValue (oSelecto & ".kine.Global.scl.sclx")
- oDupeScaleY = GetValue (oSelecto & ".kine.Global.scl.sclY")
- oDupeScaleZ = GetValue (oSelecto & ".kine.Global.scl.sclZ")
- oDupeRotX = GetValue (oSelecto & ".kine.Global.ori.euler.rotx")
- oDupeRotY = GetValue (oSelecto & ".kine.Global.ori.euler.rotY")
- oDupeRotZ = GetValue (oSelecto & ".kine.Global.ori.euler.rotZ")
- oDupePosX = GetValue (oSelecto & ".kine.Global.pos.posx")
- oDupePosY = GetValue (oSelecto & ".kine.Global.pos.posY")
- oDupePosZ = GetValue (oSelecto & ".kine.Global.pos.posZ")
- 'Match oMerge's Center to oDupe's SRT
- Translate oMerge, oDupePosX, oDupePosY, oDupePosZ, siAbsolute, siGlobal, siCtr, siXYZ, , , , , , , , , , 0
- Rotate oMerge, oDupeRotX, oDupeRotY, oDupeRotZ, siAbsolute, siGlobal, siCtr, siXYZ, , , , , , , , 0
- Scale oMerge, oDupeScaleX, oDupeScaleY, oDupeScaleZ, siAbsolute, siGlobal, siCtr, siXYZ, , , , , , , , 0
- 'Set the Merged Mesh's scale expressions linking it to the modelling half
- SetExpr oMerge & ".kine.local.sclx", oDupe & ".kine.local.sclx"
- SetExpr oMerge & ".kine.local.scly", oDupe & ".kine.local.scly"
- SetExpr oMerge & ".kine.local.sclz", oDupe & ".kine.local.sclz"
- 'Set the Merged Mesh's rotation expressions linking it to the modelling half
- SetExpr oMerge & ".kine.local.rotx", oDupe & ".kine.local.rotx"
- SetExpr oMerge & ".kine.local.roty", oDupe & ".kine.local.roty"
- SetExpr oMerge & ".kine.local.rotz", oDupe & ".kine.local.rotz"
- 'Set the Merged Mesh's translation expressions linking it to the modelling half
- SetExpr oMerge & ".kine.local.posx", oDupe & ".kine.local.posx"
- SetExpr oMerge & ".kine.local.posy", oDupe & ".kine.local.posy"
- SetExpr oMerge & ".kine.local.posz", oDupe & ".kine.local.posz"
- 'Get oMerge's bounding box co-ordinates to use in setting up relative values for SubdCtrl
- GetBBox oMerge, TRUE, Xmin, Ymin, Zmin, Xmax, Ymax, Zmax
- oMergeScale = ( ( ( Xmax - Xmin ) / 2 ) + ( ( Ymax - Ymin ) / 2 ) + ( ( Zmax - Zmin ) / 2 ) ) / 3
- CtrlXtrans = ( Xmin + Xmax ) / 2
- CtrlYtrans = Ymax + ( oMergeScale / 2.2 )
- CtrlZtrans = ( Zmin + Zmax ) / 2
- CtrlScale = oMergeScale * 0.01
- 'Move and scale SubdCtrl using the above values
- Scale oSubdCtrl, CtrlScale, CtrlScale, CtrlScale, siRelative, siGlobal, siObj, siXYZ, , , , , , , , 0
- Translate oSubdCtrl, CtrlXtrans, CtrlYtrans, CtrlZtrans, siAbsolute , siGlobal, siObj, siXYZ, , , , , , , , , , 0
- 'Add the SubdCtrl object to the oFinalSelect collection
- oFinalSelect.Add oSubdCtrl
- 'Remove the model name from selection
- oModelo = oSelecto.Model
- oSelName = replace( oSelecto, oModelo&".", "")
- 'Set some dictionary lookups to check if anything created by this script in the past still exists
- oSelTest = oCol(i) & "-Modelling"
- set ModellingTest = Dictionary.GetObject( oSelTest, false )
- oSelTest = oCol(i) & "-ClonedHalf"
- set ClonedTest = Dictionary.GetObject( oSelTest, false )
- oSelTest = oCol(i) & "-MergedMesh"
- set MergedTest = Dictionary.GetObject( oSelTest, false )
- oSelTest = oCol(i) & "-Gator"
- set GatorTest = Dictionary.GetObject( oSelTest, false )
- 'Reset WereRenamed
- WereRenamed = 0
- 'If the selected object is already created by one of my scripts, or has objects related to one of my scripts, find a new name for it and remove any annoyingness :P
- if AfterDashCheck = "-MergedMesh" or AfterDashCheck = "-Gator" or AfterDashCheck = "-Modelling" or TypeName( ModellingTest ) <> "Nothing" or TypeName( ClonedTest ) <> "Nothing" or TypeName( MergedTest ) <> "Nothing" or TypeName( GatorTest ) <> "Nothing" then
- if AfterDashCheck = "-MergedMesh" or AfterDashCheck = "-Gator" then
- LogMessage oSelName & " is already a merged result, removing expressions and finding a new name for it to keep things nice!"
- SetValue oDupe & ".visibility.selectability", True
- oSelName = Replace (oSelName, AfterDashCheck, "")
- oExpExist = "no"
- ExpStr = oDupe & ".kine.local.scl.sclx.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.sclx", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.scl.scly.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.scly", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.scl.sclz.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.sclz", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.ori.euler.rotx.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.rotx", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.ori.euler.roty.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.roty", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.ori.euler.rotz.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.rotz", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.pos.posx.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.posx", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.pos.posy.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.posy", 1
- oExpExist = "yes"
- end if
- ExpStr = oDupe & ".kine.local.pos.posz.Expression"
- set oExpCheck = Dictionary.GetObject( ExpStr, false )
- if TypeName( oExpCheck ) <> "Nothing" then
- RemoveAnimation oDupe & ".kine.local.posz", 1
- oExpExist = "yes"
- end if
- elseIf AfterDashCheck = "-Modelling" then
- LogMessage oSelName & " is a Modelling half, finding a new name for it to keep things nice!"
- oSelName = Replace (oSelName, "-Modelling", "")
- 'Check if the new modelling half has a shrink wrap op, if it does, freeze it
- SWStr = oDupe & ".polymsh.shrinkwrap"
- set oShrinkWrapCheck = Dictionary.GetObject( SWStr, false )
- if TypeName( oShrinkWrapCheck ) <> "Nothing" then
- FreezeObj oDupe & ".polymsh.shrinkwrap"
- LogMessage SWStr & " was Frozen"
- end if
- else
- LogMessage oSelecto & " already has some objects previously created by this script, finding a new name"
- 'Hide the original mesh
- SetValue oSelecto & ".visibility.viewvis", False
- SetValue oSelecto & ".visibility.rendvis", False
- end if
- 'Reset NumberCheck
- NumberCheck = "Nothing"
- 'Set a new Regex pattern that finds any numbers at the end of its name
- regEx.Pattern = "[0-9]+$"
- 'Execute the regex on the selection
- Set Matches = regEx.Execute(oSelName)
- For Each Match in Matches
- NumberCheck = Match.Value
- Next
- 'If there are no numbers on the end then set objNumber to 0 (another 1 will be added on later)
- if NumberCheck = "Nothing" then
- objNumber = "0"
- else
- 'If there is a number, set objNumber to the number found above
- objNumber = NumberCheck
- 'Now get the name without and numbers
- regEx.Pattern = "^.*?(?=[0-9])"
- Set Matches = regEx.Execute(oSelName)
- For Each Match in Matches
- oSelName = Match.Value
- Next
- end if
- 'Reset a counter I use to stop infinite loops, just incase :)
- JustIncaseAbort = 0
- 'Temporarily rename things to get them out of the way
- oDupe = SetValue (oDupe & ".Name", oSelName & "-modellingTemp")
- oClone = SetValue (oClone & ".Name", oSelName & "-cloneTemp")
- oMerge = SetValue (oMerge & ".Name", oSelName & "-mergeTemp")
- WereRenamed = 1
- 'This Do part will add a number to the object's name then check if that name is already taken
- 'if it is, it will loop and add on another number etc, until it finds a free name (or my failsafe reaches 1000)
- '-----------------------------Loop Start-----------------------------'
- Do
- 'Increase objNumber by 1
- objNumber = objNumber + 1
- 'Check if the model name needs to be added on to the test name
- if oModelo = "Scene_Root" then
- 'Add on the new number to the name to see if it exists
- oSelTest = oSelName & objNumber
- oSelTest2 = oSelName & objNumber & "-MergedMesh"
- oSelTest3 = oSelName & objNumber & "-Modelling"
- oSelTest4 = oSelName & objNumber & "-ClonedHalf"
- oSelTest5 = oSelName & objNumber & "-Gator"
- else
- 'Add on the model name aswell as the new number to the name to see if it exists
- oSelTest = oModelo & "." & oSelName & objNumber
- oSelTest2 = oModelo & "." & oSelName & objNumber & "-MergedMesh"
- oSelTest3 = oModelo & "." & oSelName & objNumber & "-Modelling"
- oSelTest4 = oModelo & "." & oSelName & objNumber & "-ClonedHalf"
- oSelTest5 = oModelo & "." & oSelName & objNumber & "-Gator"
- end if
- LogMessage "Checking if the name " & oSelTest & " is available .."
- set oSelTest = Dictionary.GetObject( oSelTest, false )
- set oSelTest2 = Dictionary.GetObject( oSelTest2, false )
- set oSelTest3 = Dictionary.GetObject( oSelTest3, false )
- set oSelTest4 = Dictionary.GetObject( oSelTest4, false )
- set oSelTest5 = Dictionary.GetObject( oSelTest5, false )
- 'Add 1 onto the abort counter
- JustIncaseAbort = JustIncaseAbort + 1
- if TypeName( oSelTest ) <> "Nothing" then
- LogMessage oSelTest & " already exists"
- end if
- if TypeName( oSelTest2 ) <> "Nothing" then
- LogMessage oSelTest2 & " already exists"
- end if
- if TypeName( oSelTest3 ) <> "Nothing" then
- LogMessage oSelTest3 & " already exists"
- end if
- if TypeName( oSelTest4 ) <> "Nothing" then
- LogMessage oSelTest4 & " already exists"
- end if
- if TypeName( oSelTest5 ) <> "Nothing" then
- LogMessage oSelTest5 & " already exists"
- end if
- 'Loop until there is a free name or the abort counter reaches 1000
- Loop Until TypeName( oSelTest ) = "Nothing" and TypeName( oSelTest2 ) = "Nothing" and TypeName( oSelTest3 ) = "Nothing" and TypeName( oSelTest4 ) = "Nothing"and TypeName( oSelTest5 ) = "Nothing" or JustIncaseAbort = 1000
- '-----------------------------Loop Finish-----------------------------'
- 'Add the final number onto oSelName
- oSelName = oSelName & objNumber
- if JustIncaseAbort = 1000 then
- LogMessage "Name checking loop aborted after 1000 unsuccessfull attempts, doh!"
- else
- LogMessage "Woohoo, " & oSelName & " was available!"
- end if
- else
- 'Hide the original mesh
- SetValue oSelecto & ".visibility.viewvis", False
- SetValue oSelecto & ".visibility.rendvis", False
- end if
- 'If the selection is in a model and things were renamed earlier..
- if oModelo <> "Scene_Root" and WereRenamed = 1 then
- 'Add the model name back into oClone and oDupe
- oClone = oModelo & "." & oClone
- oDupe = oModelo & "." & oDupe
- end if
- 'Parent SubdCtrl to the modelling mesh
- ParentObj "B:" & oDupe, oSubdCtrl
- set oDupe = Dictionary.GetObject( oDupe, False )
- set oMerge = Dictionary.GetObject( oMerge, False )
- 'Check to see if the merged mesh and the modelling mesh share the same parent object
- if oDupe.Parent <> oMerge.Parent then
- 'If they don't, give the new clone the same parent as the selection
- ParentObj "B:" & oDupe.Parent, oMerge
- end if
- 'Rename things
- oClone = SetValue (oClone & ".Name", oSelName & "-ClonedHalf")
- oMerge = SetValue (oMerge & ".Name", oSelName & "-MergedMesh")
- oSubdCtrl = SetValue (oSubdCtrl & ".Name", oSelName & "-Merged-SubdCtrl")
- oDupe = SetValue (oDupe & ".Name", oSelName & "-Modelling")
- if oExpExist = "yes" then
- LogMessage "SRT expressions were removed from " & oDupe
- end if
- LogMessage oDupe & ", " & oClone & ", " & oMerge & ", and " & oSubdCtrl & " were created, happy days :)"
- 'Each time I rename something it loses it's model name..
- if oModelo <> "Scene_Root" then
- oDupe = oModelo & "." & oDupe
- end if
- 'Add the -Modelling object to the oFinalSelect collection
- oFinalSelect.Add oDupe
- end if
- end if
- Next
- 'Select all the objects in the oFinalSelect collection
- SelectObj oFinalSelect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement