ScriptSpot

Forum topic · General Scripting

how to apply on mutliple objects

By randomf · 2014-09-16

Description

I would really to apply this script on multple splines, but I cant get it to work.
As you would imagine I'm a bit of a noob with maxscript, so any help would be really appreciated.

gsl = getsegLenghts $ cum:false byVertex:false numArcSteps:1
heightspline = amax gsl as float
mycylinder = cylinder radius:1 height:heightspline pos:(getKnotPoint $ 1 1)
mydummy = dummy pos:(getKnotPoint $ 1 2)
select mycylinder
lookAtCon=lookAt_Constraint()

showInterfaces lookAtCon --Look at the listener
showProperties lookAtCon --Look at the listener

lookAtCon.appendTarget mydummy 100
lookAtCon.target_axisFlip=false
lookAtCon.set_orientation=true
lookAtCon.target_axis=2

rotList=rotation_list()
mycylinder.rotation.controller=rotList
rotList.available.controller=lookAtCon

select mycylinder
snapshot mycylinder
delete mycylinder

select (for h in helpers where h.category == #standard collect h)
delete $

Thanks

Comments (6)

Model

randomf · 2014-09-24

I have a model made of splines and want to replace them with cylinders to be able to convert them to body objects.
After that i can edit the model in inventor.

Drathir · 2014-09-19

whate exactly you want to achive? A cylinder that goes beetween 1st and 2nd (or any other) point of spline?

Awesome

randomf · 2014-09-18

Thnx a lot :)
This works really good.
I also found another way to align the cylinder to the spline which is much shorter and probably easier to control.
I'll try to post it later today.

easiest way is to pt your

Drathir · 2014-09-17

easiest way is to put your script to function


FN crazyFunction splinesToDo =
(
   --your code here - CHANGE ALL $ to splinesToDo 
)

for s in shapes do crazyFunction s --for all shapes on scene
--OR --for s in selection where SuperClassOf s == shape do crazyFunction s --for all shapes among selected objects

AND:

change last line to


delete myDummy

or

LITTLE CHAOTIC, but works


try (destroyDialog test) catch()

rollout test "happy function"
(
	local tabSplines = (for s in shapes collect s.name)
		

	multiListBox mlb_shapesList "Shapes on scene:" items:tabSplines height:tabSplines.count--selection:#(tabSplines.count) 
	
	button btn_selectAll "select All" width: 50 height: 21 pos:[12,mlb_shapesList.height+30]
	button btn_Main "Lets rock" pos:[btn_selectAll.pos.x+50,mlb_shapesList.height+30]
	
	FN fn_main shapeToDo=
	(
		gsl = getSegLengths shapeToDo 1 cum:false byVertex:false numArcSteps:1 
		heightspline = amax gsl as float
		mycylinder = cylinder radius:1 height:heightspline pos:(getKnotPoint shapeToDo 1 1)
		mydummy = dummy pos:(getKnotPoint shapeToDo 1 2)

		select mycylinder
		lookAtCon=lookAt_Constraint()

		showInterfaces lookAtCon --Look at the listener
		showProperties lookAtCon --Look at the listener

		lookAtCon.appendTarget mydummy 100
		lookAtCon.target_axisFlip=false
		lookAtCon.set_orientation=true
		lookAtCon.target_axis=2

		rotList=rotation_list()
		mycylinder.rotation.controller=rotList
		rotList.available.controller=lookAtCon

		select mycylinder
		snapshot mycylinder
		delete mycylinder
		
		delete mydummy
		
	)
	
	on btn_selectAll pressed do
	(
		mlb_shapesList.selection=(for i=1 to mlb_shapesList.items.count collect i)
	)
	
	on btn_main pressed do
	(
		tabZaznaczonych = mlb_shapesList.selection as Array
		
		
		for i=1 to tabZaznaczonych.count do
		(
			sceneObj = getNodeByName ((mlb_shapesList.items[(tabZaznaczonych[i])]) as String)
			
			fn_main sceneObj

		)
	)
)--rollout
	rof=newrolloutfloater "i need coffee...and beer :)" 200 300
	addrollout test rof

randomf · 2014-09-16

Thnx a lot

So if I change the getSegLengths and the deletionof the helpers it should work on multiple splines?
Or do it need add anything?

Drathir · 2014-09-16

you dont need to select before deleting


for h in helpers where h.category == #standard do delete h

there a couple of errors (Checking them now)

ex:

getSegLengths splineShape spline_index [cum:boolean] [byVertex:boolean] [numArcSteps:integer]

yours:
gsl = getsegLenghts $ NO_spline_index_HERE cum:false byVertex:false numArcSteps:1

EDIT:
CHANGE 1st line to

gsl = getSegLengths $ 1 cum:false byVertex:false numArcSteps:1

and should work