Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '-----------------------------------------------------------------------------------------------------------------'
- 'Select the components (vertices if CL is a point cluster, edges if it's edge) you want to keep or add to the CL 'cluster and run this. It will scale the selected components to 0 on the objects x axis, add them to the CL 'cluster, then invert the selection and remove those from the CL cluster. In other words select what you want to 'keep, anything else will be removed :)
- '-----------------------------------------------------------------------------------------------------------------'
- dim oSel, oSelecto, ScriptCancel, oObj, CLstr, CLObj, oSelName, oSelParent, oSelHack
- 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 "You need to select the components you want to keep or add to the CL cluster: Unselected components will be removed from it", 1, "No Components Detected"
- ScriptCancel = "yes"
- end if
- 'Check if CL / point / edge cluster exists
- CLstr = oSelecto & ".polymsh.cls.CL"
- set CLObj = Dictionary.GetObject( CLstr, false )
- if ScriptCancel = "no" and TypeName( CLObj ) = "Nothing" then
- XSIUIToolkit.Msgbox "This is meant to be run on objects that have a CL cluster...", 1, "No CL Cluster Found"
- Logmessage "This script is meant to be used on objects that have a CL cluster used in my other scripts."
- LogMessage "You need to create either an edge / point cluster of the center loop and name it CL - Script Cancelled"
- ScriptCancel = "yes"
- end if
- if ScriptCancel = "no" then
- 'Check to see if the selection is an edge and the CL cluster is a point
- if oSel.Type = "edgeSubComponent" and CLObj.Type = "pnt" then
- LogMessage "Selection is " & oSel.Type & ", Cl cluster is " & CLObj.Type
- BP = XSIUIToolkit.Msgbox ("CL is a Point Cluster, subComponents selected are Edges", 1, "Component-Cluster Mismatch")
- if BP = 1 then
- LogMessage "CL is a Point Cluster, subComponents selected are Edges - Script Cancelled"
- ScriptCancel = "yes"
- else
- ScriptCancel = "yes"
- end if
- end if
- end if
- if ScriptCancel = "no" then
- 'Check to see if the selection is vertices and the CL cluster is an edge
- if oSel.Type = "pntSubComponent" and CLObj.Type = "edge" then
- BP = XSIUIToolkit.Msgbox ("CL is an Edge Cluster, subComponents selected are Vertices", 1, "Component-Cluster Mismatch")
- if BP = 1 then
- LogMessage "CL is an Edge Cluster, subComponents selected are Vertices - Script Cancelled"
- ScriptCancel = "yes"
- else
- ScriptCancel = "yes"
- end if
- end if
- 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
- Scale , 0, 1, 1, siRelative, siParent, siObj, siX, , , , , , , , 0
- 'Invert the selection and remove it from the CL cluster
- InvertSelection , siCheckComponentVisibility
- ToggleSelection oSelecto & ".polymsh.cls.CL"
- RemoveFromCluster
- SelectObj oSelecto
- 'Add the selected components to the CL cluster
- AddToCluster oSelecto&".polymsh.cls.CL, " & oSel & ""
- '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 and added to the CL cluster"
- LogMessage "Unselected components were removed from the CL cluster"
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement