Home Coding, Scripting, Shaders

Maxscripts - Stuffs I use and whatnot

1
Gonna post some scripts I use regularly.


Super Smart Create.
Based on a script by Perna, and with help from Miauu.
I use it assigned to letter C (because create :D) and depending on the subobject I am in it does diferent thing. Plus it works in both Editable Poly and the Edit Poly modifier.

Divides the selected edge in 2, putting a vert in the middle of the edge.
1_001.gif

Connects the selected edges if there is faces inbetween the edges.
2_001.gif

Caps selected borders
3.gif

Bridges selected edges.
4.gif


When you select 2 adjacent edges it creates a face.
6.gif

Bridges selected polies.
5.gif


Super Smart Create


And all this while just pressing the letter C.

I will post some more stuff in the mean time.
Thanks

Replies

  • monster
    Offline / Send Message
    monster polycounter
    Love these kinds of context sensitive tools.
  • skankerzero
    10 / 10 Will bang and call again the next day.
  • Justin Meisse
    Offline / Send Message
    Justin Meisse polycounter lvl 18
  • maxivz
    Offline / Send Message
    maxivz interpolator
    this is great, going to try this
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Are you using perna's SO mode select? If so what kind of hotkeys do you use when you have edit poly mode? Or did you bind separate smart keys for edit poly mode :)
  • RN
    Offline / Send Message
    RN sublime tool
    for child in (windows.getChildrenHWND dF) where child[4] == "#32770" do
    
    Miauu is invoking some powerful sorcery here.

    It reminds me of the experts at CGSociety compiling C# programs with MaxScript to access the Windows API: http://forums.cgsociety.org/showpost.php?p=7280793&postcount=15
  • Joltya
    Offline / Send Message
    Joltya polycounter lvl 10
    Looks super cool! Tagging for later
  • SuperFranky
    Offline / Send Message
    SuperFranky polycounter lvl 10
    Hmm, interesting. Might try it out later.
  • Pedro Amorim
    Kryzon wrote: »
    for child in (windows.getChildrenHWND dF) where child[4] == "#32770" do
    
    Miauu is invoking some powerful sorcery here.

    It reminds me of the experts at CGSociety compiling C# programs with MaxScript to access the Windows API: http://forums.cgsociety.org/showpost.php?p=7280793&postcount=15


    Dude I know right?
    I have no clue what his code does. Only that it works hehe, so I'm fine with that.
  • ZombieWells
    Offline / Send Message
    ZombieWells polycounter lvl 12
    My script did everything with the exception of "When you select 2 adjacent edges it creates a face." which I feel might be more handy so I'll give it a go. Interesting enough, it goes in to Create mode if you select a single poly. I have no clue what I am going to do with that :) but it could be useful? Thanks for sharing!
  • Pedro Amorim
    I don't question the sourcery behind it. It just works though :D
  • gauss
    Offline / Send Message
    gauss polycounter lvl 18
    ohhh man this is a windfall for my current work. awesome, thank you so much for sharing it (and for skanker for highlighting it on the fb group)
  • Popeye9
    Offline / Send Message
    Popeye9 polycounter lvl 15
    Really nice, thanks! Been playing with it this morning and has already saved a ton of time.
  • miauu
    Offline / Send Message
    miauu polycounter lvl 13
    perna wrote: »
    Awes, blood

    This:

    Any reason not to just use the default macros which toggle Command Mode?
    macros.run "Editable Polygon Object" "EPoly_ECreate" -- FCreate, etc
    
    To show him how to press a button in Command Panel. The code can be used(with little modifications) to press any button in Create, Modify, Hierarchy, Motion, Display, Utilites tabs. :)
  • huffer
    Offline / Send Message
    huffer interpolator
    Awesome script. I see that with two vertices selected it connects them with an edge, any chance to make it so they're welded together when connecting them isn't possible (when they're on different shells or don't share a polygon)?
  • rollin
    Offline / Send Message
    rollin polycounter
    can I now build my models by just pressing C?


    noicee :)
  • Pedro Amorim
    huffer wrote: »
    Awesome script. I see that with two vertices selected it connects them with an edge, any chance to make it so they're welded together when connecting them isn't possible (when they're on different shells or don't share a polygon)?


    That could be possible but actually it should be another script. This one is called smart create because you are creating geometry.

    When you weld you are reducing geometry so it falls outside the scope of this script.

    I use another stuff for that.

    I use the letter X for deleting geometry.
    And then, ctrl+X for detaching geo.
    Alt+X for collapsing geometry.
    And shift+X for deleting edges and verts but keeping faces.

    So C for creating and X for deleting/reducing.


    Another thing I also use that sometimes is useful is a script from Miauu assigned to J. It welds all the verts selected to the last vert you selected.

    But you know, I'll update this thread this week with other stuff when I have time.
  • nyx702
    Whoa looks awesome. Will give it a try. So can you just go ahead and redo the rest of max to be like this?
  • SideEffect
    Offline / Send Message
    SideEffect polycounter lvl 19
    Thanks Pedro!

    This inspired me to try and make a Maya version of this script.
    It works great so far on Maya 2014.

    Can't do bridges for adjacent edges though. Probably could force it to but that's more than I want to mess with right now.

    Selecting 2 verts and connecting them with an edge doesn't work either. I find this really weird that Maya has no command for that having come from Max (As do many others from my searching haha). Could also probably get that working but more than I want to mess with.

    I'm going to try it on Maya 2010 at work tomorrow.
    I'll post it up if that works out alright.
  • Spatz
    Offline / Send Message
    Spatz polycounter lvl 13
    nyx702 wrote: »
    Whoa looks awesome. Will give it a try. So can you just go ahead and redo the rest of max to be like this?

    +1 please



    ...and thanks a lot for posting and sharing :thumbup:
  • crazy
    Offline / Send Message
    crazy polycounter lvl 10
    well everything works except for connecting edges in Maya 2010

    Apparently there was no command that did that till Maya 2011 O_o

    I'll post the Maya 2013 script later tonight
  • SideEffect
    Offline / Send Message
    SideEffect polycounter lvl 19
    ^ whoops that was me
  • airbrush
    Offline / Send Message
    airbrush polycounter lvl 13
  • Pedro Amorim
    :) I'm gladd you guys like it.
  • kary
    Offline / Send Message
    kary polycounter lvl 18
    Great stuff Pedro, been using Perna's for years and it's good to see people advancing the good fight :).

    Is the global delete like this:
    macroscript GlobalDelete
    category:"Your Category"
    buttonText:"Global Delete"
    toolTip:"Global Delete"
    (
    if (classOf (modpanel.getcurrentobject()) == Editable_Poly) then
    	(
    	if (subobjectLevel == 1) then
    		(
    		$.EditablePoly.Remove ()
    		)
    	if (subobjectlevel == 2) then
    		(
    		case (getSelectionLevel $) of
    			(	
    			#Vertex: $.EditablePoly.Remove selLevel:#Vertex
    			#Edge:
    				(
    				sel = #{}
    				edgesel = polyOp.getEdgeSelection $
    				vertsel = polyOp.getVertsUsingEdge $ edgesel
    				$.EditablePoly.Remove selLevel:#Edge
    				for i = 1 to vertsel.numberset do
    				if ($.GetVertexEdgeCount (vertsel as array)[i]) == 2 then sel = sel + #{(vertsel as array)[i]}
    				polyop.setVertSelection $ sel
    				$.EditablePoly.Remove selLevel:#Vertex
    				)
    			#Face:
    				(		
    				sel = #{}
    				facesel = polyOp.getFaceSelection $
    				edgesel = polyOp.getEdgesUsingFace $ facesel
    				for i = 1 to edgesel.numberset do
    				if (((polyOp.getEdgeFaces $ (edgesel as array)[i]) as bitarray)(facesel as bitarray)).numberset == 2 then sel= sel + #{(edgesel as array)[i]}
    				polyop.setEdgeSelection $ sel
    				$.EditablePoly.Remove selLevel:#Edge
    				)
    			)
    
    		)		
    		else
    			(
    			max delete
    			)
    		)
    	else
    	(
    	max delete
    	)
    )
    

    and your break script like Robert Fletchers?
  • Pedro Amorim
    No, I don't think so.

    Mainly because on the code you posted, when you are on vert mode, it just removes the verts. And sometimes i don't want to remove just the verts, but actually delete them.
  • Pedro Amorim
    I have these shortcuts for the delete stuff.
    UniRemover needs some work though. Only shift+x is using a custom script. All the other shortcuts are default max commands.

    X Delete objects.
    CTRL+X Deatch (poly)
    ALT+X Colapse (poly)
    SHIFT+X UniRemover





    Uni Remover
    macroScript UniRemover
    Category:"Pedro Scripts"
    Tooltip:"UniRemover"
    (
    fn EdgeRemove = (
    		sel = #{}
    		edgesel = polyOp.getEdgeSelection $.baseobject
    		vertsel = polyOp.getVertsUsingEdge $.baseobject edgesel
    		$.EditablePoly.Remove selLevel:#Edge
    		for i = 1 to vertsel.numberset do
    		if ($.GetVertexEdgeCount (vertsel as array)[i]) == 2 then sel = sel + #{(vertsel as array)[i]}
    		polyop.setVertSelection $ sel
    		$.EditablePoly.Remove selLevel:#Vertex
    		)
     local curObj = modPanel.getCurrentObject()
     	Case (classOf curObj) of
    	(
    	Editable_poly:	(
    				case (getSelectionLevel $) of
    				(
    				#Vertex: 	If subobjectLevel == 1 and $.selectedVerts.count > 1 Then
    						(
    						--$.EditablePoly.ConvertSelectionToBorder #Vertex #Edge
    						--EdgeRemove()
    						$.EditablePoly.Remove ()
    						)
    						Else
    						If subobjectLevel == 1 and $.selectedVerts.count == 1 then
    						try	(
    							$.EditablePoly.Remove selLevel:#Vertex
    							) Catch macros.run "Editable Polygon Object" "EPoly_Remove"
    				#Edge:	EdgeRemove()
    				#Face:	(
    					sel = #{}
    					facesel = polyOp.getFaceSelection $
    					edgesel = polyOp.getEdgesUsingFace $ facesel
    					for i = 1 to edgesel.numberset do
    					if (((polyOp.getEdgeFaces $ (edgesel as array)[i]) as bitarray)*(facesel as bitarray)).numberset == 2 then sel= sel + #{(edgesel as array)[i]}
    					polyop.setEdgeSelection $ sel
    					$.EditablePoly.Remove selLevel:#Edge
    					)
    
    				)
    			)
    	Edit_Poly:	(	Case (subobjectLevel) of
    				(
    				 1: $.modifiers[#Edit_Poly].ButtonOp #RemoveVertex
    				 2: $.modifiers[#Edit_Poly].ButtonOp #RemoveEdge
    				)
    			)
    	)
    )
    


    EDIT:
    yeah, this code needs some tweaks to work in edit poly.
  • Pedro Amorim
    drag and drop the script to your max viewport and then go to
    customize \ customize user interface.
    In the category choose Pedro Scripts and then assign smart create to letter C and save.
  • kary
    Offline / Send Message
    kary polycounter lvl 18
    Mainly because on the code you posted, when you are on vert mode, it just removes the verts. And sometimes i don't want to remove just the verts, but actually delete them.

    Very cool -- ty again!
  • SideEffect
    Offline / Send Message
    SideEffect polycounter lvl 19
    I'm scrapping the Maya one.
    It works great but if you undo a lot it has a chance of causing a fatal crash in Maya and I can't figure out a workaround.
  • Popol
    Offline / Send Message
    Popol interpolator
    Thanks for the script Pedro! I started using it at work and it's really making things easier.
  • martinszeme
    Offline / Send Message
    martinszeme polycounter lvl 8
    Thanks for the script! Could you also please share your UI Color presets? Looks great.
  • greyocto
    oh cool, I've also made my own scripts like this based on perna's hotkey post and it's really interesting to see how you did things differently. I'm going to add your create face bit in to handle stuff bridge doesn't work on.

    in my own "smart create" script I ripped a piece of code from shortcutter http://www.scriptspot.com/3ds-max/scripts/shortcutter to detect open edges for bridging.

    also I put connect autolooped if you select one edge, distance connect if you have two edges and regular connect if you have more than two. add vert in middle is on a modifier of this key.

    you guys should all should check out the universal scripts nik has been making as well, makes a lot of stuff much easier http://www.scriptspot.com/users/nik
  • Pedro Amorim
    I use max2012. So this color file is for 2012 http://www.edgesize.com/crap/MaxStartUI.clr


    I think after 2012 they started saving the color files as .clrx so I'm not sure it will work.
    :D
  • SimonT
    Offline / Send Message
    SimonT interpolator
    Looks very useful!
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    I use max2012. So this color file is for 2012 http://www.edgesize.com/crap/MaxStartUI.clr


    I think after 2012 they started saving the color files as .clrx so I'm not sure it will work.
    :D

    You can still use them. Gotta put * first into the field hit enter then go find it as max filters out anything not clrx. Awesome stuff Pedro. Passed it around at work.
  • trebor777
    Offline / Send Message
    trebor777 polycounter lvl 10
    Pretty sweet script :)

    Just tested the color scheme :) It's really comfy to work with this :D
  • martinszeme
    Offline / Send Message
    martinszeme polycounter lvl 8
    You can still use them. Gotta put * first into the field hit enter then go find it as max filters out anything not clrx. Awesome stuff Pedro. Passed it around at work.

    Hey cheers for the tip!
    Also thanks Pedro for sharing! Love this community. :)
  • Pedro Amorim
    If someone wants my dark color theme for windows.. feel free to download it.
    It's just dark colors on the windows classic theme.

    http://www.edgesize.com/crap/pedro.themepack


    Looks like this
    03d0472977.png
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Beautiful themes, so good on the eyes! Thanks man
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Not sure if this is a bug or if it is just me. If you have a single 1x1 plane and use supersmartcreate on 2 edges it creates a duplicate polygon rather than connecting the 2 edges. It does work fine though once you extrude another edge out.
  • Revel
    Offline / Send Message
    Revel interpolator
    Hey Pedro, I've got a similar script like yours (and ofcourse inspired by Per as well). I haven't try your script but just would like to know about the cut/ bridge function.

    Let's say on edge selection mode;
    - select 2 non-border edges and hit C it'll connect them
    - select 2 border edges and hit C it'll bridge them

    But what about when you select 2 border edges on a same poly opposite of each other (basically on a single floating poly; the left edge and right edge are selected), does it connect them? or bridge? The desired result should be connect, but on my script it'll do bridge, and still have no idea on how to fix that. What about on yours?
  • Pedro Amorim
  • Revel
    Offline / Send Message
    Revel interpolator
    @Pedro - tried your script and it did happened similar behavior with what I described above. You can test it on a single poly, select 2 opposite edges from that 1 poly and run the script, it bridge them instead of connect, cus it detect those as a 2 border edges. Do you have any idea on how to correct this?

    PS; I guess what tynew mention on his post above me as "If you have a single 1x1 plane and use supersmartcreate on 2 edges it creates a duplicate polygon rather than connecting the 2 edges" is the same behavior like what I mention, but it's not really duplicating the poly, it bridge the 2 selected edges.
  • Fwap
    Offline / Send Message
    Fwap polycounter lvl 13
    Yeah, using this script on a plane just bridges not connects.
  • Revel
    Offline / Send Message
    Revel interpolator
    I opened up my old script and think of a way to fix this, and I've come up with abit of a hacky way, but it seems to function ok;
    (
        local
        eInit = (polyop.getEdgeSelection $) as array;
        vTest1 = (polyOp.getVertsUsingEdge $ eInit[1]) as array;
        vTest2 = (polyOp.getVertsUsingEdge $ eInit[2]) as array;
        eTest1 = (polyOp.getEdgesUsingVert $ vTest1) as array;
        eTest2 = (polyOp.getEdgesUsingVert $ vTest2) as array;
        eCollect = #();
        bridgeEdge = false
        
        for n in 1 to eTest2.count do
        (
            eFind = findItem eTest1 eTest2[n]
            if eFind != 0 then append eCollect eFind
        )
        
        if (eCollect.count == 0) then
        (
            $.bridgeSelected = 1
            $.EditablePoly.Bridge ()
            bridgeEdge = true
        )
        
        if (bridgeEdge == false) do
        (
            -- put your connect the edge script here
        )
    )
    
    This part goes inside the case, instead of straight try to bridge the edges, with this additional script it filter whether those selected edges have any shared neighbour edges or not, if it is (means it's on the same poly) dont bridge, but connect them instead.

    Let me know if it's not working with you. Or any other neat way of doing it!


    PS; it's not working on a non plane object, damn..back to mxs editor!
  • Pedro Amorim
    Yeah, but like, that only happens when you have one single poly. Usually if you want to work around it just extrude some edges and you are good to go.

    I know of this limitation but it's like, I usually do more stuff to the place before start connecting and bridging stuff :)
  • monster
    Offline / Send Message
    monster polycounter
    I think it's just a logic approach, and I recommended a fix back on the WIP post about this tool: http://www.polycount.com/forum/showpost.php?p=2255769&postcount=11

    You can attempt to connect first, and if that fails then bridge.

    But ultimately your right. I'd probably have more than a quad when I start modeling. Usually a low poly cylinder or box.
  • Pedro Amorim
    monster wrote: »
    I think it's just a logic approach, and I recommended a fix back on the WIP post about this tool: http://www.polycount.com/forum/showpost.php?p=2255769&postcount=11

    You can attempt to connect first, and if that fails then bridge.

    But ultimately your right. I'd probably have more than a quad when I start modeling. Usually a low poly cylinder or box.



    Now, what i really wanted would be to make the script work when the Show End Result is toggled in with a, let's say, a shell modifier on top.
    When you put a shell mod, and go to the base editable poly and have the show end result turned on. if you try to you the tool, it spits out an error.
  • Revel
    Offline / Send Message
    Revel interpolator
    Yeah, mybe you're right, but me personally once a while I do start with a plane, so here ya go, my updated version for anyone that interested with a single plane poly:
    (
        eBorder = (polyOp.getOpenEdges $) as array -- border edges from current model
        eInit = (polyop.getEdgeSelection $) as array -- intial edges selection
        pInit = #() -- initial polys selection
        
        -- to collect list of polys from initial edges selection and put it inside pInit array
        for e in 1 to eInit.count do
        (
            pTest = (polyOp.getFacesUsingEdge $ eInit[e]) as array
            for p in 1 to pTest.count do
            (
                if (findItem pInit pTest[p] == 0) do append pInit pTest[p]
            )
        )
        
        if    (pInit.count == eInit.count) then -- filter for border edges AND loop of polys
        (
            eTest = #()
            
            for e in 1 to eInit.count do
            (
                if (findItem eBorder eInit[e] != 0) do append eTest eInit[e]
            )
            
            if (eTest.count == eInit.count) then -- if all of the selected edges are on border: bridge
            (
                -- BRIDGE
            )
            else -- if some of the selected edges are NON-border: connect
            (
                -- CONNECT
            )
        )
        else -- filter for non-border edges AND special case of single plane poly
        (
            -- CONNECT
        )
    )
    
    Obviously I can't tested it on any possible situation, but yeah probably just PM me if anyone found a script error, I won't hijack your thread Pedro :)

    PS: it's not working if any modifier stacked ontop of it like what Pedro mentioned.
1
Sign In or Register to comment.