Keep 3DLuVr online!
3DLuVr Logo
Sections
Articles
 From the Real World
 Digital Painting Series
 Featuring of...
 On the Bookshelf
Tutorials
 3ds max
 LightWave3D
 Softimage XSI
 Rhinoceros 3D
 Video Tutorials
FunZone menu
 I always wanted to be
 Talk to an employer
 Why Ask "Why"
TechZone menu
 Hardware Reviews
 Software Reviews
 Benchmarking
 Q&A, Tips & Tricks
UserZone menu
 The Artist Sites
 15 Min of Fame
 Request an Account
 Current Assignment
 Sponsors & Prizes
 Make a Submission
 Voting Booth
 Competition Rules
About menu
 Mission Statement
 Policies
 Advertising
 Comments
 Poll Archive
 Links
 How to IRC
 Donations
Login
Log in to be able to post comments to the news items, forum posts, and other facilities.
Username: 
 
Password: 
Not registered? Register!     Lost Password?
Poll
 Your New Year`s Resolution is...
Gain employment
Stop smoking/drinking/etc
Get back in shape
Find the meaning of life
Conquer the World
Absolutely nothing

    Poll Results
Comments
Want to leave us a comment about the site or in general? Click here to access the form.
ArtZone Heading
Link Object to a Vertex
Added on: Mon Aug 14 2000
Page: 1 2 3 4 5 6 8 9 10 

Now it is time to add some actions to those buttons. First lets do the getvert_button. Type:

    on GetVert_Button pressed do (

    parentOBJ = $
    vertnum = (getvertselection parentOBJ)[1]
    vertnumL.text = "Vertex Number: " + (vertnum as string)
    VertPicked = true
    if ChildPicked == true do LinkME_Button.enabled = on

    ) -- Close on GetVert
Alright, a lot to explain here. The buttons work this way, you hit a button and the script looks through the defined "on statements" for what to do when that button is pushed.
This piece of script does this, "on Button_Name pressed do (........)"
is the generic form of the action. The only thing different with ours is we substituted GetVert_Button in for Button_Name.

It is easy to remember the syntax too. It is a shorten version of "When the button _____ is pressed do the following" All buttons, spinners, checkboxs, etc have syntax similar to this, however each one is slightly different.

The next line is "parentOBJ = $". The "$" is the character for
"the currently selected object". Since you are getting the selected object's vertex the script needs to know what object it is.

The "parentOBJ" is just a variable that I am assigning that object to.
So in the scene I provided, the parentOBJ will be the box. Now the next line is a little tricky.

"vertnum = (getvertselection parentOBJ)[1]" this assigns the vertex that is currently selected with the meshselect or editmesh modifiers to the variable "vertnum". The "getvertselection parentOBJ"
this is the actual function that gets the vertex number.

getvertselection takes one parameter (a mesh), in this case it is our parent object or the box.
The getvertselection function gives an array (fancy name for a list) back of all the selected vertices. Since we are only going to select one vertex the array will only have one number in it. This is where the "[1]" comes in. An array in MAXScript looks like this #(1,3,69,13).

To access the individual numbers in this array we use the following syntax.
Myarray[1] This will output 1, the first number in the array. Or Myarray[2] will output 3 or the second number in the array.
Since the getvertselection gives us the vertex in an array we have to extract that vertex number from the array.

By extracting the integer we can deal with a number (or integer) instead of a list of numbers. This is why the [1] is at the end of it. It outputs the first and only number in the array (our vertex) as an integer and saves it as the variable vertnum.



 
� 1997-2024 3DLuVrTM (Three Dee Lover)
Best viewed in 1024x768 or higher,
using any modern CSS compliant browser.