Home Technical Talk

Maxscritp: Stitch Problem

interpolator
Offline / Send Message
SimonT interpolator
Hi Friends.

I try to stitch some UV edges via maxscript but it doesn't get me the same result like when i do it via the stitch dialog. Here is an example picture which shoes the problem.

One shell is scaled a bit and via bias 0.0 in the stitch dialog the shell is scaled down to the target shell and all is 100% fine. BUT when i use the maxscript command it's not scaled down properly. What am i doing wrong?

Thx!

problem-maxstitch01.jpg

Replies

  • SpeCter
    Offline / Send Message
    SpeCter polycounter lvl 14
    As far as i remember it doesn´t default to scaling clusters and unfortunately you can´t do that with maxscript alone(except for scaling them yourself)
  • akramparvez
    Offline / Send Message
    akramparvez polycounter lvl 8
    Nothing wrong with your code, the maxscript command itself is incomplete. stitchVerts command does not have input parameter for "Scale Clusters" which is available in the UI, so the UVs are not scaled. Alternative is to set the values first using the dialog and use the command stitchVertsNoParams.
  • SimonT
    Offline / Send Message
    SimonT interpolator
    Thanks for the answers. Specter do you know a "simple" way to scale down the shells? I mean i didn't checked out the help file but normally handling UVs is never easy with Maxscript, right? :D
    akramparvez (crazy name :) ) for me it didn't worked to use the ...noparams() with setting the default values before. Does it work for you? I use 2010 SP1 x 64.
  • SpeCter
    Offline / Send Message
    SpeCter polycounter lvl 14
    Unfortunately i don´t :D

    But you could take a look at how textools did it(as far as i remember it hat a stitch button which did exactly what you are trying to do.
  • SimonT
    Offline / Send Message
    SimonT interpolator
    I checked textools already and the stitching works like expected: not :D Has exactly the same problem.
  • akramparvez
    Offline / Send Message
    akramparvez polycounter lvl 8
    yeah it didn't work for me either. I thought it should work as the name suggests.
  • akramparvez
    Offline / Send Message
    akramparvez polycounter lvl 8
    A Hacky way to do this
    -- Using the dialogMonitorOPS and UIAccessor to change the
    -- checkbox and press OK.
    fn stitchDialogHandler = 
    (
        WindowHandle = DialogMonitorOPS.GetWindowHandle()
        dialogName = UIAccessor.GetWindowText WindowHandle
        if dialogName == "Stitch Tool" then (
            children = UIAccessor.GetChildWindows WindowHandle
            for childHandle in children do (
                childText = UIAccessor.GetWindowText childHandle
                if childText == "Scale Clusters" then (
                    UIAccessor.sendMessage childHandle (BM_SETCHECK = 0x00f1) (BST_CHECKED = 0x0001) 0
                )
            UIAccessor.PressButtonByName WindowHandle "OK"
        )
    )
    
    DialogMonitorOPS.RegisterNotification stitchDialogHandler id:#stitchDialogHandler
    DialogMonitorOPS.Enabled = true
    
    --Call stitchVertsDialog
    $.modifiers[1].stitchVertsDialog()
    
    DialogMonitorOPS.Enabled = false
    DialogMonitorOPS.unRegisterNotification id:#stitchDialogHandler
    
  • SimonT
    Offline / Send Message
    SimonT interpolator
    I used a very similiar script but it didn't worked well. Did you used yours excessively? In my case (with my own script) sometimes the stitch dialog callback was noticed but the script-click to the button wasn't made. I don't know why. Maybe sometimes the window is to slow and the press-message is sent too fast. But sometimes it worked but then it made weird things in the UV editor. Do you know that case, when you grab and move a UV shell and it moves twice as fast as your mouse? This thing happened to me after using my callback script. Not immediately - but after a few times...
  • SpeCter
    Offline / Send Message
    SpeCter polycounter lvl 14
    Correct me if i´m wrong but as far as i remember it had 2 behaviours?
  • SimonT
    Offline / Send Message
    SimonT interpolator
    What do you mean Specter?
  • akramparvez
    Offline / Send Message
    akramparvez polycounter lvl 8
    SimonT wrote: »
    I used a very similiar script but it didn't worked well. Did you used yours excessively? In my case (with my own script) sometimes the stitch dialog callback was noticed but the script-click to the button wasn't made. I don't know why. Maybe sometimes the window is to slow and the press-message is sent too fast. But sometimes it worked but then it made weird things in the UV editor. Do you know that case, when you grab and move a UV shell and it moves twice as fast as your mouse? This thing happened to me after using my callback script. Not immediately - but after a few times...

    I haven't used it and the press message is only sent after the window handle is found so it should work, you could test it.
  • SimonT
    Offline / Send Message
    SimonT interpolator
    Other question

    Do you guys know how i can finde the corresponding Edge in the UV Editor? You know, when i select an edge, the other one is "slighty" selected also shown by another color.

    Normally i would use the function to give me the geometry edge but this function seems broken since some time and only returns "undefined".
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    SimonT wrote: »
    Other question

    Do you guys know how i can finde the corresponding Edge in the UV Editor? You know, when i select an edge, the other one is "slighty" selected also shown by another color.

    Normally i would use the function to give me the geometry edge but this function seems broken since some time and only returns "undefined".
    1. Convert a UV vertex selection to a Geometry vertex selection
    2. The resulted Geo vertex select and now convert to UV selected verts
    3. substract your inital edge to vertex UV selection
    you should have the counter vertex selection in UV space which you can convert back to an edge selection.


    In TexTools (open mzp with ZIP app) there is a fn_32__symmetry.ms file. Inside it I used a set of code like this
    ---------{  build up the uvVerts and meshVerts relation array  }----------
    local numMapVerts = uv.unwrap.NumberVertices();--just from the base, not the current edit!!!!
    local mapVerts2Verts = for mv=1 to numMapVerts collect #();
    local numMapFaces = uv.unwrap.numberPolygons();
    for f = 1 to numMapFaces do (
    	local polyFace = polyOp.getFaceVerts obj f;
    	for mv=1 to (uv.unwrap.numberPointsInFace f) do (
    		local mapVert = uv.unwrap.getVertexIndexFromFace f mv;--face, sub vert
    		if findItem mapVerts2Verts[mapVert] polyFace[mv] == 0 do(
    			append mapVerts2Verts[mapVert] polyFace[mv];
    		)
    	)
    )
    

    You need to do this once with every operation because it will give you the pairings of UV vertices and Geo vertices. Have a look at the symmetry script further on because it uses similar techniques you are after - like an initial UV edge selection, then a convertion to Geo vertices etc.
Sign In or Register to comment.