Home Technical Talk

custom maya button commands

polycounter lvl 13
Offline / Send Message
bcottage polycounter lvl 13
Long story short...im making a toolset that replicates the one similar in max to make life easier for myself.

Here is the button code for extrude:


bt0 = cmds.button( label='Extrude Face', width=203, command=cmds.'put command here' )

The command i want is the extrude one exactly the same as the extrude button in the 'Mesh Editing Tools'

im guessing i need to find the command then define it? how do i find this out?

Replies

  • perfect_paradigm
    Options
    Offline / Send Message
    perfect_paradigm polycounter lvl 7
    Not sure which extrude you're talking about but I think the code you're seeking is:
    PolyExtrudeFaces;
    

    or
    dR_extrudeTool;
    

    Though I'd rather have context sensitive extrude if it was a button than 3 buttons for each component. But I like the context-sensitive marking menus for extrude.

    A nice way to see what code is being executed when you enter a tool, run an action or change a setting etc., is to watch the code that's displayed in the script editor as you do those things.

    Window > General Editors > Script Editor


    Sometimes you have to turn on Echo All Commands to see the code you're seeking. Click clear history button first to clear irrelevant code before performing action you wish to get code for. Always turn Echo All Commands back off after finished since it can slow down Maya.

    Usually it will be the top line(s) of code that are needed as they usually call the others that are displayed so don't copy and paste it all, just test out the minimum lines of code and see if it does everything you're needing.

    History > Echo All Commands
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    You probably want to reference the documentation for commands and flags.

    http://help.autodesk.com/view/MAYAUL/2015/ENU/

    Gives you good documentation and example on how to use the commands. See you are talking about the extrude in the modelling toolkit. You definitely want to use the echo all commands Perfect mentioned about.

    If you are using python you need to import maya.mel and do
    import maya.mel as mel
    
    mel.eval("dR_extrudeTool;")	
    
  • bcottage
    Options
    Offline / Send Message
    bcottage polycounter lvl 13
    thanks guys. working nicely apart form one thing..the extrude comes with 15 divisions by default? how do i set this to just one?

    This is what i have so far:

    bt0 = cmds.button( label='Extrude Face', width=203, command=cmds.PolyExtrude )
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    if you are using PolyExtrude that isnt possible since PolyExtrude is just a script that runs either
    polyExtrudeEdge, polyExtrudeFacet, or polyExtrudeVertex based on your selection type.

    put say you wanted to do a face extrusion with only 1 division you could do this.
    btn01 = cmds.button(l='Extrude Face', w=203, c=lambda *args: cmds.polyExtrudeFacet(divisions=1))
    

    also you do realize that the most of the basic modeling operations are in the marking menus, just use shift+rmb and you get a menu around the mouse with your basic extrude, bevel, bridge, merge, cut tools. This menu is dependent on what component mode your in also.
  • perfect_paradigm
    Options
    Offline / Send Message
    perfect_paradigm polycounter lvl 7
    Passerby is correct. You could script it another way to run the proper extrude based on selected component, but by your label it seems you want it to only extrude faces.

    I encourage you to check out the marking menus which is my favorite thing about Maya. They're very fast, you don't have to wait for them to display, just drag as fast as you want after holding down shift + rmb. This allows quick access to actions and tools specific for whatever is selected. So for shift + rmb dragging down will extrude whatever component is selected, faces, edges or verts.

    I customized all my context sensitive marking menus because I dislike the defaults. Though for those marking menus you have to manually edit their mel files. If interested I can help with that.
  • bcottage
    Options
    Offline / Send Message
    bcottage polycounter lvl 13
    So much help :).

    I understand what you mean completely with the shift+rmb but this script is just to familiarise myself and any max users picking up Maya for the first time to help them ease in.

    Once I have the basic modelling tools from Max in one toolbar ported into Maya I will dish it out like candy to anyone that wants/needs to learn basic modelling tools. I am currently using Maya at Splash Damage but I always seem to prefer the 'toolbar look' I guess the max side of me loves the toolbar to much to let go :p.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    which maya version are you on? if our using 2014 or above there is the modeling toolset built in which has a toolbar that includes most modeling operations, as well as a few modified tools to offer things like pinch control on the connect tool like max users are accustomed too.
Sign In or Register to comment.