ScriptSpot

Forum topic · General Scripting

Mesh Attach Question

By chooj · 2015-12-09

Description

For example I have a lot of meshes named "left" - left001, left002, left003.... left 099. And the same number of meshes called "right", from 001 to 099. (All meshes have modifiers). And I want to mesh-attach them in pair according the index - left001 with right001, left002 with right002... etc. How should I do this?

Comments (6)

`

pixamoon · 2015-12-10

try something like this:


(
	a_From = 1
	a_To = 99
	
	a_basename1 ="left"
	a_basename2 ="right"
	
	a_resultname ="left-right"
	
	for i = a_From to a_To do (
		local n3d = (formattedPrint i format:"03d")
		a1 = getnodebyname (a_basename1 + n3d)
		a2 = getnodebyname (a_basename2 + n3d )
		if a1 != undefined and a2 != undefined do (
			convertToMesh a1
			attach a1 a2
			--meshop.attach a1 a2 targetNode:a1
			a1.name = a_resultname + n3d
		)
	)
)

chooj · 2015-12-10

Thanx, I'll try this code! And what if the nunber of meshes is different every time? Sometimes it's 025, and sometimes it's 125?

`

pixamoon · 2015-12-11

just change a a_To = 125 or maximum

code also recognize no pair - and will skip that object

so if you change a_To = 999 - it should attach all found left and right pairs till 999

hope this makes sense

chooj · 2015-12-11

Many thanx, will try this today!

chooj · 2015-12-11

Yes! Its working! Thanx again. But I've changed mesh-attach to poly-attach bacause of strange issue with normals, one of the objects was flipped every time. Now working fine!

`

pixamoon · 2015-12-11

Coool. I'm glad it helped :)

Pixamoon