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
it's true, thanks you :)
it's true, thanks you :)
File upload error..
this comes and goes...sometimes I waited til next day..it then worked...
or simply upload pic somewhere that's bombproof...then just paste the link here...
Yo mawou, thanks for all the
Yo mawou, thanks for all the explanations and the video you made, you're the boss! but as me, it's not possible to select layers inside another layer? this: ".nodes &objsArr" doesn't collect layers also?
fn SelectObjectsInLayer layerName: = -- list of layers founed to founded in the layer "Clones":
(
local objsArr
(LayerManager.getLayerFromName layerName).nodes &objsArr --is it possible to filter only the layers founded (first childs)?
objsArr -- return the selected layer
)
objsInLayerArr = SelectObjectsInLayer layerName:"Props"
select objsInLayerArr -- here the layers aren't selected
.
I thought that you want to select only the objects in the layer, not the objects in the nested layers.
Can you post an image to show how your layers are organized and which objects do you want to be selected?
Tools and Scripts for Autodesk 3dsMax
--HEllo MIIAU, sOrry Again
--HEllo MIIAU, sOrry Again and Again, but as i'd never work without js in softimage , and it's the last script that i need, i feel totaly lost in maxscript ...
-- About operations on layers, nothing appened, what did i miss? i thought "SelectObjectsInLayer" will select childs, but no.. (ligne 12)
-- it's possible to use the sign OR in this way in maxscript? (ligne 28)
-- why is my mergeMaxFile variable false? (ligne 31)
-- always my probleme to select a layer... (ligne 35)
-- Can you tell to me the way to put a variable string in a selection set? (ligne 41)
-- how to write and save a message log (in a.txt file)? (ligne 46)
fn SelectObjectsInLayer layerName: = -- list of layers founed to founded in the layer "Clones":
(
local objsArr
(LayerManager.getLayerFromName layerName).nodes &objsArr --is it possible to filter only the layers founded (first childs)?
objsArr -- return the selected layer
)
objsInLayerArr = SelectObjectsInLayer layerName:"Props" -- here nothing appened
select (
if objsInLayerArr.count != 0 do
(
for o in objsInLayerArr do
(
arrAsset = (o.name)[1] -- find the first letter of the layer's child name
if arrAsset == "" do
(
strArr = filterString o.name "_"
arrNum = strArr[strArr.count - 1] -- find the Number of the layer's child name (NameAsset)
arrName = strArr[1] -- find the Name of the layer's child name (NameAsset)
if arrAsset == "A" do
(
Mergepath = "Z:\\LL_common\\models\\A_MP_Persos\\"
if (arrNum != "") || (arrName != "") do
(
arrNum2 = arrNum[slice 2] -- slice the 2 first digits (arrNum=A001 > arrNum2=01)
mergeMaxFile @"+Mergepath+"MP_"+arrNum2+"_"+arrName+"\AutoRIG\"+o.name+".max" #select #neverReparent #autoRenameDups #useMergedMtlDups missingDLLsAction: #default quiet:true
-- Path expected: mergeMaxFile @"G:\models\A_MP_Persos\MP_01_Danael\A001_Danael.max" #select #neverReparent #autoRenameDups #useMergedMtlDups missingDLLsAction: #default quiet:true
layer = LayerManager.getLayerFromName "Characters" -- find layer Characters
for n in (selection as array) do layer.addNode n -- put the mergeMaxFile in layer "Characters"
)
NewMaster = arrName + "_Setup_Ctrl_MasterWalk_C_O_G" -- New Master
OldMaster = "Old_"+arrName+"_A0_"+arrName+"_Master" -- old Master
)
)
select (#() + $NewMaster + $OldMaster) --how to select 2 strings variables?
for n in (selection as array) do n.isFrozen = False --unFrozen selection
for n in (selection as array) do n.isHidden = False --unHide selection
NewMaster.transform = OldMaster.transform --align masters
)
else ( print " Asset not find ! " + layerName) -- write and save a message log (in a.txt file)?
)
)
.
Watch this video to see that the part of the script that selects the objects in the layer works properly: https://dl.dropboxusercontent.com/u/35093423/Other/Videos/Layrs_001.mp4
Tools and Scripts for Autodesk 3dsMax
hello again and thanks to be
hello again and thanks to be so patient,
do you know how to call a script inside another one, like in .js the command: Application.ExecuteScript ( oScriptPath + "MakeScript.js")
and what do you think aboutBatch it Max? it don't look to make the job??
Do you know another way to run a script in batch in severals scenes at once, and save them like it?
.
To run a script inside another one you have to use the FILEIN command.
Batch in 3dsMax works ok. There are a lot of scripts in the forum that uses Batch to do differnet kind of tasks.
Tools and Scripts for Autodesk 3dsMax
Hello Miaou, Since i'd tryied
Hello Miaou,
Since i'd tryied this, and all my problems seems to be gone with mergeMaxFile :
mergeMaxFile @"Z:\LL_common\models\A_MP_Persos\MP_01_Danael\AutoRIG\A001_Danael.max" #select #neverReparent #autoRenameDups #useMergedMtlDups missingDLLsAction: #default quiet:true
thanks a lot, again for for your patience,
but do you know why nothing appened when i try to move the layers? it answer me: OK and make nothing
i think i miss something very simple and essential...because i like your idea to make the script faster like doing object mode:
(
-- get the objects from the layer with the name "Layer001"
fn SelectObjectsInLayer layerName: =
(
local objsArr
(LayerManager.getLayerFromName layerName).nodes &objsArr
-- return the selected objects
objsArr
)
objsInLayerArr = SelectObjectsInLayer layerName:"Props"
-- move those objects to a layer with the name "Layer002"
layer = LayerManager.getLayerFromName "Clones"
for n in (selection as array) do layer.addNode n
)
.
Your code for moving objects in Clones layer not works, because the script moves only the selected objects. If no objects are selected then there will be no moved objects.
If you want to move the objects, selected from the Props layer, then see the code below.
Tools and Scripts for Autodesk 3dsMax