[Closed] break uvs along uv seams without unwrap ?
Ok we only have to parse geo elements and detach them. I think we’ve over complexified the problem. Thanks !
I think so too, mostly because the tools you need are already done.
Problem solved in 2 clicks.
Thank you for your reply, Jorge.
I’m not really used to use maxscript for this kind of tasks until now so nothing is evident for me here. The topic where you helped Clanker was a gold mine and I learned much from it.
I will study your links as soon as I am back to work monday and hopefully we will beat these CAD objects !
what pipeline do you use?
is it:
autodesk CAD export
autodesk MAX import
?
no third-party’s, no homemade… correct?
export SolidWorks CAD models in many different OBJs with a third-party’s software (Deep Exploration)
autodesk 3dsmax OBJ import
Then maxscript:
break and weld uvs from the other post
unflip inverted uv faces
the forecoming break uv open edges
Ugly, very ugly code, but it gets the job done and it is fast. You can run this script and then flip the inverted faces. The break and weld uvs from the other post should no longer be needed.
It’s mostly a copy/paste from the other two codes with a few more lines. It could be clearer and faster, so if you ever clean and optimize it, please put it back here so others can use it.
I hope you find it useful.
(
fn FixAndBreakUVSeams obj breakmesh:true tmp: source: =
(
m0 = snapshotasmesh obj
setnumtverts obj (obj.numfaces*3)
buildtvfaces obj
verts = for j = 1 to obj.numverts collect #()
idx = deepcopy verts
for j = 1 to obj.numfaces do
(
f1 = getface obj j
f2 = gettvface m0 j
i3 = j*3; i2 = i3-1; i1 = i3-2
v1 = gettvert m0 f2[1]
v2 = gettvert m0 f2[2]
v3 = gettvert m0 f2[3]
if (k1 = finditem verts[f1[1]] v1) == 0 then
(
append verts[f1[1]] v1
append idx[f1[1]] i1
)
else i1 = idx[f1[1]][k1]
if (k2 = finditem verts[f1[2]] v2) == 0 then
(
append verts[f1[2]] v2
append idx[f1[2]] i2
)
else i2 = idx[f1[2]][k2]
if (k3 = finditem verts[f1[3]] v3) == 0 then
(
append verts[f1[3]] v3
append idx[f1[3]] i3
)
else i3 = idx[f1[3]][k3]
settvert obj i1 v1
settvert obj i2 v2
settvert obj i3 v3
settvface obj j [i1,i2,i3]
)
meshop.deleteisomapvertsall obj
if breakmesh then
(
m1 = snapshotasmesh obj
numtverts = obj.numtverts
verts = for j = 1 to numtverts collect (gettvert m1 j)
setnumverts m1 numtverts
meshop.setvert m1 #all verts
for j = 1 to m1.numfaces do
(
face = gettvface m1 j
setface m1 j face[1] face[2] face[3]
)
m2 = snapshotasmesh obj
m3 = copy m1
for j = 1 to m1.numfaces do
(
f1 = getface m1 j; f2 = getface m2 j
setvert m3 (f1[1]) (getvert m2 f2[1])
setvert m3 (f1[2]) (getvert m2 f2[2])
setvert m3 (f1[3]) (getvert m2 f2[3])
)
tmesh = converttomesh (converttopoly (mesh mesh:m3))
FixAndBreakUVSeams tmesh breakmesh:false tmp:tmesh source:obj
)else(
setnumtverts source tmp.numtverts
buildtvfaces source
for j = 1 to tmp.numtverts do settvert source j (gettvert tmp j)
for j = 1 to tmp.numfaces do settvface source j (gettvface tmp j)
delete tmp
)
)
gc()
st = timestamp(); sh = heapfree
FixAndBreakUVSeams $
format "time:% ram:%
" (timestamp()-st) (sh-heapfree)
)
Hello Jorge.
Many thanks! Another learning piece for everyone wants dig into pure maxscript uvs stuff.
I will test it as soon as I get back to work tomorrow.
In the meanwhile, I have one question about one line of your code:
tmesh = converttomesh (converttopoly (mesh mesh:m3))
Why a conversion to poly is needed here ?
Works like a charm ! Of course… who doubted about it ?
Thank you, Jorge, for your time.