Unwanted COFFEE Array Update
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/01/2006 at 02:37, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.5
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
I've created a COFFEE expression to offset an object's points by storing them in an array, adding an offset to each array value and updating the object. The array is stored in a global variable which is only set when the array is empty. Point offset values are entered via User Data on the COFFEE tag.
When I offset the points and undo the action, the array is updated with any offset point values e.g. User Data settings will return to zero but the points will remain in their new position as default. Undo seems to be overriding if(!pointArray) pointArray = op->GetPoints();
Any suggestions on how to overcome this?var pointArray; main(doc,op) { if(!instanceof(op, PointObject)) return; if(!pointArray) pointArray = op->GetPoints(); var tag = op->GetFirstTag(); var offset = tag#ID_USERDATA:1; var p, i = 0; var pointModified; var pointCount = op->GetPointCount(); for(i=0; i < pointCount; i++) { p = pointArray[i]; pointModified = vector(p.x + offset.x, p.y + offset.y, p.z + offset.z); op->SetPoint(i, pointModified); } op->Message(MSG_UPDATE); }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/01/2006 at 12:22, xxxxxxxx wrote:
Yes, global variables within C.O.F.F.E.E. tags are quite volatile. As you've noticed they go away when you undo anything. If you want your plugin to be undo safe you will have to redesign it without global variables.