Notifications
Clear all

[Closed] creating single mesh out of multiple selected

Hey Guys,

I am trying to create a mesh out of the selected meshes taking the vertex and face positions in to arrays. Now When I run the code in teh for loop, it creates meshes as is… If I try to create a mesh out side forloop with the vertex and face arrays, it creates only one mesh with a number of verts and faces same to the total objects verts and faces… Hope i made my self clear. Any ideas how to go about it??


startTime=timeStamp()

fn exportToTrimesh =
(
   
	local objs =  for g in geometry collect g   
	local vert_count = 0
 
-- 	local theMesh = trimesh()
	
	for obj in objs do
	(
--		 print obj
		
		convertToMesh obj
		
		local faceArray = #()
		local vertArray = #()
		  
		local numFaces = getNumFaces obj
		local numVerts = getNumVerts obj
	   
		for ii=1 to numVerts do
		(
			append vertArray ((getVert obj ii))
			)
		for ii=1 to numFaces do
		(
			append faceArray ((getFace obj ii))
			)
		mesh vertices:vertArray faces:faceArray
	)
	
	
)

exportToTrimesh ()

windows.processPostedMessages()



4 Replies

in simplest terms

sel = $selection as array;
  m = mesh numverts:0 numfaces:0;
  for i in sel where canconvertto i editable_mesh do m += i;

or

m = mesh numverts:0 numfaces:0;
for i in geometry do m += i;
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

mesh + mesh is a boolean union. the attach has to be used instead

That was amazing… Thanks alot. Never knew the canconvertTo function

yep, but depends on how the meshes are arranged if there’s no intersection.