Notifications
Clear all

[Closed] position script controller not updates in Max2016-2017 at sub object level

As title says, the position script controller not udpates in 3ds Max 2016 and 2017. Here is the code:


(	
	objToAttach = $Point001		
	parentObj = $Line001
	
	knot = 2
	subSpline = 1
	script_controller = objToAttach.pos.controller = position_script ()
	script_controller.AddNode "miauuRefObj" parentObj
	script_controller.AddConstant "knot" knot
	script_controller.AddConstant "subSpline" subSpline						
	posCmdStr = "dependsOn miauuRefObj
"
	posCmdStr += "(pos = (getPointPos miauuRefObj ((knot * 3) - 1) ); return pos )"
	script_controller.script = posCmdStr
)

The point will be “attached” to the knot 2 of the line. Moving the line will move the point. When the knot 2 is selected and moved the point stays in place. If you go to top sub object level and move the line the point will be moved to its proper position(the position of knot 2).
The code works with no problems in 3dsMax 2015 and the other eariler versions.

Is there a solution?

9 Replies

Have you tried addind the BaseObject as target instead of the Node as node?

1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

Like this:


posCmdStr += "(pos = (getPointPos miauuRefObj.baseobject ((knot * 3) - 1) ); return pos )"

The result


-- Runtime error: getPointPos requires a node

No, sorry. I haven’t explained it very well.
Leave this line:
script_controller.AddNode “miauuRefObj” parentObj
And add this one:
script_controller.AddTarget “miauuRefObjBase” parentObj.baseobject

It’s just to check if this target fires the notify event to your controller. I haven’t 3dsMax here to check it.

1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

The same error:


-- Runtime error: getPointPos requires a node

Don’t change anything to your code, just add the line I’ve written above.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

brilliant solution!

(
	delete objects

	p = point wirecolor:green
	c = line wirecolor:yellow
	addnewspline c
	addknot c 1 #corner #line [0,0,0]
	addknot c 1 #corner #line [30,0,0]
	addknot c 1 #corner #line [60,0,0]
	updateshape c
	  
	s = p.pos.controller = position_script()
	s.addnode "target" c
	s.addobject "base" c.baseobject
	s.setexpression "getknotpoint target 1 2"
)

Yes, in fact “dependsOn miauuRefObj
” is not needed.
‘DependsOn’ is an obsolete command for script controllers since 3ds Max 8: http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_CF4BD614_5A08_4DB6_9039_49EE32AA5178_htm

1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

I know this, but it is there for a long time. so I just grabbed the code to show an example.

aaandres, denisT, thank you. Both solutions works. I had to read more carefully what you typed.