ScriptSpot

Forum topic · General Scripting

Stripping string names from selected

By brownpaperbag · 2015-09-09

Description

Hi, new user here , first off I must say what an amazing community.

I found this script and wondered how I could edit the string name of the selected object

ie selected objects are box_001 , dave_ , foobar_blahblah , instead I just want to strip everything away after the underscore of the name. Which will then build the layers and place the objects into the layer

(
if selection.count != 0 do
(
for o in selection do
(
objName = o.name
if (objLayer = LayerManager.getLayerFromName objName) == undefined then
(
objLayer = Layermanager.newLayerFromName objName
objLayer.addNode o
)
else
(
objLayer.addNode o
)
)
)
)

Kind regards

Rob

Comments (2)

brownpaperbag · 2015-09-13

Thanks so much for the pointer

r

.

miauu · 2015-09-10


(
	if selection.count != 0 do
	(
		for o in selection do
		(
			objName = o.name
			--
			nameArr = filterString objName "_"
			objNameWithout = nameArr[1]
			--
			if (objLayer = LayerManager.getLayerFromName objNameWithout) == undefined then
			(
				objLayer = Layermanager.newLayerFromName objNameWithout
				objLayer.addNode o
			)
			else
			(
				objLayer.addNode o
			)
		)
	)
)