Advertisement
spookymunky

SymmThings 2.0 - Reset CL Cluster (VBS)

Mar 25th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '-----------------------------------------------------------------------------------------------------------------'
  2. '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 :)
  3. '-----------------------------------------------------------------------------------------------------------------'
  4.  
  5. dim oSel, oSelecto, ScriptCancel, oObj, CLstr, CLObj, oSelName, oSelParent, oSelHack
  6.  
  7. set oSel = application.selection(0)
  8.  
  9. 'Set up a regExp for later use
  10. set regEx = New RegExp
  11.  
  12. 'Reset ScriptCancel
  13. ScriptCancel = "no"
  14.  
  15. '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
  16. if oSel.Type = "polySubComponent" then
  17.  
  18.     'Replace poly[ in the name of the selection with something I can find in regex
  19.     oSelHack = replace (osel, "poly[", "IsuckAtRegex")
  20.    
  21.     'Set a regex pattern to find everything up to (and annoyingly including) the "IsuckAtRegex" part I just added
  22.     regEx.Pattern = "^.*IsuckAtRegex"  
  23.     Set Matches = regEx.Execute(oSelHack)
  24.    
  25.     For Each Match in Matches
  26.         oSelName = Match.Value
  27.     Next
  28.    
  29.     'Get rid of ".IsuckAtRegex" to get the final output I want
  30.     oSelName = replace( oSelName, ".IsuckAtRegex", ""
  31.    
  32.     set oSelecto = Dictionary.GetObject( oSelName, false )
  33.     LogMessage "poly subcomponent of " & oSelecto & " detected"
  34.  
  35. elseif oSel.Type = "pntSubComponent" then
  36.  
  37.     oSelHack = replace (osel, "pnt[", "IsuckAtRegex")
  38.     regEx.Pattern = "^.*IsuckAtRegex"
  39.     Set Matches = regEx.Execute(oSelHack)
  40.     For Each Match in Matches
  41.         oSelName = Match.Value
  42.     Next
  43.     oSelName = replace( oSelName, ".IsuckAtRegex", "")
  44.     set oSelecto = Dictionary.GetObject( oSelName, false )
  45.     LogMessage "point subcomponent of " & oSelecto & " detected"
  46.    
  47. elseif oSel.Type = "edgeSubComponent" then
  48.  
  49.     oSelHack = replace (osel, "edge[", "IsuckAtRegex")
  50.     regEx.Pattern = "^.*IsuckAtRegex"
  51.     Set Matches = regEx.Execute(oSelHack)
  52.     For Each Match in Matches
  53.         oSelName = Match.Value
  54.     Next
  55.     oSelName = replace( oSelName, ".IsuckAtRegex", "")
  56.     set oSelecto = Dictionary.GetObject( oSelName, false )
  57.     LogMessage "edge subcomponent of " & oSelecto & " detected"
  58.    
  59. else
  60.  
  61.     LogMessage "No Components Selected - Script Cancelled"
  62.     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"
  63.     ScriptCancel = "yes"
  64.    
  65. end if
  66.  
  67. 'Check if CL / point / edge cluster exists
  68. CLstr = oSelecto & ".polymsh.cls.CL"
  69. set CLObj = Dictionary.GetObject( CLstr, false )
  70.  
  71. if ScriptCancel = "no" and TypeName( CLObj ) = "Nothing" then
  72.    
  73.     XSIUIToolkit.Msgbox "This is meant to be run on objects that have a CL cluster...", 1, "No CL Cluster Found"
  74.     Logmessage "This script is meant to be used on objects that have a CL cluster used in my other scripts."
  75.     LogMessage "You need to create either an edge / point cluster of the center loop and name it CL - Script Cancelled"
  76.                
  77.     ScriptCancel = "yes"
  78.  
  79. end if
  80.  
  81. if ScriptCancel = "no" then
  82.  
  83.     'Check to see if the selection is an edge and the CL cluster is a point
  84.     if oSel.Type = "edgeSubComponent" and CLObj.Type = "pnt" then
  85.    
  86.         LogMessage "Selection is " & oSel.Type & ", Cl cluster is " & CLObj.Type
  87.        
  88.         BP = XSIUIToolkit.Msgbox ("CL is a Point Cluster, subComponents selected are Edges", 1, "Component-Cluster Mismatch")
  89.        
  90.             if BP = 1 then
  91.            
  92.                 LogMessage "CL is a Point Cluster, subComponents selected are Edges - Script Cancelled"
  93.                 ScriptCancel = "yes"
  94.                
  95.             else
  96.            
  97.             ScriptCancel = "yes"
  98.            
  99.             end if
  100.     end if
  101.  
  102. end if
  103.  
  104. if ScriptCancel = "no" then
  105.  
  106.     'Check to see if the selection is vertices and the CL cluster is an edge
  107.     if oSel.Type = "pntSubComponent" and CLObj.Type = "edge" then
  108.    
  109.         BP = XSIUIToolkit.Msgbox ("CL is an Edge Cluster, subComponents selected are Vertices", 1, "Component-Cluster Mismatch")
  110.        
  111.             if BP = 1 then
  112.            
  113.                 LogMessage "CL is an Edge Cluster, subComponents selected are Vertices - Script Cancelled"
  114.                 ScriptCancel = "yes"
  115.                
  116.             else
  117.            
  118.             ScriptCancel = "yes"
  119.            
  120.             end if
  121.     end if
  122.    
  123. end if
  124.  
  125. if ScriptCancel = "no" then
  126.  
  127.     'Get the status of proportional modelling setting
  128.     pref = GetUserPref ("3D_TRANSFO_PROPORTIONAL_CHANGED")
  129.  
  130.     'If proportional modelling was enabled, turn it off
  131.     if pref = 1 then
  132.         SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 0
  133.     end if
  134.  
  135.     'Scale the selected components to 0 on the x axis
  136.     Scale , 0, 1, 1, siRelative, siParent, siObj, siX, , , , , , , , 0
  137.  
  138.     'Invert the selection and remove it from the CL cluster
  139.     InvertSelection , siCheckComponentVisibility
  140.     ToggleSelection oSelecto & ".polymsh.cls.CL"
  141.     RemoveFromCluster
  142.     SelectObj oSelecto
  143.    
  144.     'Add the selected components to the CL cluster
  145.     AddToCluster oSelecto&".polymsh.cls.CL, " & oSel & ""
  146.  
  147.     'If proportional modelling was previously enabled, turn it back on
  148.     if pref = 1 then
  149.         SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 1
  150.     end if
  151.  
  152.     LogMessage "Selected components were scaled to 0 on the x axis and added to the CL cluster"
  153.     LogMessage "Unselected components were removed from the CL cluster"
  154.  
  155. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement