Notifications
Clear all

[Closed] 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?

3 Replies

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.

  1. If you do need to to delete faces that are opposing you can check the face normals with
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

To get a face’s center, use –

polyop.getFaceCenter <Poly poly> <int face>  node:<node=unsupplied>
  From the reference -

     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 -

      
      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
      
      
      

nice didnt know of getFaceCenter()