CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-13-2013, 02:31 PM   #1
Puglin
New Member
portfolio
Puglin
magellan, Australia
 
Join Date: Feb 2013
Posts: 2
Selecting polygons?

Hey there-- I'm a rookie to MaxScript. I did a semester of programming a year ago but it's fair to say that I'm very new to that, too, and with this in mind I'd like a bit of help...

I've got a situation wherein I want to make a box, then make another box above it, convert them both to editable poly and attach one to the other, delete the adjacent faces and then weld those boxes together. I can do this by specifying the exact edges to weld together after deleting specific faces by name(because the edges on the bottom of the top box will always be edges 5 to 8, and the edges on top of the bottom box will always be edges 13 to 16 or something similar, and the bottom face of the box is always face 2, etc), so that works okay. I can then extrapolate from there to make it so I can run a for loop and continually stack and weld boxes together.

Firstly, this just feels messy, and secondly when you start attaching more geometry to the object the names (or rather, the numbers) attributed to edges and faces change-- so when you go to weld together edge 5 and 13, the edges that stick together are not the ones you were expecting. So is there a better way to select faces, i.e. a way to select only the topmost face, or the face on the top tier facing left, for instance?

Perhaps there's a kind of naming scheme that doesn't change for every new piece of geometry added?
 
Old 02-23-2013, 09:53 PM   #2
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 123
hey,

Im sure there are other ways of doing this but this is the way that popped into my head when i read your post.

1st, Dont rely on vertex/faces numbering when doing mesh ops, this is because max may reorder them at its own will so when you get to box 17 the numbers may not be what you expect

I don't know of any data that holds the mesh faces independently of the naming seen in max`s UI

2nd, If you stack boxes the way you are talking about just use 1 box and when making the box taller add an extra division minus 1 for the box cap. ie the box is two units high make it have 1 division, 9 high, 8 divisions etc, will give you the same result with a lot less hassle providing you want a uniform distribution of divisions.

3. If you do need to to delete faces that are opposing you can check the face normals with

Code:
polyop.getFaceNormal <Poly poly> <int face>


coupling this with a height check of the face canter will allow you to get the face facing in a particular direction at a certain height for you to extrude, and extruding would also give you the same result without attaching, AND extruding will allow you to have non-uniform distribution of divisions. There are scripts on the interweb to show how to find a face centre

hope that helps
 
Old 02-23-2013, 10:33 PM   #3
Ian31R
Expert
portfolio
Ian Adams
Freelancer
Kent, USA
 
Join Date: Aug 2011
Posts: 292
To get a face's center, use -
Code:
polyop.getFaceCenter <Poly poly> <int face> node:<node=unsupplied>

From the reference -
Code:
Returns the center of the face by taking the average of all its vertices. If <poly> is a node, or if <poly> is an Editable Poly and <node> is specified, the position returned is in the current coordinate system context. If <poly> is an Editable Poly and <node> is not specified, the return value is in the poly's local coordinate system.


Here's a way of getting faces that are between 1 and 5 in the z position -

Code:
FilteredFaces = for i = 1 to (polyop.getNumFaces $) where ( local FacePos = (polyop.getFaceCenter $ i Node:$) FacePos.z >= 1.0 and FacePos.z <= 5.0 ) collect i

Last edited by Ian31R : 02-23-2013 at 10:37 PM.
 
Old 02-24-2013, 12:23 AM   #4
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 123
nice didnt know of getFaceCenter()

 
Old 02-24-2013, 12:23 AM   #5
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:06 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.