Notifications
Clear all

[Closed] unwrap5.getSelectedGeomEdges() broken?

I noticed than unwrap5.getSelectedGeomEdges() seems be broken. It always returns undefined.
Tested in max 2010.
Is there another issue for get selected geometry edges in UVW Modifier? I like to know before I start creating my own function.

2 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it was always broken and it will be never repaired. make you own function.

I wrote something:

(
	clearListener()
	
	function getMapVerts object channel = -- return array of map IDs matched to geometry verts 
	(
		if( polyOp.getMapSupport object channel ) then
		(
			local polyOp_getMapFace = polyOp.getMapFace
			local polyop_getFaceVerts = polyop.getFaceVerts
			
			-- prepare bitarray for each verteice
			local mapVerts = for i=1 to object.numverts collect #{}
			
			local mapFace, meshFace, mVert
			for i=1 to (polyOp.getNumMapFaces object channel) do 
			(
				mapFace = polyOp_getMapFace object channel i
				meshFace = polyop_getFaceVerts object i
				
				for j=1 to meshFace.count do
					mapVerts[meshFace[j]][mapFace[j]] = true -- store index
			)
			
			mapVerts -- return
		)
		else
			undefined -- return
	)

	local uvwMod = selection[1].modifiers[#unwrap_uvw]
	local edgeSel = uvwMod.unwrap2.getSelectedEdges()
	
	obj = snapshot selection[1]
	convertToPoly obj

	local geomEdgesMapVerts = -- collect map verts for each geometry edge
	(
		local mapVerts = getMapVerts obj 1
		
		local polyop_getEdgeVerts = polyop.getEdgeVerts
		local verts
		for i=1 to polyop.getNumEdges obj collect
		(
			verts = polyop_getEdgeVerts obj i
			#( mapVerts[verts[1]], mapVerts[verts[2]] ) -- return
		)
	)
	
	local geomEdgeSel = #{}
	(
		local selectEdges = uvwMod.unwrap2.selectEdges
		local edgeToVert = uvwMod.unwrap2.edgeToVertSelect
		local getVerts = uvwMod.unwrap.getSelectedVertices
		local verts, con

		for e in edgeSel do
		(
			-- get map vertices of each selected map edge
			selectEdges #{e}
			edgeToVert()
			verts = (getVerts()) as array
			
			-- try match it to collected geom edges map vertices
			con = true
			for i=1 to geomEdgesMapVerts.count where con do
			(
				if 	(geomEdgesMapVerts[i][1][verts[1]] and geomEdgesMapVerts[i][2][verts[2]]) or 
					(geomEdgesMapVerts[i][2][verts[1]] and geomEdgesMapVerts[i][1][verts[2]]) then
				(
					geomEdgeSel[i] = true
					con = false
					
					print( "Edge match: " + (geomEdgesMapVerts[i] as string) + " and " + (verts as string) )
				)
			)
		)
	)
	
	select obj
	subObjectLevel = 2
	obj.SetSelection #Edge geomEdgeSel
)

I can’t understand why sometimes it gives wrong results.
Try create teapot and add uvw unwrap modifier. Then select edges based on teapot’s top most vertex and run the script.

I’m not sure is it the best and fastest way to do that.