Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '-----------------------------------------------------------------------------------------------------------------'
- 'This will scale the selected components (edges/vertices/polys) to 0 on the object's x axis, and move the new 'MoveComponent Op into the animation stack.
- 'If there is already a movecomponentop in place the script will ask you if you want to freeze the object, if you 'select no, it will count how many move operators exist and then ask if you want to delete the highest one found, 'click yes if you have only one movecomponentop op in either the shape modelling or animation stacks, or click no 'if the existing movecomponentops are all in the modelling stack. Since xsi renames operators depending where they 'are in the stack, and I have yet to find a way of determining where they are.. sigh, this is the best I could 'come up with for now :P
- 'If you really don't want to freeze anything, you could do this manually by selecting the edges or vertices you 'want then run my Zero X script and move the new movecomponent op manually (drag and drop) into the animation 'stack.
- '-----------------------------------------------------------------------------------------------------------------'
- dim oSel, oSelecto, ScriptCancel, oMCobj, BP, pref, MCstr, MoveComponentCount, StopLoop, JustIncaseAbort
- dim oSelHack, oSelName
- set oSel = application.selection(0)
- 'Set up a regExp for later use
- set regEx = New RegExp
- 'Reset ScriptCancel
- ScriptCancel = "no"
- 'Check if the selection is a subcomponent and use a silly hack to get the full name (including model name) of the object.. since I couldnt find a normal way to do it :P
- if oSel.Type = "polySubComponent" then
- 'Replace poly[ in the name of the selection with something I can find in regex
- oSelHack = replace (osel, "poly[", "IsuckAtRegex")
- 'Set a regex pattern to find everything up to (and annoyingly including) the "IsuckAtRegex" part I just added
- regEx.Pattern = "^.*IsuckAtRegex"
- Set Matches = regEx.Execute(oSelHack)
- For Each Match in Matches
- oSelName = Match.Value
- Next
- 'Get rid of ".IsuckAtRegex" to get the final output I want
- oSelName = replace( oSelName, ".IsuckAtRegex", "")
- set oSelecto = Dictionary.GetObject( oSelName, false )
- LogMessage "poly subcomponent of " & oSelecto & " detected"
- elseif oSel.Type = "pntSubComponent" then
- oSelHack = replace (osel, "pnt[", "IsuckAtRegex")
- regEx.Pattern = "^.*IsuckAtRegex"
- Set Matches = regEx.Execute(oSelHack)
- For Each Match in Matches
- oSelName = Match.Value
- Next
- oSelName = replace( oSelName, ".IsuckAtRegex", "")
- set oSelecto = Dictionary.GetObject( oSelName, false )
- LogMessage "point subcomponent of " & oSelecto & " detected"
- elseif oSel.Type = "edgeSubComponent" then
- oSelHack = replace (osel, "edge[", "IsuckAtRegex")
- regEx.Pattern = "^.*IsuckAtRegex"
- Set Matches = regEx.Execute(oSelHack)
- For Each Match in Matches
- oSelName = Match.Value
- Next
- oSelName = replace( oSelName, ".IsuckAtRegex", "")
- set oSelecto = Dictionary.GetObject( oSelName, false )
- LogMessage "edge subcomponent of " & oSelecto & " detected"
- else
- LogMessage "No components selected - Script Cancelled"
- XSIUIToolkit.Msgbox "No components selected - You need to select the components you want scaled to 0 on the object's X axis, then run this again", 1, "No Components Detected"
- ScriptCancel = "yes"
- end if
- 'Check if a MoveComponent op already exists
- MCstr = ".polymsh.movecomponentop"
- set oMCobj = Dictionary.GetObject( MCstr, false )
- if TypeName( oMCobj ) <> "Nothing" and ScriptCancel = "no" then
- BP = XSIUIToolkit.Msgbox( "Do you want to freeze " & oSelecto & " ? : If there is more than one movecomponent op in either the Shape Modelling or Animation stacks then this won't work (clicking no will determine how many move component ops there are, then ask if you want to delete the highest one)", 3, "Move Component Ops Detected, Freeze " & oselecto & "?" )
- if BP = 6 then
- LogMessage "Freezing Object"
- FreezeObj oSelecto
- elseIf BP = 7 then
- LogMessage "Move Component operator already in place, determining what number the new one will be"
- 'Reset some variables
- JustIncaseAbort = 0
- MoveComponentCount = 0
- StopLoop = "no"
- '-----------------------------Loop Start-----------------------------'
- do
- 'Add 1 onto the counter that will be used to see how many movecomponent ops exist
- MoveComponentCount = MoveComponentCount + 1
- 'Check to see if a movecomponent op with the count number exists e.g. movecomponentop[15]
- MCstr = oSelecto & ".polymsh.movecomponentop["&MoveComponentCount&"]"
- set oMCobj = Dictionary.GetObject( MCstr, false )
- if TypeName( oMCobj ) = "Nothing" then
- StopLoop = "yes"
- end if
- 'Increment an abort counter to stop an infinite loop
- JustIncaseAbort = JustIncaseAbort + 1
- Loop Until StopLoop = "yes" or JustIncaseAbort = 10000
- '-----------------------------Loop Finish-----------------------------'
- 'If the abort number has been reached then cancel the script
- if JustIncaseAbort = 10000 then
- LogMessage "Either something has gone horribly wrong or you have more than 10,000 move component ops ?? in which case it might be time to freeze the modelling stack :)"
- ScriptCancel = "yes"
- end if
- LogMessage oSelecto & " had " & MoveComponentCount & " movecomponentops"
- if ScriptCancel = "no" then
- BP = XSIUIToolkit.Msgbox( MoveComponentCount & " movemomponent ops were found, is there one (singular) in either the Shape Modelling or Animation stack ? ( clicking yes will delete MoveComponent[" & MoveComponentCount - 1 &"] )", 3, "Move Component Ops Detected" )
- if BP = 6 then
- MoveComponentCount = MoveComponentCount - 1
- DeleteObj oSelecto & ".movecomponentop[" & MoveComponentCount & "]"
- MCstr = oSelecto & ".polymsh.movecomponentop[" & MoveComponentCount & "]"
- LogMessage oSelecto & ".polymsh.movecomponentop[" & MoveComponentCount & "] was deleted"
- elseIf BP = 2 then
- LogMessage "Cancelling Script"
- ScriptCancel = "yes"
- end if
- end if
- else
- LogMessage "Cancelling Script"
- ScriptCancel = "yes"
- end if
- else
- MCstr = oSelecto & ".polymsh.movecomponentop"
- end if
- if ScriptCancel = "no" then
- 'Get the status of proportional modelling setting
- pref = GetUserPref ("3D_TRANSFO_PROPORTIONAL_CHANGED")
- 'If proportional modelling was enabled, turn it off
- if pref = 1 then
- SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 0
- end if
- 'Scale the selected components to 0 on the x axis and move the op to the animation stack
- Scale , 0, 1, 1, siRelative, siParent, siObj, siX, , , , , , , , 0
- MoveOperatorAfter oSelecto & ".polymsh", MCstr, oSelecto & ".polymsh.shapemarker"
- 'If proportional modelling was previously enabled, turn it back on
- if pref = 1 then
- SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 1
- end if
- LogMessage "Selected components were scaled to 0 on the x axis, the operation should have been moved to the animation stack"
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement