Notifications
Clear all

[Closed] no getFaceMatID function for Editable Mesh

Hi there,

First, I am new at Maxscript. I use Autodesk 3ds Max 2013.

I have a function that copies the material ID from one model to another. It works great when I use Editable Poly, but I have got problems with Editable Mesh.
I cannot use the function “getFaceMatID” (“setFaceMatID” neither) with Editable Meshes.

The Docs (and many forum threads everywhere) gave snippets like:

case classOf sel of
(
editable_poly: polyOp.setFaceMatID sel (polyOp.getFaceSelection sel) 7
editable_mesh: for i in (getFaceSelection sel) do setFaceMatID sel i 7
)

But if I use setFaceMatID, then I get the error: “no getFaceMatID function for Editable Mesh”.
For Editable_Poly it works wonderful.
Why?

Any ideas are appreciated!

UPDATE: I figured out that getFaceMatID works for Editable_Mesh, IF it is NOT a baseObject.
So


getFaceMatID $ 1

works fine, but


getFaceMatID $.baseobject 1

gives me the error

 No ""getfaceMatID"" function for Editable Mesh 

Are there any ideas how I can get and set the materialI IDs of the base object?

Kind Regards!

3 Replies

Yes, the TriMesh of the .baseobject is accessible through a property called .mesh

In other words, this works

obj = plane()
-->$Plane:Plane002 @ [0.000000,0.000000,0.000000]
convertToMesh obj
-->$Editable_Mesh:Plane002 @ [0.000000,0.000000,0.000000]
getFaceMatID obj.baseobject.mesh 1
-->1
setFaceMatID obj.baseobject.mesh 1 2
-->2
obj.material = multimaterial numsubs:2
-->#Multi/Sub-Object:Multimaterial(Standard:Material #25, Standard:Material #26)
obj.material.materialList[2].diffusecolor = red
-->(color 255 0 0)

I must agree though that it is not documented exactly in your face
If you look at http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/files/GUID-0532C071-4401-4846-8450-3DA5510A3883.htm
you will find


Constructors (TriMesh)
TriMesh()
Creates an empty TriMesh. Use the methods listed below to build the mesh.

<node>.mesh
Extracts a copy of a node’s world state if it is convertible to a mesh.

<editable_mesh_baseobject>.mesh
Extracts a copy of base object’s mesh.

In another mesh related topic, there is an example of accessing the .baseobject.mesh:

http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/files/GUID-BD473113-389F-4C96-BE07-217FF75796EF.htm


To access the selection from the EditableMesh base object when there are modifiers present on the stack, you should access the TriMesh value of the base object,
FOR EXAMPLE
getVertSelection $foo.baseobject.mesh

i believe that you are not really looking for a baseobject. the baseobject is an object state before modifier. you are probably has to look at mesh object which is current mesh state.

for example if you have an editable mesh node without any modifier. in this case its mesh and baseobject.mesh are the same.

$.mesh == $.baseobject.mesh -- true

but if you apply an Edit Mesh modifier the meshes become different:

$.mesh == $.baseobject.mesh -- false

edit mesh modifier might change your node geometry and topology so the number of faces and face ids can be different for mesh and baseobject.mesh.

just check what mesh you really need – current or before modifier…

Thanks to you both! That really helped a lot!
Now everything works fine! I am so happy right now