Hi!
The proximity pin is a bit complexer of a setup than the other constraints, it also has more options to choose from and the options will actually influence how the nodenetwork created by the constraint looks like. So there isn't a command to create this constraint.
The easiest way to script this is to create the proximity constraint with the settings you want, and then look at the node network and recreate it node by node using code. In most proximity pin setups there doesn't have to be much created since the proximityPin node handles all calculation.
As an Example:
I create a proximity Pin for a selected shape with a selected transform as an input, a new transform as output and no maintained offset. The Nodenetwork looks like this.
Now if I wanted to create the same setup in pyhton, it would look like this:
import maya.cmds as mc
def proximityConst(shape = "", inTrans = ""):
"""
creates a proximityPin with the settings input: existing transform , output: new Transform
mode: edge, maintain offset: False.
Needs kwargs: 'shape' for shapenode to connect to, 'inTrans' for name of input
"""
#getting original shape node
shapeOrig = mc.listConnections("{0}.inMesh".format(shape), d = True)
#creating original state nodes if no shapeOrig exists
if shapeOrig == None:
dup = mc.duplicate(shape, n= "{0}OrigTrans".format(shape), rc = True)[0]
shapeOrig= mc.listRelatives(dup, s = True)[0]
shapeOrig = mc.rename(shapeOrig, "{0}Orig".format(shape))
mc.setAttr("{0}.visibility".format(dup),0)
mc.setAttr("{0}.intermediateObject".format(shapeOrig), 1)
mc.connectAttr("{0}.worldMesh[0]".format(shapeOrig), "{0}.inMesh".format(shape))
#getting name for existing shapeOrig from list
else:
shapeOrig = shapeOrig[0]
#creating the proximityPin node
pin = mc.createNode("proximityPin", n = "{0}_poximityPin".format(shape))
#setting input connections for proximity Pin
mc.connectAttr("{0}.worldMesh[0]".format(shape), "{0}.deformedGeometry".format(pin))
mc.connectAttr("{0}.outMesh".format(shapeOrig), "{0}.originalGeometry".format(pin))
mc.connectAttr("{0}.matrix".format(inTrans), "{0}.inputMatrix[0]".format(pin))
#creating output transform
outTrans = mc.createNode("transform", n = "{0}_pinTrans".format(shape))
#setting input connections for output transform
mc.connectAttr("{0}.outputMatrix[0]".format(pin), "{0}.offsetParentMatrix".format(outTrans))
proximityConst(shape = "Shape", inTrans = "inputTransform")
Now this code is something I just wrote for this in like 15 min, so it can certainly be improved, but I thought an example might be helpful.
I hope this helps!