home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 April / maximum-cd-2002-04.iso / Software / Apps / gmax / gmaxinst.exe / gmaxsetup11.cab / Macro_Constraints.mcr < prev    next >
Encoding:
Text File  |  2001-09-12  |  36.1 KB  |  946 lines

  1. -- Easy Constraint Assignment MacroScript File
  2. --
  3. -- Created:          April 7 2000
  4. -- Last Updated:     January 2 2001
  5. --
  6. -- Author :   Frank DeLise
  7. -- Version:  3ds max 4
  8. --
  9. -- Constraint tools
  10. -- This script increases workflow on assigning constraints by adding a list controller automatically.
  11. --***********************************************************************************************
  12. -- MODIFY THIS AT YOUR OWN RISK
  13.  
  14. -- Aug 15 added prompting
  15. -- Aug 20 added LinkConstraint
  16. -- Nov 6  added "H" key support ForceListenerFocus
  17. -- Dec 14 Added Biped Support  
  18. -- Dec 18 Fixed LookAt, Orientation and Noise Rotation constraints - passing wrong channel to AddConstraint
  19. -- Jan 4  Added support for HI IK and HD IK objects; Added group support
  20.  
  21. MacroScript Path
  22.  
  23.     ButtonText:"Path Constraint"
  24.     Category:"Constraints" 
  25.     internalCategory:"Constraints" 
  26.     Tooltip:"Path Constraint" 
  27.     SilentErrors:(Debug != false)
  28.  
  29. (
  30.     Global EC_OBJ, EC_TargetOBJ = "None"
  31.     
  32.     -- Check to see if something is selected
  33.         
  34.     on isEnabled return (selection.count != 0 and
  35.                          classof selection[1].controller != BipSlave_Control and
  36.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[1].controller != undefined) and
  37.                          (    selection.count == 1 or 
  38.                             selection.count > 1 and
  39.                             (
  40.                                 local h = selection[1].parent 
  41.                                 h != undefined and h.isSelected and isGroupHead h
  42.                             )
  43.                          )
  44.                         )
  45.      
  46.     on execute do 
  47.     (
  48.         Try
  49.         (
  50.             -------------------------------------------------------------------------------------------
  51.             -- Switch to Motion Panel
  52.             -------------------------------------------------------------------------------------------
  53.         
  54.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  55.             
  56.             -------------------------------------------------------------------------------------------
  57.             -- Check for Groups and act accordingly
  58.             -------------------------------------------------------------------------------------------
  59.             
  60.             EC_OBJ = selection[1]
  61.             if selection.count > 1 do 
  62.             (
  63.                 local h = EC_OBJ.parent 
  64.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  65.             )
  66.             
  67.             -------------------------------------------------------------------------------------------
  68.             -- Define Filter Function for PickObject Selection
  69.             -------------------------------------------------------------------------------------------
  70.             
  71.             fn ShapeFilt o = superClassOf o == Shape and o != EC_OBJ
  72.             
  73.             -------------------------------------------------------------------------------------------
  74.                     
  75.             --Format "%\n" ("Pick Shape to Constrain " + EC_OBJ.name + " to:") to:Listener
  76.             
  77.             EC_TargetOBJ = PickObject count:1 select:true filter:ShapeFilt message:"Pick Shape to Constrain to.." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  78.  
  79.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  80.             (
  81.                 -------------------------------------------------------------------------------------------
  82.                 -- Add List Controller
  83.                 -------------------------------------------------------------------------------------------
  84.                 
  85.                 local cont = AddListController EC_OBJ "Pos" Position_List
  86.                 
  87.                 -------------------------------------------------------------------------------------------
  88.                 -- Add Constraint
  89.                 -------------------------------------------------------------------------------------------
  90.                 If classof cont[listCtrl.GetActive cont].object != Path then constraint = AddConstraint EC_OBJ "Pos" Path true
  91.                 else constraint = cont[listCtrl.GetActive cont].object
  92.         
  93.                 -------------------------------------------------------------------------------------------
  94.                 -- Add Position Constraint Objects
  95.                 -------------------------------------------------------------------------------------------
  96.                         
  97.                 constraint.AppendTarget EC_TargetOBJ 50
  98.         
  99.                 -------------------------------------------------------------------------------------------
  100.                 -- Set Active Controller
  101.                 -------------------------------------------------------------------------------------------
  102.                         
  103.                 SetActiveController cont constraint
  104.                             
  105.                 --Format "%\n"  (EC_OBJ.name + " is Path Constrained to " + EC_TargetOBJ.name) to:Listener
  106.                 
  107.                 -------------------------------------------------------------------------------------------            
  108.                 Select EC_OBJ
  109.             )    
  110.         )
  111.         Catch (MessageBox "Path Constraint Not Completed" Title:"Constraints")
  112.     )    
  113. )
  114.  
  115.  
  116. MacroScript LinkConstraint
  117.  
  118.     ButtonText:"Link Constraint"
  119.     Category:"Constraints" 
  120.     internalCategory:"Constraints" 
  121.     Tooltip:"Link Constraint" 
  122.     SilentErrors:(Debug != True)
  123.     
  124.     (
  125.     Global EC_OBJ, EC_TargetOBJ = "None"
  126.  
  127.         
  128.     -- Check to see if something is selected
  129.         
  130.     on isEnabled return (selection.count != 0 and
  131.                          classof selection[1].controller != BipSlave_Control and
  132.                          (classof selection[1].controller != IK_ControllerMatrix3Controller) and
  133.                          (    selection.count == 1 or 
  134.                             selection.count > 1 and
  135.                             (
  136.                                 local h = selection[1].parent 
  137.                                 h != undefined and h.isSelected and isGroupHead h
  138.                             )
  139.                          )
  140.                         )
  141.      
  142.     on execute do 
  143.     (
  144.         Try 
  145.         (
  146.             -------------------------------------------------------------------------------------------
  147.             -- Switch to Motion Panel
  148.             -------------------------------------------------------------------------------------------
  149.         
  150.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  151.             
  152.             -------------------------------------------------------------------------------------------
  153.             -- Check for Groups and act accordingly
  154.             -------------------------------------------------------------------------------------------
  155.             
  156.             EC_OBJ = selection[1]
  157.             if selection.count > 1 do 
  158.             (
  159.                 local h = EC_OBJ.parent 
  160.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  161.             )
  162.             
  163.             -------------------------------------------------------------------------------------------
  164.             -- Define Filter Function for PickObject Selection
  165.             -------------------------------------------------------------------------------------------
  166.             
  167.             fn SameFilt o = o != EC_OBJ
  168.             -------------------------------------------------------------------------------------------
  169.             
  170.             --Format "%\n" ("Pick Object to Link " + EC_OBJ.name + " to:") to:Listener
  171.             
  172.             -------------------------------------------------------------------------------------------
  173.             -- Pick Target Object
  174.             -------------------------------------------------------------------------------------------
  175.                     
  176.             EC_TargetOBJ = PickObject count:1 select:true Filter:SameFilt message:"Pick Object to Link to.." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  177.  
  178.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  179.             (
  180.                 ---------------------------------------------------------------------------------------
  181.                 -- Add Constraint 
  182.                 -- If it's not a link constraint already, check for IK object and IK goal object
  183.                 ---------------------------------------------------------------------------------------    
  184.                 local constraint
  185.                 if Classof EC_OBJ.controller == IKControl then (constraint = EC_OBJ.Transform.controller.fk_sub_control.controller)
  186.                     else if Classof EC_OBJ.controller == IKChainControl then (constraint = EC_OBJ.Transform.controller.ik_goal.controller)    
  187.                         else (constraint = EC_OBJ.Transform.controller)
  188.                 If Classof constraint != Link_Constraint do 
  189.                 (
  190.                     constraint = Link_Constraint ()
  191.                     if Classof EC_OBJ.controller == IKControl then (EC_OBJ.Transform.controller.fk_sub_control.controller = constraint)
  192.                         else if Classof EC_OBJ.controller == IKChainControl then (EC_OBJ.Transform.controller.ik_goal.controller = constraint)    
  193.                             else (EC_OBJ.Transform.controller = constraint)
  194.                 )
  195.                 
  196.                 ---------------------------------------------------------------------------------------
  197.                 -- Add Links to Link Constraint
  198.                 ---------------------------------------------------------------------------------------
  199.                         
  200.                 if Classof EC_OBJ.controller == IKControl then EC_OBJ.controller.fk_sub_control.controller.AddTarget EC_TargetOBJ SliderTime
  201.                     else if Classof EC_OBJ.controller == IKChainControl then EC_OBJ.controller.ik_goal.controller.AddTarget EC_TargetOBJ SliderTime    
  202.                         else  EC_OBJ.Transform.controller.AddTarget EC_TargetOBJ SliderTime
  203.                 
  204.                 Select EC_OBJ        
  205.             )
  206.         )    
  207.         Catch (MessageBox "Link Constraint Not Completed" Title:"Constraints")
  208.     )
  209. )
  210.  
  211.  
  212. MacroScript Position_Constraint
  213.  
  214.     ButtonText:"Position Constraint"
  215.     Category:"Constraints" 
  216.     internalCategory:"Constraints" 
  217.     Tooltip:"Position Constraint" 
  218.     SilentErrors:(Debug != True)
  219.  
  220. (
  221.     Global EC_OBJ, EC_TargetOBJ = "None" 
  222.         
  223.     -- Check to see if something is selected
  224.         
  225.     on isEnabled return (selection.count != 0 and
  226.                          classof selection[1].controller != BipSlave_Control and
  227.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[1].controller != undefined) and
  228.                          (    selection.count == 1 or 
  229.                             selection.count > 1 and
  230.                             (
  231.                                 local h = selection[1].parent 
  232.                                 h != undefined and h.isSelected and isGroupHead h
  233.                             )
  234.                          )
  235.                         )
  236.      
  237.     on execute do 
  238.     (
  239.         Try 
  240.         (
  241.             -------------------------------------------------------------------------------------------
  242.             -- Switch to Motion Panel
  243.             -------------------------------------------------------------------------------------------
  244.         
  245.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  246.             
  247.             -------------------------------------------------------------------------------------------
  248.             -- Check for Groups and act accordingly
  249.             -------------------------------------------------------------------------------------------
  250.             
  251.             EC_OBJ = selection[1]
  252.             if selection.count > 1 do 
  253.             (
  254.                 local h = EC_OBJ.parent 
  255.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  256.             )
  257.             
  258.             -------------------------------------------------------------------------------------------
  259.             -- Define Filter Function for PickObject Selection
  260.             -------------------------------------------------------------------------------------------
  261.             
  262.             fn SameFilt o = o != EC_OBJ
  263.             
  264.             -------------------------------------------------------------------------------------------
  265.             
  266.             --Format "%\n" ("Pick Object to Constrain " + EC_OBJ.name + " to:") to:Listener
  267.             
  268.             -------------------------------------------------------------------------------------------
  269.             -- Pick Target Object
  270.             -------------------------------------------------------------------------------------------
  271.         
  272.             EC_TargetOBJ = PickObject count:1 select:true Filter:SameFilt message:"Pick Object to Constraint to..." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  273.         
  274.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  275.             (
  276.                 -------------------------------------------------------------------------------------------
  277.                 -- Add List Controller
  278.                 -------------------------------------------------------------------------------------------
  279.                 
  280.                 local cont = AddListController EC_OBJ "Pos" Position_List
  281.                 print cont
  282.  
  283.                 -------------------------------------------------------------------------------------------
  284.                 -- Add Constraint
  285.                 ---------------------------------------------------------------------------------------
  286.                 If classof cont[listCtrl.GetActive cont].object != Position_Constraint then constraint = AddConstraint EC_OBJ "Pos" Position_Constraint true
  287.                 else constraint = cont[listCtrl.GetActive cont].object
  288.                 -------------------------------------------------------------------------------------------
  289.                 -- Add Position Constraint Objects
  290.                 -------------------------------------------------------------------------------------------
  291.                 constraint.AppendTarget EC_TargetOBJ 50
  292.                 -------------------------------------------------------------------------------------------
  293.                 -- Set Active Controller
  294.                 -------------------------------------------------------------------------------------------
  295.                         
  296.                 SetActiveController cont constraint
  297.                             
  298.                 --Format "%\n"  (EC_OBJ.name + " is Constrained to " + EC_TargetOBJ.name) to:Listener
  299.             
  300.                 -------------------------------------------------------------------------------------------
  301.                 Select EC_OBJ        
  302.             )    
  303.         )
  304.         Catch messagebox "Position Constraint Not Completed!"
  305.     )
  306. )
  307.  
  308.  
  309. MacroScript Orientation_Constraint
  310.  
  311.     ButtonText:"Orientation Constraint"
  312.     Category:"Constraints" 
  313.     internalCategory:"Constraints" 
  314.     Tooltip:"Orientation Constraint" 
  315.     SilentErrors:(Debug != True)
  316.     -- Icon Needed Icon:#("NURBScurve",1)
  317.  
  318. (
  319.     Local ConstraintCompleted = False
  320.     Global EC_OBJ, EC_TargetOBJ = "None"
  321.     
  322.     -- Check to see if something is selected
  323.         
  324.     on isEnabled return (selection.count != 0 and
  325.                          classof selection[1].controller != BipSlave_Control and
  326.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[2].controller != undefined) and
  327.                          (    selection.count == 1 or 
  328.                             selection.count > 1 and
  329.                             (
  330.                                 local h = selection[1].parent 
  331.                                 h != undefined and h.isSelected and isGroupHead h
  332.                             )
  333.                          )
  334.                         )
  335.      
  336.     on execute do 
  337.     (
  338.         Try 
  339.         (
  340.     
  341.             -------------------------------------------------------------------------------------------
  342.             -- Switch to Motion Panel
  343.             -------------------------------------------------------------------------------------------
  344.         
  345.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  346.             
  347.             -------------------------------------------------------------------------------------------
  348.             -- Check for Groups and act accordingly
  349.             -------------------------------------------------------------------------------------------
  350.             
  351.             EC_OBJ = selection[1]
  352.             if selection.count > 1 do 
  353.             (
  354.                 local h = EC_OBJ.parent 
  355.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  356.             )
  357.             
  358.             -------------------------------------------------------------------------------------------
  359.             -- Define Filter Function for PickObject Selection
  360.             -------------------------------------------------------------------------------------------
  361.             
  362.             fn SameFilt o = o != EC_OBJ
  363.             
  364.             -------------------------------------------------------------------------------------------
  365.             
  366.             --Format "%\n" ("Pick Object to Constrain " + EC_OBJ.name + " to:") to:Listener
  367.             
  368.             EC_TargetOBJ = PickObject count:1 select:true filter:SameFilt message:"Pick Object to Constrain to..." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  369.  
  370.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  371.             (
  372.                 -------------------------------------------------------------------------------------------
  373.                 -- Add List Controller
  374.                 -------------------------------------------------------------------------------------------
  375.                 
  376.                 local cont = AddListController EC_OBJ "Rotation" Rotation_List
  377.                 
  378.                 -------------------------------------------------------------------------------------------
  379.                 -- Add Constraint
  380.                 ---------------------------------------------------------------------------------------
  381.                 If classof cont[listCtrl.GetActive cont].object != Orientation_Constraint then constraint = AddConstraint EC_OBJ "Rotation" Orientation_Constraint true
  382.                     else constraint = cont[listCtrl.GetActive cont].object
  383.  
  384.                 -------------------------------------------------------------------------------------------
  385.                 -- Add Position Constraint Objects
  386.                 -------------------------------------------------------------------------------------------
  387.                         
  388.                 constraint.AppendTarget EC_TargetOBJ 50
  389.         
  390.                 -------------------------------------------------------------------------------------------
  391.                 -- Set Active Controller
  392.                 -------------------------------------------------------------------------------------------
  393.                         
  394.                 SetActiveController cont constraint
  395.         
  396.                 --Format "%\n"  (EC_OBJ.name + " is Constrained to " + EC_TargetOBJ.name) to:Listener
  397.                 
  398.                 -------------------------------------------------------------------------------------------
  399.                 Select EC_OBJ
  400.             )    
  401.         )
  402.         Catch (MessageBox "Orientation Constraint Not Completed" Title:"Constraints")
  403.     )
  404. )
  405.  
  406.  
  407. MacroScript Look_At
  408.  
  409.     ButtonText:"Look-At Constraint"
  410.     Category:"Constraints" 
  411.     internalCategory:"Constraints" 
  412.     Tooltip:"Look-At Constraint"
  413.     SilentErrors:(Debug != True) 
  414.     -- Icon Needed Icon:#("NURBScurve",1)
  415.  
  416. (
  417.     Local ConstraintCompleted = False
  418.     Global EC_OBJ, EC_TargetOBJ = "None"
  419.     
  420.     -- Check to see if something is selected
  421.         
  422.     on isEnabled return (selection.count != 0 and
  423.                          classof selection[1].controller != BipSlave_Control and
  424.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[2].controller != undefined) and
  425.                          (    selection.count == 1 or 
  426.                             selection.count > 1 and
  427.                             (
  428.                                 local h = selection[1].parent 
  429.                                 h != undefined and h.isSelected and isGroupHead h
  430.                             )
  431.                          )
  432.                         )
  433.      
  434.     on execute do 
  435.     (
  436.         Try 
  437.         (
  438.     
  439.             -------------------------------------------------------------------------------------------
  440.             -- Switch to Motion Panel
  441.             -------------------------------------------------------------------------------------------
  442.         
  443.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  444.             
  445.             -------------------------------------------------------------------------------------------
  446.             -- Check for Groups and act accordingly
  447.             -------------------------------------------------------------------------------------------
  448.             
  449.             EC_OBJ = selection[1]
  450.             if selection.count > 1 do 
  451.             (
  452.                 local h = EC_OBJ.parent 
  453.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  454.             )
  455.             
  456.             -------------------------------------------------------------------------------------------
  457.             -- Define Filter Function for PickObject Selection
  458.             -------------------------------------------------------------------------------------------
  459.             
  460.             fn SameFilt o = o != EC_OBJ
  461.             
  462.             -------------------------------------------------------------------------------------------
  463.             
  464.             -- Format "%\n" ("Pick Object to Constrain " + EC_OBJ.name + " to:") to:Listener
  465.     
  466.             -------------------------------------------------------------------------------------------
  467.             -- Pick Target Object
  468.             -------------------------------------------------------------------------------------------
  469.             
  470.             EC_TargetOBJ = PickObject count:1 select:true filter:SameFilt Message:"Pick Object to Look At.." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  471.         
  472.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  473.             (
  474.                 -------------------------------------------------------------------------------------------
  475.                 -- Add List Controller
  476.                 -------------------------------------------------------------------------------------------
  477.                 
  478.                 local cont = AddListController EC_OBJ "Rotation" Rotation_List
  479.                 
  480.                 -------------------------------------------------------------------------------------------
  481.                 -- Add Constraint
  482.                 ---------------------------------------------------------------------------------------
  483.                 
  484.                 If classof cont[listCtrl.GetActive cont].object != LookAt_Constraint then constraint = AddConstraint EC_OBJ "Rotation" LookAt_Constraint true
  485.                     else constraint = cont[listCtrl.GetActive cont].object
  486.                 -------------------------------------------------------------------------------------------
  487.                 -- Add Look At Constraint Objects
  488.                 -------------------------------------------------------------------------------------------
  489.                         
  490.                 constraint.AppendTarget EC_TargetOBJ 50
  491.         
  492.                 -------------------------------------------------------------------------------------------
  493.                 -- Set Active Controller
  494.                 -------------------------------------------------------------------------------------------
  495.                         
  496.                 SetActiveController cont constraint
  497.         
  498.                 -- Format "%\n"  (EC_OBJ.name + " is Constrained to " + EC_TargetOBJ.name) to:Listener
  499.                 
  500.                 -------------------------------------------------------------------------------------------
  501.                 Select EC_OBJ
  502.             )
  503.         )
  504.         Catch (MessageBox "LookAt Constraint Not Completed" Title:"Constraints")
  505.     )
  506. )
  507.  
  508.  
  509. MacroScript Attachment
  510.  
  511.     ButtonText:"Attachment Constraint"
  512.     Category:"Constraints" 
  513.     internalCategory:"Constraints" 
  514.     Tooltip:"Attachment Constraint"
  515.     SilentErrors:(Debug != True) 
  516.     -- Icon Needed Icon:#("NURBScurve",1)
  517.  
  518. (
  519.     Global EC_OBJ, EC_TargetOBJ = "None"
  520.     
  521.     -- Check to see if something is selected
  522.     on isEnabled return (selection.count != 0 and
  523.                          classof selection[1].controller != BipSlave_Control and
  524.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[1].controller != undefined) and
  525.                          (    selection.count == 1 or 
  526.                             selection.count > 1 and
  527.                             (
  528.                                 local h = selection[1].parent 
  529.                                 h != undefined and h.isSelected and isGroupHead h
  530.                             )
  531.                          )
  532.                         )
  533.  
  534.     on execute do 
  535.     (
  536.         Try
  537.         (
  538.             -------------------------------------------------------------------------------------------
  539.             -- Switch to Motion Panel
  540.             -------------------------------------------------------------------------------------------
  541.         
  542.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  543.             
  544.             -------------------------------------------------------------------------------------------
  545.             -- Check for Groups and act accordingly
  546.             -------------------------------------------------------------------------------------------
  547.             
  548.             EC_OBJ = selection[1]
  549.             if selection.count > 1 do 
  550.             (
  551.                 local h = EC_OBJ.parent 
  552.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  553.             )
  554.             
  555.             -------------------------------------------------------------------------------------------
  556.             -- Define Filter Function for PickObject Selection
  557.             -------------------------------------------------------------------------------------------
  558.             
  559.             fn GeomFilt o = superClassOf o == GeometryClass and o != EC_OBJ
  560.             
  561.             -------------------------------------------------------------------------------------------
  562.                     
  563.             --Format "%\n" ("Pick Object to Attach " + EC_OBJ.name + " to:") to:Listener
  564.             
  565.             EC_TargetOBJ = PickObject count:1 select:true filter:GeomFilt message:"Pick Object to Attach to.." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  566.         
  567.             If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  568.             (
  569.         
  570.                 -------------------------------------------------------------------------------------------
  571.                 -- Add List Controller
  572.                 -------------------------------------------------------------------------------------------
  573.                 
  574.                 local cont = AddListController EC_OBJ "Pos" Position_List
  575.                 
  576.                 -------------------------------------------------------------------------------------------
  577.                 -- Add Constraint
  578.                 -------------------------------------------------------------------------------------------
  579.                 If classof cont[listCtrl.GetActive cont].object != Attachment then constraint = AddConstraint EC_OBJ "Pos" Attachment true
  580.                     else constraint = cont[listCtrl.GetActive cont].object
  581.  
  582.                 -------------------------------------------------------------------------------------------
  583.                 -- Set Node Attached To, initial key
  584.                 -------------------------------------------------------------------------------------------
  585.                         
  586.                 constraint.Node = EC_TargetOBJ
  587.                 local key = AttachCtrl.addnewkey constraint 0
  588.                 key.face=1
  589.         
  590.                 -------------------------------------------------------------------------------------------
  591.                 -- Set Active Controller
  592.                 -------------------------------------------------------------------------------------------
  593.                         
  594.                 SetActiveController cont constraint
  595.                                                         
  596.                 --Format "%\n"  (EC_OBJ.name + " is Attached to " + EC_TargetOBJ.name) to:Listener
  597.                 
  598.                 -------------------------------------------------------------------------------------------
  599.                         
  600.                 Select EC_OBJ
  601.                 
  602.             )
  603.         )
  604.         Catch (MessageBox "Attachment Constraint Not Completed" Title:"Constraints")
  605.     )
  606. )
  607.  
  608.  
  609. MacroScript Surface
  610.  
  611.     ButtonText:"Surface Constraint"
  612.     Category:"Constraints" 
  613.     internalCategory:"Constraints" 
  614.     Tooltip:"Surface Constraint"
  615.     SilentErrors:(Debug != True) 
  616.     -- Icon Needed Icon:#("NURBScurve",1)
  617.  
  618. (
  619.     Local ConstraintCompleted = False
  620.     Global EC_OBJ, EC_TargetOBJ = "None"
  621.     
  622.     -- Check to see if something is selected
  623.     on isEnabled return (selection.count != 0 and
  624.                          classof selection[1].controller != BipSlave_Control and
  625.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[1].controller != undefined) and
  626.                          (    selection.count == 1 or 
  627.                             selection.count > 1 and
  628.                             (
  629.                                 local h = selection[1].parent 
  630.                                 h != undefined and h.isSelected and isGroupHead h
  631.                             )
  632.                          )
  633.                         )
  634.  
  635.     on execute do 
  636.     (
  637.         Undo on
  638.         (
  639.             Try 
  640.             (
  641.                 -------------------------------------------------------------------------------------------
  642.                 -- Switch to Motion Panel
  643.                 -------------------------------------------------------------------------------------------
  644.             
  645.                 IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  646.                 
  647.                 -------------------------------------------------------------------------------------------
  648.                 -- Check for Groups and act accordingly
  649.                 -------------------------------------------------------------------------------------------
  650.             
  651.                 EC_OBJ = selection[1]
  652.                 if selection.count > 1 do 
  653.                 (
  654.                     local h = EC_OBJ.parent 
  655.                     if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  656.                 )
  657.                 
  658.                 -------------------------------------------------------------------------------------------
  659.                 -- Define Filter Function for PickObject Selection
  660.                 -------------------------------------------------------------------------------------------
  661.                 
  662.                 fn GeomFilt o = (o != EC_OBJ and
  663.                                  (    oclass = ClassOf o
  664.                                      oclass == NURBSSurf or 
  665.                                      oclass == Editable_Patch or 
  666.                                      oclass == Sphere or 
  667.                                      oclass == Cone or 
  668.                                      oclass == Cylinder or 
  669.                                      oclass == Torus or 
  670.                                      oclass == Loft
  671.                                  )
  672.                                 )
  673.                 
  674.                 -------------------------------------------------------------------------------------------
  675.                         
  676.                 --Format "%\n" ("Pick NURBS Surface to Attach " + EC_OBJ.name + " to:") to:Listener
  677.                 
  678.                 EC_TargetOBJ = PickObject count:1 select:true filter:GeomFilt message:"Pick Surface to Attach to.." Rubberband:EC_OBJ.transform.pos ForceListenerFocus:False
  679.             
  680.                 If EC_TargetOBJ != undefined and EC_TargetOBJ != "None" then
  681.                 (
  682.             
  683.                     -------------------------------------------------------------------------------------------
  684.                     -- Add List Controller
  685.                     -------------------------------------------------------------------------------------------
  686.                     
  687.                     local cont = AddListController EC_OBJ "Pos" Position_List
  688.                     
  689.                     -------------------------------------------------------------------------------------------
  690.                     -- Add Constraint
  691.                     ---------------------------------------------------------------------------------------
  692.                     If classof cont[listCtrl.GetActive cont].object != Surface_Position then constraint = AddConstraint EC_OBJ "Pos" Surface_Position true
  693.                         else constraint = cont[listCtrl.GetActive cont].object
  694.  
  695.                     -------------------------------------------------------------------------------------------
  696.                     -- Add Object
  697.                     -------------------------------------------------------------------------------------------
  698.                         
  699.                     constraint.Surface = EC_TargetOBJ
  700.                             
  701.                     -------------------------------------------------------------------------------------------
  702.                     -- Set Active Controller
  703.                     -------------------------------------------------------------------------------------------
  704.                             
  705.                     SetActiveController cont constraint
  706.     
  707.                     Select EC_OBJ
  708.                     
  709.                 )
  710.             )
  711.             Catch (MessageBox "Surface Constraint Not Completed" Title:"Constraints")
  712.         )
  713.     )
  714. )
  715.  
  716.  
  717. MacroScript Noise_P
  718.  
  719.     ButtonText:"Noise Position"
  720.     Category:"Controllers" 
  721.     internalCategory:"Controllers" 
  722.     Tooltip:"Noise Position Controller"
  723.     SilentErrors:(Debug != True) 
  724.     -- Icon Needed Icon:#("NURBScurve",1)
  725.  
  726. (
  727.     Global EC_OBJ, EC_TargetOBJ = "None"
  728.  
  729.     -- Check to see if something is selected
  730.     on isEnabled return (selection.count != 0 and
  731.                          classof selection[1].controller != BipSlave_Control and
  732.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[1].controller != undefined) and
  733.                          (    selection.count == 1 or 
  734.                             selection.count > 1 and
  735.                             (
  736.                                 local h = selection[1].parent 
  737.                                 h != undefined and h.isSelected and isGroupHead h
  738.                             )
  739.                          )
  740.                         )
  741.  
  742.     on execute do 
  743.     (
  744.         Try
  745.         (
  746.             -------------------------------------------------------------------------------------------
  747.             -- Switch to Motion Panel
  748.             -------------------------------------------------------------------------------------------
  749.         
  750.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  751.             
  752.             -------------------------------------------------------------------------------------------
  753.             -- Check for Groups and act accordingly
  754.             -------------------------------------------------------------------------------------------
  755.             
  756.             EC_OBJ = selection[1]
  757.             if selection.count > 1 do 
  758.             (
  759.                 local h = EC_OBJ.parent 
  760.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  761.             )
  762.             
  763.             -------------------------------------------------------------------------------------------
  764.             -- Add List Controller
  765.             -------------------------------------------------------------------------------------------
  766.             
  767.             local cont = AddListController EC_OBJ "Pos" Position_List
  768.             
  769.             -------------------------------------------------------------------------------------------
  770.             -- Add Constraint
  771.             ---------------------------------------------------------------------------------------
  772.             If classof cont[listCtrl.GetActive cont].object != Noise_Position then constraint = AddConstraint EC_OBJ "Pos" Noise_Position true
  773.                 else constraint = cont[listCtrl.GetActive cont].object
  774.     
  775.             -------------------------------------------------------------------------------------------
  776.             -- Set Active Controller
  777.             -------------------------------------------------------------------------------------------
  778.                     
  779.             SetActiveController cont constraint
  780.     
  781.             -------------------------------------------------------------------------------------------
  782.                     
  783.             Select EC_OBJ
  784.                 
  785.         )
  786.         Catch (MessageBox "Noise Constraint Not Completed" Title:"Constraints")
  787.             
  788.     )
  789. )
  790.  
  791.  
  792. MacroScript Noise_R
  793.  
  794.     ButtonText:"Noise Rotation"
  795.     Category:"Controllers" 
  796.     internalCategory:"Controllers" 
  797.     Tooltip:"Noise Rotation Controller"
  798.     SilentErrors:(Debug != True) 
  799.     -- Icon Needed Icon:#("NURBScurve",1)
  800.  
  801. (
  802.     Global EC_OBJ, EC_TargetOBJ = "None"
  803.  
  804.     -- Check to see if something is selected
  805.     on isEnabled return (selection.count != 0 and
  806.                          classof selection[1].controller != BipSlave_Control and
  807.                          (classof selection[1].controller != IK_ControllerMatrix3Controller or selection[1].controller[2].controller != undefined) and
  808.                          (    selection.count == 1 or 
  809.                             selection.count > 1 and
  810.                             (
  811.                                 local h = selection[1].parent 
  812.                                 h != undefined and h.isSelected and isGroupHead h
  813.                             )
  814.                          )
  815.                         )
  816.  
  817.     on execute do 
  818.     (
  819.         Try
  820.         (
  821.         
  822.             -------------------------------------------------------------------------------------------
  823.             -- Switch to Motion Panel
  824.             -------------------------------------------------------------------------------------------
  825.         
  826.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  827.             
  828.             -------------------------------------------------------------------------------------------
  829.             -- Check for Groups and act accordingly
  830.             -------------------------------------------------------------------------------------------
  831.             
  832.             EC_OBJ = selection[1]
  833.             if selection.count > 1 do 
  834.             (
  835.                 local h = EC_OBJ.parent 
  836.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  837.             )
  838.         
  839.             -------------------------------------------------------------------------------------------
  840.             -- Add List Controller
  841.             -------------------------------------------------------------------------------------------
  842.             
  843.             local cont = AddListController EC_OBJ "Rotation" Rotation_List
  844.             
  845.             -------------------------------------------------------------------------------------------
  846.             -- Add Constraint
  847.             ---------------------------------------------------------------------------------------
  848.             If classof cont[listCtrl.GetActive cont].object != Noise_Rotation then constraint = AddConstraint EC_OBJ "Rotation" Noise_Rotation true
  849.                 else constraint = cont[listCtrl.GetActive cont].object
  850.     
  851.             -------------------------------------------------------------------------------------------
  852.             -- Set Active Controller
  853.             -------------------------------------------------------------------------------------------
  854.                     
  855.             SetActiveController cont constraint
  856.     
  857.             -------------------------------------------------------------------------------------------
  858.                     
  859.             select EC_OBJ
  860.         
  861.         )
  862.         Catch (MessageBox "Noise Constraint Not Completed" Title:"Constraints")
  863.             
  864.     )
  865. )
  866.  
  867.     
  868. MacroScript Noise_S
  869.  
  870.     ButtonText:"Noise Scale"
  871.     Category:"Controllers" 
  872.     internalCategory:"Controllers" 
  873.     Tooltip:"Noise Scale Controller"
  874.     SilentErrors:(Debug != True) 
  875.     -- Icon needed Icon:#("NURBScurve",1)
  876.  
  877. (
  878.     Global EC_OBJ, EC_TargetOBJ = "None"
  879.  
  880.     -- Check to see if something is selected
  881.     on isEnabled return (selection.count != 0 and
  882.                          classof selection[1].controller != BipSlave_Control and
  883.                              (classof selection[1].controller != IK_ControllerMatrix3Controller) and
  884.                          (    selection.count == 1 or 
  885.                             selection.count > 1 and
  886.                             (
  887.                                 local h = selection[1].parent 
  888.                                 h != undefined and h.isSelected and isGroupHead h
  889.                             )
  890.                          )
  891.                         )
  892.  
  893.     on execute do 
  894.     (
  895.         Try
  896.         (
  897.             -------------------------------------------------------------------------------------------
  898.             -- Switch to Motion Panel
  899.             -------------------------------------------------------------------------------------------
  900.         
  901.             IF getCommandPanelTaskMode() != #motion then SetCommandPanelTaskMode Mode:#Motion
  902.             
  903.             -------------------------------------------------------------------------------------------
  904.             -- Check for Groups and act accordingly
  905.             -------------------------------------------------------------------------------------------
  906.             
  907.             EC_OBJ = selection[1]
  908.             if selection.count > 1 do 
  909.             (
  910.                 local h = EC_OBJ.parent 
  911.                 if (h != undefined and h.isSelected and isGroupHead h) do EC_OBJ = h
  912.             )
  913.             
  914.             -------------------------------------------------------------------------------------------
  915.             -- Add List Controller
  916.             -------------------------------------------------------------------------------------------
  917.             
  918.             local cont = AddListController EC_OBJ "Scale" Scale_List
  919.             
  920.             -------------------------------------------------------------------------------------------
  921.             -- Add Constraint
  922.             ---------------------------------------------------------------------------------------
  923.             If classof cont[listCtrl.GetActive cont].object != Noise_Scale then constraint = AddConstraint EC_OBJ "Scale" Noise_Scale true
  924.                 else constraint = cont[listCtrl.GetActive cont].object
  925.     
  926.             -------------------------------------------------------------------------------------------
  927.             -- Set Active Controller
  928.             -------------------------------------------------------------------------------------------
  929.                     
  930.             SetActiveController cont constraint
  931.     
  932.             -------------------------------------------------------------------------------------------
  933.                     
  934.             Select EC_OBJ
  935.         
  936.         )
  937.         Catch (MessageBox "Noise Constraint Not Completed" Title:"Constraints")
  938.     )
  939. )
  940.     
  941.         
  942.     
  943.  
  944.  
  945.  
  946.