arnecls
02-28-2006, 12:58 PM
I've got a problem with polyOp.attach.
I want to attach polys and detach them by materialid after doing some operations on the merged poly.
The problem is, that attach() does NOT keep the materialIds as it should do.
The script works like this:
[...]
-- this happens in a loop, so there are different CurrentMatId per mesh
polyOp.setFaceMatID Mesh #all CurrentMatId
[...]
-- this happens in the same loop
MasterObject.EditablePoly.attach Mesh MasterObject
[...]
-- doing some stuff
[...]
-- another loop ...
-- Is there a function that does this part here?
Faces = #()
for Index=1 to (polyOp.getNumFaces MasterObject) do
(
if polyOp.getFaceMatID MasterObject Index == MatId then
Faces[Faces.count + 1] = Index
)
[...]
-- the same loop as above
polyOp.detachFaces MasterObject Faces asNode:true name:NewMeshName
NewMesh = getNodeByName NewMeshName ignoreCase:false
-- NewMesh can be undefined as MaterialIDs will be merged almost always
I stopped the workeflow after attaching the polys together and the materialids are definitly merged wrong there (had 1-3, got 1 and 2), so no problem with my "getByMaterialID" function.
Is there any hidden option to tell attach "keep that materialIds"? Didn't find anything in the Maxscript help.
What I found out is, that when I use the normal "attach" button, it asks me to keep MaterialIDs. If I check this, my script works like a charm, but it would be nice to automate this behavior.
Thanks
Arne
I want to attach polys and detach them by materialid after doing some operations on the merged poly.
The problem is, that attach() does NOT keep the materialIds as it should do.
The script works like this:
[...]
-- this happens in a loop, so there are different CurrentMatId per mesh
polyOp.setFaceMatID Mesh #all CurrentMatId
[...]
-- this happens in the same loop
MasterObject.EditablePoly.attach Mesh MasterObject
[...]
-- doing some stuff
[...]
-- another loop ...
-- Is there a function that does this part here?
Faces = #()
for Index=1 to (polyOp.getNumFaces MasterObject) do
(
if polyOp.getFaceMatID MasterObject Index == MatId then
Faces[Faces.count + 1] = Index
)
[...]
-- the same loop as above
polyOp.detachFaces MasterObject Faces asNode:true name:NewMeshName
NewMesh = getNodeByName NewMeshName ignoreCase:false
-- NewMesh can be undefined as MaterialIDs will be merged almost always
I stopped the workeflow after attaching the polys together and the materialids are definitly merged wrong there (had 1-3, got 1 and 2), so no problem with my "getByMaterialID" function.
Is there any hidden option to tell attach "keep that materialIds"? Didn't find anything in the Maxscript help.
What I found out is, that when I use the normal "attach" button, it asks me to keep MaterialIDs. If I check this, my script works like a charm, but it would be nice to automate this behavior.
Thanks
Arne
