Notifications
Clear all

[Closed] Spline shape Select

Nice catch Branko,
As for what I’m after it still is not quite there.
I need to have the objects selected/sorted in the order the spline knots. So if there is a way to step along the line from start to finish and find the intersecting objects that would work best.

Do you know if there is a way to get a point on a spline based on its length. Say for example the entire spline is 100cm.
could i get the point 3 value that is 10cm in on the spline.

That way i will just move along the spline by distance finding the closest objects.

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Try this


cnt = 0 ; step = 10
  for i = 1 to curvelength $ by step do 
( 
	cnt+=1
	print (interpCurve3D $ 1 (cnt*(1/step)) pathParam:false)
)

Seems to return the same value when i run it on a spline.

This is just a rough concept. Not sure if it is ideal or as accurate.


		for i = 0.0 to 1.0 by .01 do
		(	
			x = pathInterp theShape 1 i steps:6
			
			for o in _testObjs do
			(
				nodeCenter = o.center
				result = distance nodeCenter x
				
				if result <= range do (appendIfUnique _pathObjs o)
			)
		)

 3ak

you need float here.

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

I know.
i’m working on it

This is another try and now it’s works


 delete objects
 spl = Helix radius1:50 radius2:25 height:80
 convertto spl splineshape
 		for i = 0.0 to 1.0 by .05 do
		(	
			point pos:(interpCurve3D spl 1 i) wirecolor:orange --steps:6
			
			/*for o in _testObjs do
			(
				nodeCenter = o.center
				result = distance nodeCenter x
				
				if result <= range do (appendIfUnique _pathObjs o)
			)*/
		)

nicely done. I do believe this will work out great for what I’m trying to do. Thanks

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

I’m sure 99.9% .

are you not reading my posts?
i’ve answered these questions before you asked… http://forums.cgsociety.org/showpost.php?p=7332879&postcount=7

I’m going back and looking over your version Denis. I have been a bit scattered today. Last two nights of work have been 21 hour days, so I’m a bit loopy.

So the next step Im going to work on is sorting the objects by distance to the closest object to the spline each time an iteration of objects is added.
Iteration meaning each time a new spline pos is being tested.
The grey box marked spline is the spline object being used. It goes right through the middle. The red objects are the objects closest to the spline on each iteration, then the yellow ones are ones that were also collected but get sorted based on distance. The black boxes are just ignored and not collected because they do not fall into the required settings.

This seems feasible.

your original question was about the intersection with spline… now you are looking for an object which center is nor far than something from the closest point on slpine… that’s absolutely different thing. so what do you really need?
the center of an object might be close enough but the size of the object might be smaller. in this case the spline doesn’t intersect the object. and vice versa

I know the code is a bit dirty right now, I’ll go back and clean it up as well as implement the ideas and concepts you guys have posted here.
Thank you for you help and direction on this guys.


try(destroyDialog ::rlShapeOrder)catch()
rollout rlShapeOrder "Shape Order"
(
	local theShape = undefined
	
	fn fnShapeFilter obj = superclassof obj == Shape

	fn fnSortRadialDistance obj1 obj2 refPt: = (
		distance refPt obj1.center - distance refPt obj2.center
	)
	
	fn fnShapeOrder = (
		if theShape != undefined and isValidNode theShape do
		(
			_pathObjs = #()
			_testObjs = for o in objects where superclassof o == GeometryClass collect o
			range = theShape.render_thickness --diameter
			for o in _testObjs do o.wirecolor = black
			resetLengthInterp()
			
		for i = 0.0 to 1.0 by .005 do
		(	
			x = pathInterp theShape 1 i steps:6
			
			_batch = #()
			for o in _testObjs do
			(
				nodeCenter = o.center
				result = distance nodeCenter x
				
				if result <= range do (appendIfUnique _batch o)
			)
			qsort _batch fnSortRadialDistance refPt:x --sort by distance to the given point on the spline
			for o in _batch do appendIfUnique _pathObjs o
		)
			
			--//wirecolor
			r1 = random 1 3
			r2 = random 1 3
			for i = 1 to _pathObjs.count do
			(
				val = [0,0,0]
				val[r1] = i*.5
				val[r2] = i*.5
				_pathObjs[i].wirecolor = val
			)
		)
	)	
	
	label lbRedObjEdge "" style_sunkenedge:true width:162 height:24 pos:[7,10]
	button btnClearRefObj "X" width:26 height:22 pos:[142,11]
	pickbutton pbRefObj "Pick Reference Shape" width:134 height:22 pos:[8,11]	filter:fnShapeFilter
	button btnShapeOrder "Order Selection"width:160 height:30 pos:[10,40]
	
	on pbRefObj picked obj do 
	(
		theShape = if obj != undefined then obj else undefined
		pbRefObj.text = if obj != undefined then obj.name else "Pick Reference Shape"
	)
	on btnClearRefObj pressed do
	(
		theShape = undefined
		pbRefObj.text = "Pick Reference Shape"
	)
	on btnShapeOrder pressed do
	(
		fnShapeOrder()
	)
)
createDialog rlShapeOrder 180 80 style:#(#style_SysMenu, #style_ToolWindow)

Page 2 / 3