S.O.S!!!

Hi,
I'm very new with maxscript,
and i need to deconcatenate (with split and slice?? like in js) some strings
and unfortunatly, i'don't have any idea how to do that:

--1 make a collection of all obj in the scene named "*_Master":

for h in $*_Master do print h.name

-- i obtain a list:
--"A135_gg_PersoName_Master"
--"B256a_AnimName_a_gg_Master"
--"B256a_AnimName_a_gg_Master"
--"B256a_AnimName_a_gg_Master"

-->2 i need to keep only the fisrt letter: "A" or "B" of each obj founded
-->3 make a condition: if it's A: split "_" to obtain: "PersoName"
-->4 find this PersoName folder and import it

if anyone can help me with this, it would be geat because i'm lost :(

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

(
	objsArr = for o in objects where (matchpattern o.name pattern:"*_Master") collect o
 
	if objsArr.count != 0 do
	(
		for o in objsArr do
		(
			firstChar = (o.name)[1]
			if firstChar == "A" do
			(
				strArr = filterString o.name "_"
				--	"if the PersoName is always the third element in the array use"
				persoName = strArr[3]
				--	"if the PersoName is before the _Master then use"
-- 				persoName = strArr[strArr.count - 1]
				--	<filename_string> must be the path to the file that you want to import
				importFile <filename_string> #noPrompt  
			)
		)
	)
)

You can't import a fodler. You can import a file. So, modify the script to works as you want.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.