Introduction to Maya plug-in development

Source: Internet
Author: User

Introduction to Maya plug-in development
Here I will provide a simple process for creating the Maya C ++ plug-in.
The author provides two versions of Mel and C ++ plug-ins to achieve the same function.
The background of this plug-in is like this. Most people are delighted to hear that maya8.5 has been released and can finally feel the new version of Maya. After hearing the news, Fang's boss was helpless and resentful. The following Mel and C ++ plug-ins both implement this idea.
Mel version:
Float $ maya_version = 8.5;
String $ boss = "bossfang ";
String $ person = "bossfang ";
If ($ maya_version = 8.5 & $ person! = $ Boss ){
Print ("Happy:) enjoy Maya 8.5/N ");
}

If ($ maya_version = 8.5 & $ person = $ boss ){
Print (": (XXX! XXX! Sign, why now? /N ");
}

Enter the Script Editor and run the script.

Figure execution mel

C ++ plug-in for maya7.0:
Execute the file in. Net | new | project ,.

Figure new project

In the Visual C ++ project, select mayapluginwizard, and then select the file path and give a name. Here I use the name of Boss.

Figure select mayapluginwizard

After you click OK, the Maya plug-in wizard automatically enters the plug-in Setup window and selects maya7.0 to create a plug-in for maya7.0. The installation path of Maya is also selected below, enter the author name.

Figure plug-in settings

Click plug-in type (plug-in type) on the left and select Mel command to create the Mel command plug-in. Enter the plug-in name. Set this plug-in to boss. In the future, enter boss in the command line, you can execute this plug-in.

Figure input plug-in name

Finally, click included libraries on the left side to set which library files the plug-in contains. For the simple plug-in we want to create, the default library is enough. Click Finish ).

Figure selecting the default Library

In this way, under the guidance of Maya plug-in Wizard, we have successfully created the required CPP file and inserted the code in the doit function.

Figure insert code into the doit Function

To include the required Maya header file at the top of the file.
# Include <Maya/mglobal. h>
# Include <Maya/mstring. h>
Add custom code to doit.

Figure Add the Maya header file and code

Finally, run generate | generate solution in. Net to get the. MLL file ,. The following describes how to load and use plug-ins.

Figure shows the. MLL file.

The following is all the code of the plug-in:

// Copyright (c) lizhihao
// File: bosscmd. cpp
// Mel command: Boss
// Author: Maya plug-in Wizard 2.0
//
# Include <Maya/msimple. h>
# Include <Maya/mglobal. h>
# Include <Maya/mstring. h>

Declaresimplecommand (boss, "lizhihao", "7.0 ");

Mstatus BOSS: doit (const marglist & ARGs)

{
Mstatus stat = MS: ksuccess;


Mstring Info;

Mstring boss ("bossfang ");
Mstring person ("bossfang ");
Double maya_version = 8.5;
If (maya_version == 8.5 & person = boss ){
Info = mstring (": (fuck! Fuck! Sign, why now? /N ");
}

If (maya_version = 8.5 & person! = Boss ){
Info = mstring ("Happy:) enjoy Maya 8.5/N ");
}

// Display string, equivalent to print in mel
Mglobal: displayinfo (Info );

Setresult ("boss Command executed! /N ");

Return Stat;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.