Hey Sven,
If you need to recreate some functionality from an existing core primitive, the easiest way would be to check out the code in the NetLogo code. Prim files and classes are prefixed with an underscore, so usually aren't too hard to find.
In this case the _resizeworld
code and _setpatchsize
code look pretty close to what you're doing, but they are wrapping the setDimensions()
call in a waitFor()
. I believe this is because the setDimensions()
method is running the change on an event queue for the GUI. That might cause the weird behavior you're seeing, so it'd be worth trying the same waitFor()
call to see if it helps.
-Jeremy