Advertisement
spookymunky

SymmThings 2.0 - Create ShrinkCenter (VBS)

Mar 25th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '-----------------------------------------------------------------------------------------------------------------'
  2. 'Creates a Grid (*-ShrinkCenter) for each object in the selection to be used with my shrinkwrap script, then pose 'constrains it to it's object with an offset of -90 on the Z rotation axis and makes it a child of the same object 'to keep things tidy.
  3. '-----------------------------------------------------------------------------------------------------------------'
  4.  
  5. dim oCol, oSelection, oSelecto, oModelo, oSelName, oShrinky, oSubdCtrlCheck
  6.  
  7. 'Set up a regExp for later use
  8. set regEx = New RegExp
  9.  
  10. 'Define a collection(oCol) for adding objects to
  11. Set oCol = CreateObject( "XSI.Collection" )
  12.  
  13. 'Check if an object is selected
  14. if Application.Selection.count > 1 Then
  15.  
  16.     'Add the application selection to oCol
  17.     Set oSelection = Application.Selection
  18.    
  19.     for i = 0 to (oSelection.Count - 1)
  20.    
  21.         'Set a new Regex pattern that finds any letters after - at the end of its name
  22.         regEx.Pattern = "-[a-zA-Z]+$"
  23.            
  24.         'Reset oSubdCtrlCheck
  25.         oSubdCtrlCheck = "Nothing"
  26.            
  27.         'Execute the regex on the selection
  28.         Set Matches = regEx.Execute(oSelection(i))
  29.         For Each Match in Matches
  30.             oSubdCtrlCheck = Match.Value
  31.         Next
  32.            
  33.         'If the selection doesnt end in -SubdCtrl then add it to the oCol Collection.
  34.         if oSubdCtrlCheck <> "-SubdCtrl" then
  35.            
  36.             Logmessage oSelection(i) & " winked at me!, added to oCol"
  37.             oCol.add oSelection(i)
  38.                
  39.         else
  40.            
  41.             Logmessage oSelection(i) & " thinks I'm ugly :(, rejected"
  42.                
  43.         end if
  44.        
  45.     next   
  46.  
  47. elseIf Application.Selection.count = 1 Then
  48.  
  49.     oCol.add Application.Selection(0)
  50.        
  51. else   
  52.  
  53.     'If no object is selected, start a picksession
  54.     LogMessage "Select The Control Mesh (-Modelling)"
  55.     PickObject "Select The Control Mesh (-Modelling)", " ", oSelecto
  56.    
  57.     'Add Picksession object to oCol
  58.     oCol.add oSelecto
  59.    
  60. end if
  61.  
  62. for i = 0 to (oCol.count-1)
  63.     set oSelecto = oCol(i)
  64.  
  65.     'Remove Model name from oSelecto
  66.     oModelo = oSelecto.Model
  67.     oSelName = replace( oSelecto, oModelo&".", "")
  68.    
  69.     'Create a new grid to be used as a shrinkwrap target
  70.     Preferences.SetPreferenceValue "Interaction.autoinspect", false
  71.     set oShrinky = CreatePrim ("Grid", "MeshSurface", oSelName & "-ShrinkCenter")
  72.     Preferences.SetPreferenceValue "Interaction.autoinspect", true
  73.    
  74.     'Pose constrain the shrink center to original object
  75.     ApplyCns "Pose", oShrinky, oSelecto
  76.    
  77.     'Adjust the shrink center's pose constrain scale to 50x on all axis, and -90deg on z rotation axis
  78.     SetValue oShrinky & ".kine.posecns.sclx", 50
  79.     SetValue oShrinky & ".kine.posecns.scly", 50
  80.     SetValue oShrinky & ".kine.posecns.sclz", 50
  81.     SetValue oShrinky & ".kine.posecns.rotz", -90
  82.  
  83.     'Disable all of the shrink center's visibility options
  84.     SetValue oShrinky & ".visibility.shdwcast", False
  85.     SetValue oShrinky & ".visibility.shdwrecv", False
  86.     SetValue oShrinky & ".visibility.primray", False
  87.     SetValue oShrinky & ".visibility.scndray", False
  88.     SetValue oShrinky & ".visibility.trnscast", False
  89.     SetValue oShrinky & ".visibility.trnsvis", False
  90.     SetValue oShrinky & ".visibility.causvis", False
  91.     SetValue oShrinky & ".visibility.globcast", False
  92.     SetValue oShrinky & ".visibility.globvis", False
  93.     SetValue oShrinky & ".visibility.viewvis", False
  94.     SetValue oShrinky & ".visibility.rendvis", False
  95.    
  96.     ParentObj "B:" & oSelecto, oShrinky
  97.        
  98.     LogMessage "Created " & oShrinky
  99.    
  100. next
  101.  
  102. SelectObj oCol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement