title: Creating curve controls with position relative to a selection in Maya with Python?
body: <p>I am still very new at coding and thought I would try scripting a tool from a tutorial by Chris Lesage which outlines a little softMod rig. So far I've been trying to put it together one step at a time like a lot of coding tutorials recommend.
  <a href="https://chrislesage.com/posts/sliding-bulging-effects-with-softmods/" rel="nofollow noreferrer">https://chrislesage.com/posts/sliding-bulging-effects-with-softmods/</a></p>
  
  <p>It is working ok, but I am curious how I can create the circles in this case being used as controllers but with their 'center' attribute relative to a selected vertex. I'm not sure what commands I should be looking </p>
  
  <p>Ultimately I'm trying to make a softMod at a selected vertex, and have these controls created to animated the effects. I hope that makes sense. It's a fun learning exercise so far! </p>
  
  <p>Thank you for any tips!
  Alex</p>
  
  <pre><code>import maya.cmds as cmds
  import pymel.core as pm
  from pymel.core import *
  
  cmds.softMod( falloffRadius=10, envelope=1, falloffAroundSelection=True)
  
  cntrlA = cmds.circle( nr=(0, 0, 1), c=(0, 0, 0), r=2, name="ControlA" )
  cntrlB = cmds.circle( nr=(0, 0, 1), c=(0, 0, 0), r=1, name="ControlB" )
  
  #Need to translate the curves above the specific surface or mesh
  
  cmds.parentConstraint( 'ControlA', 'ControlB', maintainOffset=True )
  
  cmds.spaceLocator(name="testLoc")
  
  cmds.parentConstraint( 'ControlA', 'testLoc', maintainOffset=False )
  
  cmds.connectAttr( 'testLoc.t', 'softMod1.falloffCenter' )
  cmds.connectAttr( 'ControlB.t', 'softMod1Handle.translate' )
  cmds.connectAttr( 'ControlB.r', 'softMod1Handle.rotate' )
  
  #### This code worked to create the controls AND assign them to a variable
  
  cmds.select( cntrlB) 
  cmds.addAttr('ControlB', ln='softModENV', keyable=True, dv=1, min=0, max=1 )
  cmds.addAttr('ControlB', ln='falloffRAD', keyable=True, dv=10, )
  
  # Connect the attributes you made previously
  cmds.connectAttr( 'ControlB.softModENV', 'softMod1.envelope' )
  cmds.connectAttr( 'ControlB.falloffRAD', 'softMod1.falloffRadius' )
  
  cmds.group( 'ControlA', 'ControlB', 'testLoc', 'softMod1Handle', n='softModGRP' )
  </code></pre>