Announcement

Collapse
No announcement yet.

Maxscript Smoothing Groups Remove

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript Smoothing Groups Remove

    I'm looking to remove smoothing groups through Macroscript. I've set up the following actions to help optimize my meshes:

    Code:
    macros.run "Modifier Stack" "Convert_to_Poly"
    subobjectLevel = 1
    actionMan.executeAction 0 "40021"
    $.EditablePoly.SetSelection #Vertex #{1..5000}
    $.EditablePoly.weldFlaggedVertices ()
    subobjectLevel = 4
    
    actionMan.executeAction 0 "40021"
    $.EditablePoly.SetSelection #Face #{1..5000}
    As you can see, I stopped it at faces so that I can manually deselect the smoothing groups (which for some unknown reason are applied to every imported objects.)

    When I recorded the removal, the scripting spat out errors. Also, I manually set the vertices and faces to select within a large range, but since I'm unfamiliar with the syntax, I didn't know how to specify 'all within a range' instead of 1-5000.

    Can anyone please help?
    LunarStudio Architectural Renderings
    HDRSource HDR & sIBL Libraries
    Lunarlog - LunarStudio and HDRSource Blog

  • #2
    so, let me get this straight, juju, you need to have ideally aa smooth operator set to no auto-smooth on top of your objects?
    The first line converts to Editable mesh the selected obj.
    The second selects all faces and sets them to smoothing 0.0 (no smoothing angle threshold).
    The third is needed so that ax updates the mesh in the viewports
    Code:
    convertToMesh $
    meshop.autoSmooth $ #{1..$.numfaces} 0.0
    update $
    You can skip the first line if the objects are already editable meshes (like in most imports).
    The macroscript macrorecorder only goes so far, lucky me :P

    Lele

    Comment


    • #3
      Hahahah. So you noticed that I've employed the macrorecroder then. Damn, and I was trying to fool people into thinking I'm semi-talented... Anyhow, this particular file is huge - probably a thousand or more objects that I was manually doing this conversion to (that's a lot of clicking.) Hence the need for a script (or to just suffer and render the beast of the file as is.)

      1) First I convert to poly from editable mesh.

      2) When I converted from editable mesh to poly on my imported models, they come in with extra vertices and faces - hence the weld operation.

      3) The objects then automatically have a smoothing group assigned, which I DON'T want in most cases for these particular files. I tried to macrorecord 'clear all' under the faces rollout but when I run the script, it spits out unexpected objects error.

      The things about macroscripting I don't know (in this particular task):

      1) How to select all vertices/faces within a model. Hence I specified 1-5000. I take it I can substitute your "#{1..$.numfaces}" to be the wildcard?

      2) How to get a 'working unsmooth.' I take it your code "#{1..$.numfaces}" will do the trick for me - I'll have to retest the script with your line later today.

      3) I don't know why it needs to updaet in the viewport but I trust you. All the other scripting in my code automatically updates the viewport. Perhaps this is something 'smooth' specific?

      Thanks Lele.
      LunarStudio Architectural Renderings
      HDRSource HDR & sIBL Libraries
      Lunarlog - LunarStudio and HDRSource Blog

      Comment


      • #4
        Originally posted by jujubee
        Hahahah. So you noticed that I've employed the macrorecroder then. Damn, and I was trying to fool people into thinking I'm semi-talented... Anyhow, this particular file is huge - probably a thousand or more objects that I was manually doing this conversion to (that's a lot of clicking.) Hence the need for a script (or to just suffer and render the beast of the file as is.)
        You need a slightly different code to be able to handle many objects at once. Will script sometimes soon, fairly messed up personally right now.

        1) First I convert to poly from editable mesh.
        In that case you might skip the operation and use the PolyOp methods.
        2) When I converted from editable mesh to poly on my imported models, they come in with extra vertices and faces - hence the weld operation.
        Clever that.
        3) The objects then automatically have a smoothing group assigned, which I DON'T want in most cases for these particular files. I tried to macrorecord 'clear all' under the faces rollout but when I run the script, it spits out unexpected objects error.
        limits of macroscript reached. need a human scripter

        1) How to select all vertices/faces within a model. Hence I specified 1-5000. I take it I can substitute your "#{1..$.numfaces}" to be the wildcard?
        Got that right.
        Need to specify an interval, so 1..$.numfaces specifies all the faces in the object selected

        2) How to get a 'working unsmooth.' I take it your code "#{1..$.numfaces}" will do the trick for me - I'll have to retest the script with your line later today.
        Not quite.
        Face selection interval is common across all the mesh /poly operations.
        Notice though i issued a COMMAND here: "meshop.autoSmooth" with a selection of faces, and a value for the command (0.0) .
        In plain english: autosmooth the selected faces with a smooth angle of 0.0 degrees.
        3) I don't know why it needs to updaet in the viewport but I trust you. All the other scripting in my code automatically updates the viewport. Perhaps this is something 'smooth' specific?
        It says so in the maxscript help, and names the update as a requirement to actually let max know the mesh has changed.
        It will then update the viewports.

        Thanks Lele.
        As they say in the WoW loading tips, a little kindness will take you a long way
        Thank you

        Lele

        Comment

        Working...
        X