Combine 2 string arrays in one string arrays

Hallo.

I am new on 3d max script and I have an idea to do a quick layer creator script.
My purpose is to create a few defined layer by base name entered in edittext. My script was half completed but I was stuck on other half of the codes. If someone could tell me how can I combine two different arrays by string variables into one array string I will be thankful to answerer.

This is my script written through me for the purpose.

------------------------------------

----- LayerCreator 0.1 -----

----- Global Varibles ------

global crtNewLayer ----- varable to create new layer
global lyrDefNames ----- string array for
global lyrNames
global bsNames

----- Definition of Global Variables --------

lyrDefNames= # ("_Mesh","_Controller","_Hiden") ------- layer names was defined in array

lyrNames=
(
fn cmbLyrNames=
if bsNames != undefined then
(
for n = 1 to lyrDefNames.count do
(
i= n
x=bsNames
append x lyrNames [i]
)

)
)

crtNewLayer =
(
---- The function for Create New Layers button ------
fn realiseLayers=
(
for n = 1 to lyrDefNames.count do -------- a loop to create each layer
(

i= n
x= lyrDefNames
y= layermanager.getlayerfromname x [i]
z= layermanager.newlayerfromname x [i]
if y != undefined then
z
)
)

)

rollout LayerCreator "LayerCreator 0.1" width:280 height:112
(
button crtLayers "Create New Layers" pos:[0,56] width:280 height:37 enabled:true toolTip:""
editText lyrBsName " Base Name of Layers" pos:[4,24] width:270 enabled:true

on lyrBsName entered txt do
(
if lyrBsName.text != "" then
(
bsNames = # (lyrBsName.text as string)
)
)

on crtLayers pressed do
(
crtNewLayer ()
lyrNames()
)

)
createdialog LayerCreator

----------------------------------------------------

Comments

Comment viewing options

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

............................

I can add afew more options on the script.

----- LayerCreator 0.1 -----
 
----- Global Varibles  ------ 
 
 
global crtNewLayer  ----- varable to create new layer
global lyrDefNames  ----- string array for 
global lyrNames      
global bsName
 
----- Definition of Global Variables --------
 
lyrDefNames= #() ------- layer names was defined in array 
lyrNames= #()
 
fn cmbNames= 
(
	if bsName != "" then 
	( 
		for i= 1 to lyrDefNames.count  collect
		append lyrNames (bsName + lyrDefNames [i])
	)
)
 
crtNewLayer =
(
	---- The function for Create New Layers button ------
	fn realiseLayers= 
	(  
		for n = 1 to lyrNames.count do         --------  a loop to create each layer
		(  
 
		   i= n
		   x= lyrNames 
		   y= layermanager.getlayerfromname  x [i]
		   z= layermanager.newlayerfromname x [i]
		   if  y != undefined then  
			   z	
		)
	)
)
 
rollout LayerCreator "LayerCreator 0.1" width:280 height:208
(
	groupBox Layers "Select Layers for Scene Objects" pos:[8,40] width:264 height:112
	checkbox lyrCameras "Cameras" pos:[144,88] width:120 height:24
	checkbox lyrController "Controller Objects" pos:[16,88] width:120 height:24
	checkbox lyrHiden  "Hiden Objects" pos:[16,120] width:120 height:24
	checkbox lyrLights "Light Objects" pos:[144,56] width:120 height:24
	checkbox lyrMesh "Mesh Objects" pos:[16,56] width:120 height:24
	checkbox lyrParticles "Particles" pos:[144,120] width:120 height:24
	edittext lyrBsName " Base Name of Layers" pos:[13,7] width:254 height:17 enabled:true
	button crtLayers "Create New Layers" pos:[8,160] width:264 height:37 enabled:true toolTip:""
 
	on lyrCameras changed theState do 
	(   
		if lyrCameras.checked == true then 
		(
			objCameras= "_Cameras"
		    append lyrDefNames objCameras
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrController changed theState do 
	(
		if lyrController.checked ==true then
		(
		   objController= "_Controller"
		   append lyrDefNames objController
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrMesh changed theState do
	( 
		if lyrMesh.checked==true then
		(
		objMesh= "_Mesh"
		append lyrDefNames objMesh
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrHiden changed theState do
	(
		if lyrHiden.checked==true then
		(
		objHiden= "_Hiden"
		append lyrDefNames objHiden
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrLights changed theState do
	(
		if lyrLights.checked ==true then
		(
		objLights= "_Lights"
		append lyrDefNames objLights
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrParticles changed theState do
	(
		if lyrParticles.checked ==true then
		(
		objParticles= "_Particles"
		append lyrDefNames objParticles
		)
		else
		(
			append lyrDefNames ""
		)
	)
 
	on lyrBsName entered txt do
	(
		bsName= lyrBsName.text
		cmbNames ()
	)
 
	on crtLayers pressed do 
	(
		crtNewLayer ()
	)
 
)
 
createdialog LayerCreator
barigazy's picture

...

It's difficult to understand what do you want to achive here.
Just tell me this.
If I type word in textbox let say "NewObjects" and press the "Create New Layers" button what should look final layer name string?

barigazy

Deman3D's picture

.........

Thanks for answer.
The final layer name will be the word in textbox plus every given layer name in the script. Such as " textbox" plus "_Mesh" after they had been combined will be "textbox_Mesh". The script will be an easy way to create specific layer names in complex scenes.

barigazy's picture

...

Ok. But U have array with predefined names (prefix)
lyrDefNames= # ("_Mesh","_Controller","_Hiden")
How can script know when need to use one of this items in combination with textbox text?

barigazy

Deman3D's picture

.....

The script is not ready yet completely. Predefined array is necessary for its purpose.

barigazy's picture

...

This is the simple concept

try(destroyDialog ::LayerCreator)catch()
rollout LayerCreator "LayerCreator 0.1" width:280 height:112
(
	label lbl "Layer Name:                                           Prefix:" pos:[5,5]
	editText lyrBsName "" pos:[0,20] width:190 height:17
	dropdownlist ddlist "" pos:[195,18] width:80 items:#("_Mesh","_Controller","_Hiden")
	button crtLayers "Create New Layers" pos:[5,45] width:270
	on LayerCreator open do setFocus lyrBsName
	on crtLayers pressed do
	(
		if lyrBsName.text == "" then messagebox "Define Layer Name" title:"Warning" beep:off else
		layName = lyrBsName.text + ddlist[ddlist.selection]
		if LayerManager.getLayerFromName layName == null then LayerManager.newLayerFromName layName else
		(
			 messagebox "This layer already exists!" title:"Warning" beep:off  
		)
	)
)
createdialog LayerCreator 280 70 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

Deman3D's picture

..........

Your idea is good but it's not what I am looking for.

Here it is my last codes for my idea, I want to add a few more things before publishing final result of script.

----- LayerCreator 0.1 -----

----- Global Varibles ------

global crtNewLayer ----- varable to create new layer
global lyrDefNames ----- string array for
global lyrNames
global bsName

lyrDefNames= #()
lyrNames= #()

fn cmbNames=
(
if bsName != "" then
(
for i= 1 to lyrDefNames.count collect

append lyrNames (bsName + lyrDefNames [i])

)
)

crtNewLayer =
(
---- The function for Create New Layers button ------
fn realiseLayers=
(
for n = 1 to lyrNames.count do -------- a loop to create each layer
(

i= n
x= lyrNames
y= layermanager.getlayerfromname x [i]
z= layermanager.newlayerfromname x [i]
if y != undefined then
z
)
)

)

rollout LayerCreator "LayerCreator 0.1" width:280 height:208
(
edittext lyrBsName " Base Name of Layers" pos:[13,7] width:254 height:17 enabled:true
button crtLayers "Create New Layers" pos:[8,160] width:264 height:37 enabled:true toolTip:""
groupBox Layers "Select Layers for Scene Objects" pos:[8,40] width:264 height:112
checkbox _Controller "Controller Objects" pos:[16,88] width:120 height:24
checkbox _Cameras "Cameras" pos:[144,88] width:120 height:24
checkbox _Mesh "Mesh Objects" pos:[16,56] width:128 height:24
checkbox _Hiden "Hiden Objects" pos:[16,120] width:120 height:24
checkbox _Lights "Light Objects" pos:[144,56] width:120 height:24
checkbox _Particles "Particles" pos:[144,120] width:120 height:24

on _Controller theState do
(
objController= "_Controller"
append lyrDefNames objController
)
on _Cameras changed theState do
(
objCameras="_Cameras"
append lyrDefNames objCameras
)
on _Mesh changed theState do
(
objMesh="_Mesh"
append lyrDefNames objMesh
)
on _Hiden changed theState do
(
objHiden="_Hiden"
append lyrDefNames objHiden
)
on _Lights changed theState do
(
objLights="_Lights"
append lyrDefNames objLights
)
on _Particles changed theState do
(
objParticles="_Particles"
append lyrDefNames objParticles
)
on lyrBsName entered txt do
(
bsName = lyrBsName.text
cmbNames ()
)
on crtLayers pressed do crtNewLayer ()

)

createdialog LayerCreator

miauu's picture

.

Post your code inside(without the quotes) to make it readable.

[""code""]

{""/code""}

barigazy's picture

Comment viewing options

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