INSIDE 3DS MAX® 7 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

INSIDE 3DS MAX® 7 [Electronic resources] - نسخه متنی

Adobe Creative Team

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











  • Getting into the Mindset


    Turning MAXScript into an effective part of your workflow may require you to pick up some new habits. This section contains a number of tips about how to approach writing code before we get into the specifics of actually writing any.

    Start with Pseudocode


    Pseudocode is code that is not specific to any programming language. It is the set of instructions for a script. Pseudocode is probably more important than the code itself; if you can see logically what you want a script to do, the rest is just translating that into the syntax that MAXScript understands. Think of it in artistic terms: After you've decided on the overall composition of a piece, you can then worry about filling in the details.

    Use the MAXScript Reference


    I cannot recommend enough using the online help. When I'm scripting, I refer to that document every few minutes. The MAXScript Reference is a bit like a foreign language dictionary. You use it to translate your pseudocode into valid MAXScript.

    The help is less helpful when it comes to questions of overall grammar or program structure, although a number of excellent how-to examples have been added to the MAXScript online Reference for this version.

    You can also use the MAXScript online Reference to determine what can and can't be done. Not everything in 3ds max is scriptable, particularly in parts of the program that have changed little since before MAXScript entered the picture in version 2 of the application. In these cases, the online Reference will let you know, which can potentially save you a lot of fruitless work. For example, the entry for loft states, "Loft compound objects are not constructible by MAXScript."

    Steal


    If you don't know how to do something, find someone else's script that does something similar and then adapt it until it does what you want it to do. This practice is common, and it will save you from rewriting a lot of code that doesn't need to be reinvented. Looking at someone else's program structure can also teach you new ways of approaching problems or streamlining your code. Remember, if a substantial part of your code (or even just a function or two) belongs to someone else, it's good manners to credit that person somewhere in your script. Check the licensing agreement that comes with any script you're editing to make sure the author doesn't mind, or email the person and ask. Who knows, maybe the author can be even more help. For a good place to get scripts written by other users, try www.scriptspot.com.

    Use the Macro Recorder, but Don't Rely on It Completely


    In the MAXScript menu you'll find the Macro Recorder, which echoes commands you perform in the interface. For example, if you want to write a script that makes spheres, turn on the Macro Recorder and make a sphere in your interface; a command like the following appears in the Macro Recorder (you may have to open the MAXScript Listener window to see the whole command):

    [View full width]

    Sphere radius:6.57503 smooth:on segs:32 chop:0 slice:off sliceFrom:0 sliceTo:0 mapCoords
    :on recenter:off pos:[-2.50576,-0.672316,0] isSelected:on

    If you want to create a sphere in your script, you now have an example of how to approach the task. For simple scripts, you can record a series of events in this manner and then just drag the text from the Macro Recorder to a toolbar. A button will appear, and anytime you press that button, it will repeat the actions.

    Note

    The Macro Recorder does not echo everything that's scriptable, nor does it always generate correct code. Something in max might be scriptable but not appear in the Macro Recorder. In some instances the Macro Recorder will give you false information, and frequently the commands it outputs will include many optional parameters. Use it for what it's worth, and if your action doesn't appear in the Macro Recorder or doesn't work when pasted into your script, search the Reference fileit's probably still possible to write your script.

    Try to Generalize Code When You Feel It's Worth It


    In a production environment, often you make custom software to work only with the current situation. For example, suppose an animator has ten objects she wants to move along a surface in a specific fashion. You could hard-code your script to work only with those ten objects. This can be faster because you don't need to make a fancy interface and you can make certain time-saving assumptions on how these objects will react to your script. It also means, however, that your code is now throwaway, useful only in this one instance; if another job comes up where you're doing something similar, you have to rewrite a whole lot of code. Learn when to generalize and when to be more specific.

    One technique I use when I'm not sure if I'll be reusing a piece of code is to write a lot of comments in the script and then save it to a "quickies" folder in my scripts directory. If I need it again, I can generalize it later (or just plug in different hard-coded values) without investing a lot of effort in figuring out what I did.

    Get a Good Text Editor to Write Longer Scripts


    Although you can use the text editor that exists inside max (MAXScript menu > New Script), this editor has a major disadvantage: If your script crashes max, the script is lost, and possibly a bunch of work with it. I prefer editing my scripts in an outside text editor, such as Microsoft's Notepad or Helios Software's TextPad (www.textpad.com), which I now use exclusively. TextPad is cool for a number of reasons: It formats code better, its syntax highlighting is faster and more robust than the built-in editor's, you can search and replace in multiple documents at the same time (and with regular expressions), and it uses a tabbed interface for multiple files, which helps when you have multiple scripts that need editing at the same time.

    Note

    The one instance in which the built-in MAXScript Editor is indispensable is when using the Visual MAXScript (VMXS) utility to create interface elements. VMXS will only write its code to a MAXScript Editor window. You can then copy and paste the block of code out to TextPad.

    An evaluation copy of TextPad, as well as the MaxScript.syn file needed for TextPad's syntax highlighting features, is included on the DVD. Keep in mind that TextPad is commercial software, so you must register it if you use it past the evaluation period.

    Set Up TextPad for MAXScript



    1.

    Run the installer.

    2.

    Copy MaxScript.syn from the DVD to your Program Files\TextPad 4\system folder. (If you don't have the DVD handy, you can download the file from www.textpad.com/add-ons/synh2180.)

    3.

    Start TextPad and then choose Configure/New Document Class.

    4.

    In the wizard, enter MAXScript as the document class name and click Next.

    5.

    Enter *.ms,*.mcr as the class members and click Next.

    6.

    Check the "Enable syntax highlighting" check box, choose MaxScript.syn in the drop-down menu, and click Next.

    7.

    Verify your choices in the summary screen and click Finish.



    • / 193