Notifications
Clear all

[Closed] Spring Controller Update (Invalidate) ?

Could anyone find a simple way to update newly created Spring controller do be able to get a new spring?


(
	delete objects
	s = sphere iselected:on
	b = box()
	c = SpringPositionController()
	s.pos.controller = c
	c.addspring b
	c.getSpringCount()
)


as you can see this code doesn’t add the second spring (box) to the controller

8 Replies

nooooooo…not you…

here’s how I got around it…don’t ask…I don’t know much about scripting…I just do whatever I have to, to get around a problem…

(
	delete objects
	s = sphere iselected:on
	b = box()
	dum = dummy()
	c = SpringPositionController()
	pot = teapot()
	cyl = cylinder()
	s.pos.controller = c
	c.addspring dum
	c.addspring b
	c.addspring pot
	c.addspring cyl
	c.getSpringCount()
)

anything after the 1st ‘dummy’ add is correctly added…bug ?

it has to return 4 in your case, but it must be 5 including self

but i think bug is that the 1st add doesn’t get registered…hence I added a dummy first (knowing it would be ignored)

then self + box + pot + cyl = 4

(anything related to index base 0 or 1 ? only experts like you would know)
(ps: I did check whether the object was added but count is incorrect ? But in the Controller popup, it does not list the 1st added object…so ‘count’ is right)

you are right. the trick works. thank you, Vu

here is a little cleaner trick solution (doesn’t need extra node):


(
	delete objects
	s = sphere()
	b = box()
	c = s.pos.controller = SpringPositionController()
	c.addspring b -- first is ignored
	c.addspring b
	c.getSpringCount()
)


but anyway i would like to see a ‘not trick’ solution

my hunch for the devs is that…1st slot is RESERVED for self…therefore, if there is an ‘add’, start adding at 2nd slot, so if index start is 0, 1st add should start at 1, or if index start is 1, then 1st add would be at 2…i’ll even put my Nostradumbass hat on and say, check the for loop, the i should be offset by 1 at the start.

look at the source code in jiggle.h , jiggle.cpp and jigglefunctions.cpp to see whats going on

1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

i did… but can’t find a problem. it seems like deeper, maybe in the SpringSys code

some findings:

(
	delete objects
	s = sphere()
	b = box()
	c = s.pos.controller = SpringPositionController()
	c.getSpringCount()
)

This returns 0 which is incorrect, it should be 1…itself as displayed in Spring Dynamics Rollout

(
	delete objects
	s = sphere()
	b = box()
	c = s.pos.controller = SpringPositionController()
	
	c.addspring b -- ignore 1st add
	c.addspring b
	
	c.getSpringCount()
)

This returns 2, correct as per Rollout display

In the Rollout, You can remove any spring, except itself…but waaaaaaiiiiit…try this


(
	delete objects
	s = sphere()
	b = box()
	c = s.pos.controller = SpringPositionController()
	
	c.addspring s
	
	c.getSpringCount()
)

Check the Rollout…poooooooooooooooooooooooooooooof…GONE !! Yet count returns 2 !!! Go figure