Advertisement
spookymunky

SymmThings 2.0 - Add To CL Cluster (VBS)

Mar 25th, 2013
162
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 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.
  3. '-----------------------------------------------------------------------------------------------------------------'
  4.  
  5. dim oSel, oSelecto, ScriptCancel, CLstr, CLobj, BP, pref, oSelHack, oSelName
  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 some components that you want to add to the CL cluster", 1, "No Components Detected"
  63.     ScriptCancel = "yes"
  64.    
  65. end if
  66.  
  67. 'Define the CL cluster
  68. CLstr = oSelecto & ".polymsh.cls.CL"
  69. set CLObj = Dictionary.GetObject( CLstr, false )
  70.  
  71. 'Check if CL / point / edge cluster exists
  72. if ScriptCancel = "no" and TypeName( CLObj ) = "Nothing" then
  73.    
  74.     XSIUIToolkit.Msgbox "This is meant to be run on objects that have a CL cluster...", 1, "No CL Cluster Found"
  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.         BP = XSIUIToolkit.Msgbox ("CL is a Point Cluster, subComponents selected are Edges", 1, "Component-Cluster Mismatch")
  88.        
  89.             if BP = 1 then
  90.            
  91.                 LogMessage "CL is a Point Cluster, subComponents selected are Edges - Script Cancelled"
  92.                 ScriptCancel = "yes"
  93.                
  94.             else
  95.            
  96.             ScriptCancel = "yes"
  97.            
  98.             end if
  99.            
  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.            
  122.     end if
  123.    
  124. end if
  125.  
  126. if ScriptCancel = "no" then
  127.  
  128.     'Get the status of proportional modelling setting
  129.     pref = GetUserPref ("3D_TRANSFO_PROPORTIONAL_CHANGED")
  130.  
  131.     'If proportional modelling was enabled, turn it off
  132.     if pref = 1 then
  133.         SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 0
  134.     end if
  135.  
  136.     'Scale the selected components to 0 on the x axis
  137.     Scale , 0, 1, 1, siRelative, siParent, siObj, siX, , , , , , , , 0
  138.  
  139.     'Add selection to the CL cluster
  140.     ToggleSelection oSelecto & ".polymsh.cls.CL"
  141.     AddToCluster
  142.     SelectObj oSelecto
  143.  
  144.     'If proportional modelling was previously enabled, turn it back on
  145.     if pref = 1 then
  146.         SetUserPref "3D_TRANSFO_PROPORTIONAL_CHANGED", 1
  147.     end if
  148.  
  149.     LogMessage "Selection was scaled to 0 on the x axis and added to the CL cluster"
  150.  
  151. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement