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 add to the CL cluster 'and run this, it will scale the selected components to 0 on the objects x axis and add them to the CL cluster.
- '-----------------------------------------------------------------------------------------------------------------'
- dim oSel, oSelecto, ScriptCancel, CLstr, CLobj, BP, pref, 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 "You need to select some components that you want to add to the CL cluster", 1, "No Components Detected"
- ScriptCancel = "yes"
- end if
- 'Define the CL cluster
- CLstr = oSelecto & ".polymsh.cls.CL"
- set CLObj = Dictionary.GetObject( CLstr, false )
- 'Check if CL / point / edge cluster exists
- 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 "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
- 'Add selection to the CL cluster
- ToggleSelection oSelecto & ".polymsh.cls.CL"
- AddToCluster
- SelectObj oSelecto
- 'If proportional modelling was previously enabled, turn it back on
- if pref = 1 then
- SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 1
- end if
- LogMessage "Selection was scaled to 0 on the x axis and added to the CL cluster"
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement