Notifications
Clear all

[Closed] Controller Illegal self reference

Hello gents,

I’ve been reading everything that I could find about weak references, custom attributes but I still have problems to understand the concepts. I cannot reference a node so I’ve been trying to use a weak reference. The thing is the folowing, I added 2 custom attributes to a point helper, I’d like to read one of this attributes and change the scale of an object based on this value. I’ve tried several times and it sitll does not work. Is there anyone that could help me with this,it is driving me insane… I’ve read PEN’s tutorial several times and I don’t know what is going on. How do I make a custom attribute from a second object able to be referenced in another object? Please any help will be more then welcomed… I am attaching a screenshot and the script.

thanks in advance
G.

 
--------------------------------------------------------------------------------------------------------
 
--CUSTOM ATTRIBUTES
 
--------------------------------------------------------------------------------------------------------
 
caDefOrPos = attributes datum_originalPosition
 
(
 
parameters main
 
(
 
originalPosition type:#float tabSizeVariable:true 
 
) 
 
)
 
caDefDistPoint = attributes datum_distancePoint 
 
(
 
parameters main rollout:rDist
 
(
 
distancePoint type:#float tabSizeVariable:true 
 
)
 
rollout rDist "General Info"
 
(
 
group "Values"
 
( 
 
spinner spOrDist "Original Z" type:#float range:[0.0,1000000000000.00,0.0]
 
spinner spDist "Current Dist" type:#float range:[0.0,1000000000000.00,0.0]
 
)
 
fn updateListOne =
 
(
 
spOrDist.value = $.modifiers[1].originalPosition
 
spDist.value = $.modifiers[1].distancePoint 
 
)
 
on rDist open do updateListOne()
 
) 
 
)
 
caDefController = attributes datum_controlPoint
 
(
 
parameters nodesP rollout:nodesR
 
(
 
controlPoint type:#maxObjectTab tabSize:0 tabSizeVariable:true
 
)
 
 
 
rollout nodesR "General Info"
 
( 
 
group "Control Node"
 
(
 
listBox nodesList
 
) 
 
fn updateList =
 
( 
 
nNames=for n in controlPoint collect n.node.name
 
nodesList.items=nNames
 
) 
 
 
 
on nodesR open do 
 
(
 
updateList()
 
)
 
)
 
)
 
--------------------------------------------------------------------------------------------------------
 
obj = $
 
pointArray = #()
 
faceCount = getNumFaces obj 
 
for i = 1 to faceCount by 2 do 
 
(
 
--POINT PROPERTIES 
 

 
sz = 20
 
p = point()
 
p.name = (uniquename ("Weight_")) 
 
p.size = sz
 
p.wirecolor = black
 
p.isHidden = true
 
 
 
AtC = attachment()
 
p.pos.controller = AtC
 
addNewKey AtC 0f
 
theAKey = AttachCtrl.getKey AtC 1
 
AtC.node = obj
 
theAKey.face = i
 
theAKey.coord = [0,0.5] 
 
append pointArray p 
 
 
 
EM=(EmptyModifier())
 
addModifier p EM
 
custAttributes.add EM caDefOrPos 
 
custAttributes.add EM caDefDistPoint
 
a = p.pos[3]
 
p.modifiers[1].originalPosition = a
 
p.modifiers[1].distancePoint.controller = bezier_float()
 
ctrlS = float_script()
 
ctrlS.script = "$"+p.name+".modifiers[1].distancePoint = (abs($"+p.name+".pos[3] - $" \
 
+p.name+".modifiers[1].originalPosition))"
 
p.modifiers[1].distancePoint.controller = ctrlS
 
)
 
 
 
theShape = $Ellipse01
 
for j in pointArray do
 
(
 
newObj = copy theShape
 
newObj.pos = j.pos
 
EM=(EmptyModifier())
 
addModifier newObj EM
 
custAttributes.add EM caDefController 
 
append newObj.modifiers[1].controlPoint (nodeTransformMonitor node:j forwardTransformChangeMsgs:true)
 
--updateList() 
 

 
newObj.scale.controller = scale_list()
 
ctrlScale = scale_script()
 
ctrlScale.script = "MS = ($" \
 
+newObj.name+".modifiers[1].controlPoint[1]).node.modifiers[1].distancePoint * 0.01 * [1,1,1]" 
 
newObj.scale.controller = ctrlScale
 
)