[Closed] by-reference controller assignment?
Does anyone know why this does’nt work?
fn test &a =
(
a = position_script()
)
val = $point01.pos.controller
test &val
What means does’nt work? If you expect that to change the $point01 controller (not only the ‘val’ variable) then s’d say: (test &$point01.pos.controller)
yes i know that would work – but i thought ‘&’ is a by-reference to the ‘actual’ object. For example:
fn test &a =
(
a.value = [10,10,10]
)
val = $.pos.controller
test &val
This works – Why not controller assignment by variable? Does by-reference only work as a pointer to a property of an object eg.
$myObject.myProperty
myController.myProperty
Yes, good question, by-ref works with values, maybe should ask ADSK dev team why.
What i presume is that by-ref are in Mxs just to support functions that need to return multiple results.
Well, the following code doesn’t work either:
a = $.position.controller
a = position_script()
It’s basically the same you’re doing. But as I understand it makes sense actually. Looks like the code “position_script()” generates information in a new memory address FIRST and then points this new address to the variable, losing the first reference. You are expecting this information to be inserted at the same memory address as the variable “val” is pointing to. What is not the case…
Regards,
Jr.
…tried, but haven’t found a good excuse to use ‘by reference’…
val=$.pos.controller
replaceinstances val (position_script())