Notifications
Clear all

[Closed] Convert unwrap edges to mesh

Hello everyone.
I have a problem with converting selected UV edges in Unwrap to mesh edges.

unwrap.GetSelectedGeomEdges function is broken, so I spend almost a week to find out good fast solution.
I read dozens of related old posts here and in other places, especially DenisT and Polytools3d conversations, but didn’t find too much info about my topic.

At this point I wrote couple of slow algorythms but I want to improve it.

First one is obvious bruteforce:
Parse all selected unwrap edges one by one, to find pairs of their verts. Then select corresponding edges in mesh.

Second is a little smarter and faster but still very unreliable:

  1. Store selected unwrap edges
  2. Convert all of them to verts
  3. Store this verts
  4. Convert them again to edges
  5. Find edges to exclude (there will be more selected edges at this point)
  6. Parse only these exclude edges one by one to find their verts. Sometimes it’s still very slow. Depends of initial selection.
  7. Do the same process on mesh level and exclude those edges.

The problem is that I don’t see any other method to find unwrap edge verts other than select it and convert to vertices one by one. And this is predictable slow.

I even tried to understand how unwrap numerate uv edges based on uv vertices indexes. But.

  1. Sometimes unwrap numerate edges differently on the same mesh
  2. Algorythm of numeration is too tricky for my skills, I’m not sure I can understand and reproduce it.

I would be grateful for any advice.

18 Replies
3 Replies
(@miauu)
Joined: 11 months ago

Posts: 0

HI!

I suppose that you asked me a question in my blog about the speed of Transform Edges script. Can you tell me how exactly to test the script? How many edges should have the mesh objects. How many UV edges have to be selected? What version of 3ds Max you use?

(@denist)
Joined: 11 months ago

Posts: 0

unwrap.getSelectedGeomEdgesByNode has to work

(@nik684)
Joined: 11 months ago

Posts: 0

Not for me max2016


$.modifiers[1].getSelectedGeomEdgesByNode $
undefined

One man told me that this function returns some bitarray in his max2017, but this bitarray doesn’t match with actual geometry edges.
Anyway I can’t rely on max2017 because it’s a public code and I want to make support not only 2017+

Yes, that was me. Hi, Kostadin

Well, for example plane 100×100 segments and Unwrap selection like this.

My max version is 2016.

I’m asking about performance because I don’t understand how to get edgeVerts in Unwrap other than select them one by one. This is the main speed killer.
So if your speed in this case will be about a second (not 20 or 30) then maybe you can… push me to right direction? I’m not asking your algorythm, just a little advice.

Before to answer me I ran the script.
3ds Max 2014. Plane 100×100 segments, 11658 selected uv edges. Time to convert selection to mesh edges – 374.039 sec.
I will run the test on 3ds Max 2-16 after few minutes and will post the result.

3ds Max 2016, plane 100×100 segments, all uv edges selected(as in your image): Time to convert selection to mesh edges – 682.319 sec.

Well, I see 374 sec, not 1-2. My code do this in 30sec. Not very impressive too.
I suppose only PolyTools3D knows the secret, because PolyUnwrapper do this operation in less than a second.

1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

Yes. Maxscript is not too fast in this situation, but sometimes even 30 sec is faster than doing all this manually.

Interesting. I got 109sec for 20000 edges.

1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

Different approaches leads to different results.

i need to check, but i don’t have MAX around…


local obj = $
obj.modifiers[Unwrap_UVW].getSelectedGeomEdgesByNode obj

Like this? Still undefined.
What 3dsMax version do you have?

Actually I’m a little surprised by your answer because here what you said in 2011.

Yea, 2011 is not 2017 but in my max2016 it still broken. I will install 2017 to check it myself.

And here is Autodesk bugreport

I don’t know if it has any relation with this thread, but there’s a function <IBitArray> FnGetSelectedEdges { get; } in the IIUnwrapMod2 interface exposed in SDK.NET.

1 Reply
(@nik684)
Joined: 11 months ago

Posts: 0

I saw unwrap sources in sdk examples and found related function, but I’m not familiar with SDK and C++. It’s beyond my skills.
Function exist, but all that I found in web tells that it’s broken. At least in 2009-2016.

it should be some trick… because i see that i used it in one of my very old tools. maybe it works only unwrap_uvw applied to an editable mesh?

also in another tool see custom function:


fn mapEdgesToEdge modi: node: = with undo off
(
   node = selection[1]
   if modi == unsupplied do modi = getWrap()
   edges = modi.getSelectedEdges()
   per_edge = #()
   for f=1 to modi.numberPolygons() do
   (
      map_verts = #()
      geo_verts = #()
      for k=1 to modi.numberPointsInFace f do
      (
         m = modi.getVertexIndexFromFace f k
         append map_verts m
         g = modi.getVertexGeomIndexFromFace f k
         append geo_verts g
      )
      append map_verts map_verts[1]
      map_edges = for k=1 to map_verts.count-1 collect
      (
         modi.selectVertices #{map_verts[k],map_verts[k+1]}
         modi.vertToEdgeSelect()
         e = (modi.getSelectedEdges() as array)[1]
      )
      append geo_verts geo_verts[1]
      geo_edges = for k=1 to geo_verts.count-1 collect
      (
         (patch.getEdges node geo_verts[k] geo_verts[k+1])[1]
      )
      for k=1 to map_edges.count do
      (
         i = map_edges[k]
         if per_edge[i] != undefined and per_edge[i] != geo_edges[k] do format "% % %
" i per_edge[i] geo_edges[k] 
         per_edge[i] = geo_edges[k]
      )
   )
   modi.selectEdges edges
   per_edge
)

it’s made for Patch but can be easily modified to mesh or poly

also i remember some trick…

unwrap’s ‘convert to component’ is much faster if you do it in not the same level as you convert to… (or vise versa, :))
so if you convert to verts the level has to be edge or face
if convert to verts and back to edges it has to be face level…

1 Reply
(@nik684)
Joined: 11 months ago

Posts: 0

Convert to verts works if subobjectlevel != 1, but getSelectedGeomVerts doesn’t. It seems in my loop it doesn’t update verts selection.
And I measured speeds, it seems it was “vise versa”, because convert edges to verts in sublevel 1 was 7sec, and in sublevel 2 it’s 24sec.

Page 1 / 2