ScriptSpot

Forum topic · General Scripting

uniquename + suffix

By citizenWOLF · 2017-07-27

Description

Hello!

I wonder how can i have uniquename and suffix in a single line code.
For instance if you run this line:


for points = 1 to 3 do (point size:1 name:(uniquename "Spine_"+"_helper"))

the output will be:

$Point_Helper:Spine001__helper @ [0.000000,0.000000,0.000000]
$Point_Helper:Spine001__helper @ [0.000000,0.000000,0.000000]
$Point_Helper:Spine001__helper @ [0.000000,0.000000,0.000000]

Notice that the objects in the scene don't have unique names at all. Objects has the same name!
I tried this line, but is not quite correct..


for points = 1 to 3 do (point size:1 name:(uniquename "Spine_") + "_helper")

the output is:

-- Unable to convert: "_helper" to type:

Long story short, it is possible in a single mxs line code, the final result to be:

$Point_Helper:Spine_001_helper
$Point_Helper:Spine_002_helper
$Point_Helper:Spine_003_helper

?

Thanks in advance,
-E.

Comments (6)

.

jahman · 2017-08-09

I wonder how can i have uniquename and suffix in a single line code.
Note that your last approach has nothing to do with a uniquename.

citizenWOLF · 2017-08-09

Well, i found an easier way to do it.


for p = 1 to 3 do point size:20 name:("BaseName_" + p as string + "_suffix")

Thank you for the help,
-M.

onliner

jahman · 2017-08-02

for p in (for i=1 to 3 collect point name:(uniqueName "point_")) do p.name += "_helper"

citizenWOLF · 2017-08-09

Yap. This is another good solution. Thanks!

miauu · 2017-08-02

I don't know why you need one line solution, but:


(
	pointsArr = for points = 1 to 3 collect(point size:1 name:(uniquename "Spine_"));for p in pointsArr do p.name += "_helper";
)

I prefere this way of coding:


(
	pointsArr = for points = 1 to 3 collect
	(
		point size:1 name:(uniquename "Spine_")
	)
	for p in pointsArr do p.name += "_helper"
)

citizenWOLF · 2017-08-09

Thanks for the help miauu!