PDA

View Full Version : Add object count to name string


em3
08-08-2009, 05:26 PM
The following code is selecting objects and welding their verticies. I am also trying to name each object appending an i to the end of the string. Pretty simple but it keeps throwing this error.

Unable to convert: 1 to type: String


(
Objs = for o in objects collect o

for o in Objs do
(
for i = 1 to objs.count do
(
x = o
x.name = o.name + "_mesh" + i

select o
subobjectLevel = 1
actionMan.executeAction 0 "40021"
$.EditablePoly.SetSelection #Vertex #{1..76}
$.EditablePoly.weldFlaggedVertices ()
subobjectLevel = 0
)
)
)


Where am I going wrong here?

MarcoBrunetta
08-08-2009, 05:43 PM
Instead of x.name = o.name + "_mesh" + i use x.name = o.name + "_mesh" + i as string

The problem is that you are trying to add string with integers, and, much like oranges and apples, they just don't mix. By using "i as string" you ask maxscript to transform it into a string, thus enabling the addition to work.

em3
08-08-2009, 05:48 PM
Makes perfect sense, thank you sir!

CGTalk Moderation
08-08-2009, 05:48 PM
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.