ScriptSpot

Forum topic · General Scripting

select folder - write variable - show in textfield - beginner needs help

By dallchris · 2013-12-19

Description

Hi everybody.

i'm new to maxscript and i'm trying just a easy thing(not easy for me but for the professionals here yes) I want to create a rollout with a button "browse", where I can select a folder. for example c:\user\desktop\maps\. This path should be stored as a variable (and need it for an later action in the script) and should be shown in my edittext box and the user should be able to select and copy the path. for now it's half working with the attached script. But if I press a second time on the button "Browse" I can select another folder for example d:\materials the script changes the variable (for testing I used the print function) but did NOT show it in my edittext?Is there a kind of autoupdate function?

 

Is there anyone out there how can help me ???

thanks a lot in advanced and greetings chris

 

 

    rollout xx "Maps Path" width:800 height:496
(
   button btn_browse "Browse" pos: [124,10] width:60 height:16
    label choose "select maps path " pos:[8,10] width:112 height:16
 
   on btn_browse pressed do
   (
     dir = getSavePath caption:"Select Folder" initialDir:#images
    
       print dir
       
   )    
          edittext theedittextt "Path" text:dir

   )
    
   
rof=newrolloutfloater "Test"800 600
addRollout xx rof rolledUp:false

Comments (3)

perfect... solved

dallchris · 2013-12-20

thanks a lot this works very fine :) this was exactly I was looking for :)
now I can finish my script and start my xmas holiday :)

merry xmas to all

tassel · 2013-12-19

Hi,

I am not sure that i understand, but is it something like this you want:


	try(destroyDialog ::rol_Browse_SavePathINI)catch()
	
	rollout rol_Browse_SavePathINI "Browser"
	(
		local foldersPathIni = "C:\\Temp\\FolderSettingsIni.ini" -- Change this to whatever you want the INI file to be stored.
		
		group ""
		(
			button btn_1_Open "Open File" pos: [114,16] height:18
			button btn_browse1 "Browse" pos: [190,16] width:60 height:18 tooltip:"Set Path"
			label lbl_choose "Select maps path:" pos:[8,16] width:90 height:18
			
			label label_item1 "..." pos:[8,40] width:290
		)	
		
		-- Functions
		function SelectFolder btn =
		(
			dir = getSavePath caption:"Select folder" initialDir:(getIniSetting foldersPathIni btn "folder_path")
			if dir != undefined do
			(
				setIniSetting foldersPathIni btn "folder_path" dir
			)
			
		    label_item1.text = (getIniSetting foldersPathIni "btn_browse1" "folder_path")
		)	
		
		function OPENFoldersAndFiles dir =
		(
			try (
			f = getOpenFileName caption:"Open File..." \
			filename:(dir + "\\") \
			types:"Max(*.max)|*.max|All|*.*|"
			
			files = getFiles f
			for f in files do (loadMAXFile f)
			) catch()
			
			(
				messagebox "Please select File"
			)
		)
		
		-- Button Pressed Stuff
		on btn_browse1 pressed do
		(
			SelectFolder "btn_browse1" 
		) 
		
		on btn_1_Open pressed do
		(
			OPENFoldersAndFiles ((getIniSetting foldersPathIni "btn_browse1" "folder_path"))
		)
		
		on rol_Browse_SavePathINI open do
		(
			label_item1.text = (getIniSetting foldersPathIni "btn_browse1" "folder_path")
		)
		
		
	)
    
   
createDialog rol_Browse_SavePathINI width:260 height:70

by the way

dallchris · 2013-12-20

hey raymond by the way .. nice homepage :)