[Closed] getEdgeFace not working
Ok, create a cube, set the sides to 5 for all 3 axis. Add an editpoly modifier ontop. When I run this…
EditPolyMod.getNumEdges $.modifiers[1]
I get a proper value for the number of edges in the object. But when I run this…
EditPolyMod.getEdgeFace 2 1 $.modifiers[1]
I get “– Runtime error: Object does not implement this interface: EditPolyMod”. The maxscript helpfile is as cryptic as ever in explaining the syntax (like, is the index for the side 0 and 1 or 1 and 2?) Does anyone know what I’m doing wrong here?
- Neil
Instead of Edit_Poly or EditPolyMod, try using the actual instance of the Edit Poly modifier directly like so:
$.modifiers[1].getNumEdges()
$.modifiers[1].getEdgeFace 2 1
Since a lot of the epoly modifier and epoly object functions are identical, more help about certain methods can often be found in the epoly object section. Here’s some info on the getEdgeFace function taken from the reference:
Returns the face index used by the specified edge.
Since an edge can have two faces, the side argument is
needed to define which of the two possible faces to get.
Example:
p = convertToPoly(Plane()) --create a Plane, convert to Epoly
p.GetEdgeFace 18 1 --returns face 6
p.GetEdgeFace 18 2 --returns face 7
p.GetEdgeFace 4 1 --returns face 1
p.GetEdgeFace 4 2 --returns 0 as there is no second face
Hope this helps,
Martijn
Ah, thanks, that seems far more direct. I wonder why they even bothered putting that other method in the help file.
Good idea. I have become distrustful of looking in the editable poly page for edit poly stuff since a lot of the commands aren’t identical. For example, editablepoly has a function called GetEdgeFaces, and that doesn’t exist in Edit Poly, it will only get you a single face. So I have to get each face seperately, and then combine them to get the same output. But you’re right, I should look in there just in case it’s the same.
Speaking of dissimilarities, Editable Poly has a function called getFaceNormal which you invoke using polyOp.getFaceNormal. I can’t seem to find any way to get a face normal inside editpoly (at least in max8). Any idea if that’s possible?
- Neil
It’s either missing in the docs or I’m looking in the wrong places. However, this works:
$.modifiers[1].getFaceNormal 1
Here’s how to get a list of all available properties and methods for the Edit_Poly interface:
showInterfaces Edit_Poly
There are some other methods (eg. GetFaceCenter) that show up when you type the above in the Listener. Bobo might be able to tell you more about this. Like I said, I could very well be looking in the wrong places in the manual
Martijn
Thanks again. Yes, those are definately missing from the docs. Bobo, if you’re reading this, adding these to the max10 docs would be uber useful.
- Neil
D’oh! Are you using max9 perhaps? Because in max8 I still get an “Unknown property” error when I try and access the face normal.
- Neil
I’ll try it in max9 when I get home. And I’ll add code to my script so if you run the script in max8, it will only work on EditablePoly, wheras it will run both on editablepoly and editpoly in max9. Thanks for all the help.
- Neil
Just heard back that it might not be too late, will try to add it tonight… Cheers!
Awesome! And if you can add something about using $.modifiers[1] instead of using Edit_Poly or EditPolyMod, that would be really useful to the average person.
- Neil
This is actually how all max classes are documented. For example the Box : GeometryClass topic also shows (for example) <Box>.length indicating that you should replace <Box> with a node of class Box. If you get used to this syntax it actually makes sense
Martijn
I understand your point, but I feel my original point still stands. I feel that documenting things in this way leads to a lot of confusion (And Bobo, I know you’ve been working hard on fixing this stuff, so please forgive me if this is in any way harsh). But please, if you will, view this for a second from the position of someone just starting to learn maxscript.
You want to get the number of faces produced after an edit poly modifier. So you search and find the Edit Poly page. You are presented with a page that has NO example scripts, so you have no actual example code from which to draw any conclusions on how to actually modify an edit poly modifier. So since you can’t learn by example, you start by trial and error. So you look at the top of the page, it says…
Constructor:
EditPolyMod
Then you find the command you want and it says:
<integer>GetNumEdges node:<node>
So you think, ok, maybe that’s the command I need to use. So you try some code like this…
EditPolyMod.GetNumEdges $.modifiers[1]
And you get an answer of 300. Great, that code works! You have learned through trial and error that if you do a, you get b. Now from that experience, you move on. You want to get a face that is attached to a particular edge.
The help file says:
<index>GetEdgeFace <index>edgeID <index>side node:<node>
So, you say “This follows pretty much the same form as the other one, so obviously the following code should work”:
EditPolyMod.getEdgeFace 2 1 $.modifiers[1]
And you get an error.
So you can’t learn from example, learning by trial and error has failed since two similar commands do not work, so you ask for help on a forum. You find out what you needed to write is…
$.modifiers[1].getEdgeFace 2 1
This form is not discussed anywhere on this page. And the other form works for some things and not others. I’m sure you can see that this leads to the average person to become frustrated, since there’s no immediately obvious logic as to why one thing works, while something very similar does not, and the only way to get both to work is not discussed anywhere on the page that they went to for help.
So if there is any way to make this clearer in the helpfile, I think we will all appreciate it.
- Neil
Neil,
I completely agree and see where the confusion comes from.
I had already fixed all the interface methods to be prefixed with the < Edit_Poly > token to make it obvious how to use them.
Now I added this:
---------------------------------------------
[b]NOTE:[/b]
The EditPolyModInterface is a [b]Mixin Interface[/b] exposed by the [b]Edit_Poly[/b] modifier.
You can call the methods listed below as methods exposed by the Edit_Poly modifier itself because MAXScript will search both the modifier and all its Interfaces for the method name.
Thus, instead of saying something like
$Box01.modifiers[#Edit_Poly].EditPolyMod.GetSelection #Vertex
--or
$Box01.Edit_Poly.EditPolyMod.GetSelection #Vertex
you could say either
$Box01.modifiers[#Edit_Poly].GetSelection #Vertex
--or
$Box01.Edit_Poly.GetSelection #Vertex
The shorter form without specifying the Interface's name is not only more compact to write, it is also slightly faster to execute.
Of course, it is much better formatted (which is true for the whole reference).
What the heck is a Mixin Interface you ask?
Here is a good link:
http://sparks.discreet.com/knowledgebase/sdkdocs_v8/ref/main/html/class_f_p_mixin_interface.html
Detailed Description
See Also: Class FPInterface, Class FPInterfaceDesc, Function publishing.
class FPMixinInterface : public FPInterface
Description:
This class is available in release 4.0 and later only.
A “Mixin” interface provides a way for a plug-in to expose some of its functionality for use by other plug-ins or MAXScript. The notion of “Mixin” refers to the idea that the interface is a sub-class of the plug-in class and thus “mixed in” with it. Many classes in the SDK now inherit from FPMixinInterface in order to expose some of their functionality.
Developers should see the documentation for Class FPInterface for reference on this class as well.
For an overview of the function publishing system as a whole, see Function publishing.
Awesome Bobo. Even just one or two lines of example code is all you need to instantly communicate to the viewer how to do something. Can’t wait to check out the new Max10 documentation.
- Neil