Home Technical Talk

[MAXScript] Editable Poly vs Edit Poly

interpolator
Offline / Send Message
Revel interpolator
Hello guys,

I've been trying to make a "smart" script that combine many functions based on what sub object level I'm currently in and map it to a single hotkey, really inspired by Perna's thread a long while back.
Now my problem is I'm trying to figure out how to translate this Editable Poly code into an Edit Poly compatible;
$.bridgeSelected = 1
if ($.EditablePoly.Bridge () == false) do
(
    $.EditablePoly.ConnectEdges ()
)
It's based on miauu's Magic Hotkey script which I'm trying to expand more. Basically to check if the selection is on open edge it'll bridge them, if it's not then connect them. Code bellow just won't work;
$.modifiers[#Edit_Poly].ButtonOp #BridgeEdge
if ($.modifiers[#Edit_Poly].bridgeselected == false) do
(
    $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
)
Any idea?

Replies

  • miauu
    Options
    Offline / Send Message
    miauu polycounter lvl 14
    Revel wrote: »
    Hello guys,

    It's based on miauu's Magic Hotkey script which I'm trying to expand more. Basically to check if the selection is on open edge it'll bridge them, if it's not then connect them. Code bellow just won't work;
    $.modifiers[#Edit_Poly].ButtonOp #BridgeEdge
    if ($.modifiers[#Edit_Poly].bridgeselected == false) do
    (
        $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
    )
    
    Any idea?

    This works:
    (
        $.modifiers[#Edit_Poly].ButtonOp #BridgeEdge
        if ($.modifiers[#Edit_Poly].bridgeselected == 1) do
        (
            $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
        )
    )
    
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hey miauu, if using those somehow it run both of the codes, so after bridge it then connect it and that's not what I really want; is either bridge (on open edges) or connect (on closed edges). Is it possible to achieve that?

    I did try to use array and compare both of these two;
    edgeSel = $.modifiers[#Edit_poly].GetSelection #Edge
    openEdge = $.modifiers[#Edit_Poly].getOpenEdges()
    
    Check whether all of the selected edges are part of the open edges or not; if yes then do bridge, else connect. If edgeSel.count > part of the open edges; connect them (this work if one of the selected edges are on the border and the rest are closed edges). But since I'm new to MAXScript, I have no idea on how to proceed from those 2 lines, haha!
  • miauu
    Options
    Offline / Send Message
    miauu polycounter lvl 14
    (    
        $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
        if ($.modifiers[#Edit_Poly].bridgeselected != undefined) do
        (
            res = $.modifiers[#Edit_Poly].ButtonOp #BridgeEdge
        )
    )
    
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Heyy! that works! thanks miauu :D
    Btw, I'm wonder how did you come up with the solution? or just pure out of experience?
    And just an extra question, what does the 'res' means?
  • miauu
    Options
    Offline / Send Message
    miauu polycounter lvl 14
    The first code was: - first bridge, then connect, which cuses the problem - bridged edges are connected. But - first connect, then bridge. If the script can't connect, then it will try to bridge. If the script can connect, then it is impossible to bridge. Most important is to have the proper logic of how the things must happen. The code will comes after that.
    I forgot to remove the res variable. I used it to show me what the command will return, but since its return OK in any situations it is useless, so remove it from the code.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hmmm..I see, yeah that make perfect sense.
    But how come with the Editable Poly object it's working fine?

    The code for Editable Poly and Edit Poly for a same operation are just...different with one another. I don't think I will introduce Edit/ Editable Mesh into the code in the future, since I never use it anyway and adding mode headache, haha!
  • miauu
    Options
    Offline / Send Message
    miauu polycounter lvl 14
    Revel wrote: »
    Hmmm..I see, yeah that make perfect sense.
    But how come with the Editable Poly object it's working fine?

    The code for Editable Poly and Edit Poly for a same operation are just...different with one another. I don't think I will introduce Edit/ Editable Mesh into the code in the future, since I never use it anyway and adding mode headache, haha!
    It works for Editable Poly objects, because $.EditablePoly.Bridge() returns true if you can bridge the edges and false if you can't bridge them, while the same opration for Edit Poly mod always returns OK.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Ah! I see. Thanks for the explanation there miauu.
    I might ask few more questions here if I stumble across some problem again next time~
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    EDIT; Sorry, got it! using the bellow do the trick! :)
    case (classOf $.modifiers[1]) of
    (
        default:
        (
            -- block of codes for generic stuff
        )
    
        Unwrap_UVW:
        (
            -- block of codes for specified modifier
        )
    )
    
    Hey guys, is there any way to merge this blocks for undefinedClass and Edit_Poly together cus both contain the same thing?
    case (classOf $.modifiers[1]) of
    (
        undefinedClass:
        (
            max snap toggle
        )
        Edit_Poly:
        (
            max snap toggle
        )
        Unwrap_UVW:
        (
            case of
            (
                default:
                (
                    actionMan.executeAction 2077580866 "40132"
                ) -- end default
    
                (keyboard.altPressed and not keyboard.shiftPressed and not keyboard.controlPressed):
                (
                    $.modifiers[#unwrap_uvw].unwrap.snap ()
                )
            )
        )
    )
    
  • miauu
    Options
    Offline / Send Message
    miauu polycounter lvl 14
    Test if this works properly:
    objClass = classOf $.modifiers[1]
    case  of
    (
        (objClass  == undefinedClass):
        (
            max snap toggle
        )
        (objClass  == Edit_Poly):
        (
            max snap toggle
        )
        (objClass  == Unwrap_UVW):
        (
            case of
            (
                default:
                (
                    actionMan.executeAction 2077580866 "40132"
                ) -- end default
    
                (keyboard.altPressed and not keyboard.shiftPressed and not keyboard.controlPressed):
                (
                    $.modifiers[#unwrap_uvw].unwrap.snap ()
                )
            )
        )
    )
    
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yeah those totally legal, miauu. But at first I try to do like bellow;
    case (classOf $.modifiers[1]) of
    (
        (undefinedClass and Edit_poly):
        (
            ...
    
    Which breaks the code cus it freak out once I plugged in boolean value into class type, haha! I'm hoping it would be like "in class of undefined class and edit poly class, do the code bellow", but it's just working that way. I also try (undefinedClass or Edit_poly): instead of (undefinedClass and Edit_poly):, well it's just not work as well.

    So I'm wondering if "if statement" can have more then one condition in order for it to enter the code block bellow it? like "if (this or that) are true then do the code"?

    Currently for a multiple condition like that I'm using logic like "if (this) is true then if (that) is true then only do the code".

    Ah, I edited my previous post for my current solution :)
Sign In or Register to comment.