Notifications
Clear all

[Closed] Question about Path constraint

I wonder if there is any way to apply to the percentage parameter according to where the object is located manually, in other words I want to create a path and four dummies and when the path constraint is created are kept in that position and apply a percentage value to the path constraint.

$pos.controller.percent = “any method of automatically applying this value and not manually”???

path1 = $Spline_01
pc= path_constraint()
$Point_PT_001.pos.controller =pc
$Point_PT_001.pos.controller.percent = 0
pc.appendTarget path1 50
deletekeys $Point_PT_001.controller #allkeys

Thank you

2 Replies

Don’t know of a built-in way of automatically calculate the offset but if the helpers are on the shape you’ll use as a path, perhaps you could use nearestPathParam () to approximate the percentage.

(
	delete objects
	sp = converttosplineshape (helix radius1:100 radius2:100 height:400 turns:4 bias:0 direction:0 wirecolor:yellow)
	
	points = #()
	for j = 0 to 3 do
	(
		append points (point pos:[ 100, 0, j*100]    wirecolor:green)
		append points (point pos:[-100, 0, j*100+50] wirecolor:red)
	)
	
	for j in points do
	(
		constraint = path_constraint()
		
		param = nearestpathparam sp 1 j.pos steps:((curvelength sp)*10)
		constraint.percent = param * 100
		
		constraint.appendtarget sp 50
		j.pos.controller = constraint
		--deletekeys constraint #allkeys
	)
)

thank you very much PolyTools3D
Exactly as you say, using nearestPathParam results in what you were looking for.