Notifications
Clear all

[Closed] Creating Directory

I figured out the solution to Creating a Directory!
makeDir (txtPath.text + “\” + cameraName)

I meant for this to post in the MAX SCRIPT SECTION – Mods if you can move this for me, please do!

I’ve researched but I can not find a way to have max create a new directory by using a script. I’ve only found how to create custom files like .txt files, but nothing about directories. Can anyone point me in the right direction? Here is what Im trying to achieve:

  I have a custom script that will automaticly setup a Irradience Map for V-Ray.  Everything works including creating the .vrmap file that V-Ray uses for irradience maps.  The only problem is, the directory must already exist for the map to create properly.  
  
  Is there an easy fix for the directory to automaticly create?  OR -  Is it possible to create a dialog box that will easily allow the user to manually create the directory without the user having to open Windows Explorer?   Here is the script I have for the Irradience map to work:
-- This is the textbox that the user manually types the location of the Irradience Directory.
      edittext txtPath  FieldWidth:360
      
      -- variable that constructs the naming of the VRay Irradiene Map.
     -- IRStart and IREnd grabs the frame start and end numbers.
    -- CameraName simply grabs the camera name but the directory must exist.
     -- Anyway for the directory to automaticly create?
      IRName = txtPath.text + cameraName + "\\" +IRStart + "-" + IREnd +".vrmap"
      
      -- Location for the VRay Irradience Map to create.
      vr.adv_irradmap_autoSaveFileName = IRName
3 Replies
 PEN

I’m guessing you answered your own question?

makeDir <directory_path_string>

edit – ah sorry missed the top of your post!

i wrote a small camera rollout a while back – it saves has a few controls including saving out the active camera to the current max directory. You may be able to grab something from there of use. please bear in mind its not named or formatted properly and much of it i would streamline these days – I hadnt meant for anyone to see it!


  
  try(destroydialog camcontrol)catch()
  
  global currentcam
  global camdiagpos 
  global camsaver
  global finalpath
  global theMaxFilePath 
  global theMaxFilePathplus
  global cwidth = 170
  global cheight = 740
  
  	global registerCAMCallback
  
  	fn registerCAMCallback =
  	(
  		try
  		(
  			filein (getdir #scripts +"\\CamClippingAssist.ms")
  		)catch()
  	)
  
  
  	rollout camcontrol "Camera Control" width:172 height:740
  	(
  		spinner spn1 "" pos:[39,149] width:117 height:16 range:[0,3000,0]
  		spinner spn2 "" pos:[42,244] width:117 height:16 range:[0,3000,0]
  		checkbutton ckb1 "Clip on/off" pos:[6,48] width:75 height:43 highlightColor:(color 123 143 123)
  		label lbl1 "" pos:[11,19] width:104 height:17
  		button btn1 "125" pos:[30,265] width:20 height:20
  		GroupBox grp1 "Current Camera" pos:[6,2] width:155 height:41
  		button btn3 "500" pos:[140,265] width:20 height:20
  		button btn4 "400" pos:[118,265] width:20 height:20
  		button btn5 "100" pos:[8,265] width:20 height:20
  		button btn6 "150" pos:[52,265] width:20 height:20
  		button btn7 "200" pos:[74,265] width:20 height:20
  		button btn8 "300" pos:[96,265] width:20 height:20
  		button btn9 "10" pos:[72,169] width:20 height:20
  		button btn10 "0.1" pos:[8,169] width:20 height:20
  		button btn11 "1" pos:[29,169] width:20 height:20
  		button btn12 "5" pos:[50,169] width:20 height:20
  		button btn13 "15" pos:[94,169] width:20 height:20
  		button btn14 "20" pos:[116,169] width:20 height:20
  		button btn15 "25" pos:[138,169] width:20 height:20
  		button btn44 "Refresh" pos:[116,14] width:41 height:24
  		GroupBox grp3 "Select" pos:[2,330] width:162 height:85
  		button btn16 "Camera" pos:[6,348] width:51 height:62
  		button btn17 "Both" pos:[108,348] width:51 height:62
  		GroupBox grp4 "Add TCB" pos:[3,418] width:159 height:37
  		button btn18 "Camera" pos:[12,434] width:67 height:16
  		button btn19 "Target" pos:[88,434] width:67 height:16
  		slider sld1 "" pos:[13,194] width:150 height:25 enabled:true range:[0,400,0] ticks:0
  		slider sld2 "" pos:[13,291] width:150 height:25 range:[0,3000,0] ticks:0
  		GroupBox grp33 "Near Clipping Distance" pos:[5,134] width:159 height:86
  		
  		GroupBox grp34 "Far Clipping Distance" pos:[5,225] width:159 height:96
  		button btn24 "Save to file" pos:[84,48] width:79 height:43
  		GroupBox grp6 "Ease From" pos:[5,587] width:76 height:109
  		GroupBox grp7 "Ease To" pos:[88,587] width:75 height:109
  		button btn21 "0" pos:[13,605] width:62 height:13		
  		button btn66 "5" pos:[14,620] width:17 height:17
  		button btn67 "10" pos:[36,620] width:17 height:17
  		button btn68 "15" pos:[57,620] width:17 height:17
  		button btn69 "20" pos:[14,639] width:17 height:17
  		button btn70 "25" pos:[36,638] width:17 height:17
  		button btn71 "30" pos:[57,637] width:17 height:17
  		button btn72 "35" pos:[14,656] width:17 height:17
  		button btn73 "40" pos:[36,656] width:17 height:17
  		button btn74 "45" pos:[57,655] width:17 height:17
  		button btn75 "50" pos:[14,674] width:59 height:14
  		button btn77 "0" pos:[95,606] width:62 height:13
  		button btn78 "5" pos:[96,621] width:17 height:17
  		button btn79 "10" pos:[118,621] width:17 height:17
  		button btn80 "15" pos:[139,621] width:17 height:17
  		button btn81 "20" pos:[96,640] width:17 height:17
  		button btn82 "25" pos:[118,639] width:17 height:17
  		button btn83 "30" pos:[139,638] width:17 height:17
  		button btn84 "35" pos:[96,657] width:17 height:17
  		button btn85 "40" pos:[118,657] width:17 height:17
  		button btn86 "45" pos:[139,656] width:17 height:17
  		button btn87 "50" pos:[96,675] width:59 height:14
  		button btn43 "Rename to Scene Name" pos:[6,102] width:156 height:22		
  		
  		
  		button camkeyinfo "Key Info Cam" pos:[6,701] width:78 height:20
  			
  		button btn45 "Key Info Target" pos:[87,701] width:77 height:20
  		button btn46 "Key Cam" pos:[5,478] width:162 height:27
  		button btn47 "Key Target" pos:[5,506] width:162 height:27
  		button btn48 "Key Both" pos:[5,534] width:162 height:27
  		
  		
  		
  		GroupBox grp29 "TCB Utilities" pos:[2,570] width:164 height:157
  			
  		GroupBox grp30 "TCB Utilities" pos:[3,460] width:164 height:108
  		button btn49 "Target" pos:[57,348] width:51 height:62
  		on camcontrol open do
  		(			
  		try (currentcam = getActiveCamera())catch(lbl1.text = "Select a camera view")		
  		if currentcam == undefined then () else(		
  		theMaxFilePath = maxFilePath	
  		pth = "wip/"	
  		theMaxFilePathplus= maxFilePath + pth		
  		finalpath = theMaxFilePathplus + currentcam.name + " Camera"	
  		)
  									
  		try
  		(			
  		ckb1.enabled = true
  		currentcam.nearclip.controller = bezier_float ()
  		currentcam.farclip.controller = bezier_float ()		
  		lbl1.text = currentcam.name
  		ckb1.state = currentcam.clipManually
  		spn1.controller = currentcam.nearclip.controller
  		spn2.controller = currentcam.farclip.controller
  		sld1.controller = currentcam.nearclip.controller
  		sld2.controller = currentcam.farclip.controller
  		)
  		catch (	lbl1.text = "Select a camera view"
  		ckb1.enabled = false)
  		)
  		on camcontrol close do
  		(	
  		callbacks.removeScripts id:#CAMAssist
  		camdialogpos = getdialogpos camcontrol		
  		SetIniSetting "$scripts\\GlobalScriptSettings.ini" "CamControlSettings" "DialogPosition" ((getDialogPos camcontrol) as string)
  
  		
  		)
  		on ckb1 changed state do
  		(
  			if state == false
  			then 
  			(
  			try(currentcam.clipManually = false)catch()
  			)
  			else 
  			(
  			try(currentcam.clipManually = true)catch()
  			)
  		)
  		on btn1 pressed do
  			spn2.value = 125
  		on btn3 pressed do
  			spn2.value = 500
  		on btn4 pressed do
  			spn2.value = 400
  		on btn5 pressed do
  			spn2.value = 100
  		on btn6 pressed do
  			spn2.value = 150
  		on btn7 pressed do
  			spn2.value = 200
  		on btn8 pressed do
  			spn2.value = 300
  		on btn9 pressed do
  			spn1.value = 10
  		on btn10 pressed do
  			spn1.value = 0.1
  		on btn11 pressed do
  			spn1.value = 1
  		on btn12 pressed do
  			spn1.value = 5
  		on btn13 pressed do
  			spn1.value = 15
  		on btn14 pressed do
  			spn1.value = 20
  		on btn15 pressed do
  			spn1.value = 25
  		on btn44 pressed do
  		(
  		camdialogpos = getdialogpos camcontrol
  		destroydialog camcontrol
  		createdialog camcontrol cwidth cheight style:#(#style_toolwindow, #style_sysmenu) pos:(if camdialogpos == undefined then [0,0] else camdialogpos)
  		)
  		on btn16 pressed do
  			try(select currentcam)catch()
  		on btn17 pressed do
  		(
  				try(
  				select currentcam.target
  				selectmore currentcam
  				)catch()
  			)
  		on btn18 pressed do
  		(
  		try
  		(
  		select currentcam
  		$.pos.controller = tcb_position ()
  		)
  		catch()
  		)
  		on btn19 pressed do
  		(
  		try
  		(
  		select currentcam.target
  		$.pos.controller = tcb_position ()
  		)
  		catch()
  		)
  		on btn24 pressed do
  		if currentcam == undefined then
  			(
  			lbl1.text = "Must be a camera!"			
  			)
  			else
  			(
  			createdialog camsaver style:#(#style_toolwindow, #style_sysmenu)
  			)
  		on btn21 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 0
  			)
  			catch()	
  		)
  		on btn66 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 5
  			)
  			catch()	
  		)
  		on btn67 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 10
  			)
  			catch()	
  			
  		)
  		on btn68 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 15
  			)
  			catch()	
  		)
  		on btn69 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 20
  			)
  			catch()	
  		)
  		on btn70 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 25
  			)
  			catch()	
  		)
  		on btn71 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 30
  			)
  			catch()	
  		)
  		on btn72 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 35
  			)
  			catch()	
  		)
  		on btn73 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 40
  			)
  			catch()	
  		)
  		on btn74 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 45
  			)
  			catch()	
  		)
  		on btn75 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easefrom = 50
  			)
  			catch()	
  		)
  		on btn77 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 0
  			)
  			catch()	
  		)
  		on btn78 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 5
  			)
  			catch()	
  		)
  		on btn79 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 10
  			)
  			catch()	
  		)
  		on btn80 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 15
  			)
  			catch()	
  		)
  		on btn81 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 20
  			)
  			catch()	
  		)
  		on btn82 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 25
  			)
  			catch()	
  		)
  		on btn83 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 30
  			)
  			catch()	
  		)
  		on btn84 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 35
  			)
  			catch()	
  		)
  		on btn85 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 40
  			)
  			catch()	
  		)
  		on btn86 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 45
  			)
  			catch()	
  		)
  		on btn87 pressed do
  		(
  			try
  			(
  				local tvis = $.position.controller
  				addnewkey tvis currenttime
  				keyind = getKeyIndex tvis currenttime
  				tvis.keys[keyind].easeto = 50
  			)
  			catch()	
  		)
  		
  		
  		
  		on btn43 pressed do
  		(
  				try
  				(
  				
  				tempname = maxfilename
  				filetypestrip = filterstring tempname "."				
  				currentcam.name = filetypestrip[1]
  				currentcam.target.name = filetypestrip[1]+" (Target)"
  				
  		camdialogpos = getdialogpos camcontrol
  		destroydialog camcontrol
  		createdialog camcontrol cwidth cheight style:#(#style_toolwindow, #style_sysmenu) pos:(if camdialogpos == undefined then [0,0] else camdialogpos)
  
  				
  				
  				)
  				catch()
  			)
  		on camkeyinfo pressed do
  		(
  				select currentcam
  				tvis = $.position.controller
  				selectkeys tvis currenttime
  				displayControlDialog tvis "Camera key properties"
  			)
  		on btn45 pressed do
  		(
  				select currentcam.target
  				tvis = $.position.controller
  				selectkeys tvis currenttime
  				displayControlDialog tvis "Camera Target Key properties"
  			)
  		on btn46 pressed do
  		(
  			try
  			(
  				select currentcam
  		local tvis = $.position.controller
  				addnewkey tvis currenttime
  			)
  			catch()	
  		)
  		on btn47 pressed do
  		(
  			try
  			(
  			select currentcam.target
  		local tvis = $.position.controller
  				addnewkey tvis currenttime
  			)
  			catch()	
  		)
  		on btn48 pressed do
  		(
  			try
  			(
  			select currentcam	
  		local tvis = $.position.controller
  				addnewkey tvis currenttime
  			select currentcam.target
  		local tvis = $.position.controller
  				addnewkey tvis currenttime
  			)
  			catch()	
  		)
  		on btn49 pressed do
  			try(select currentcam.target)catch()
  	)	
  	
  	rollout camsaver "Save current camera to max file" width:263 height:56
  (
  	button btnsave "Save" pos:[118,27] width:79 height:23
  	button btncncl "Cancel" pos:[199,27] width:58 height:23
  	edittext edt1 "Camera Name" pos:[8,3] width:249 height:20 bold:true
  	checkbox chkwip "Save to wip folder" pos:[7,28] width:109 height:19 checked:true
  	
  	
  	on camsaver open do
  	(
  	edt1.text = currentcam.name 
  	)
  	on btnsave pressed do
  	(	
  	currentcam.name = edt1.text
  	
  		if chkwip.checked == true then 
  		(
  		makeDir theMaxFilePathplus	
  		savenodes currentcam finalpath
  		destroydialog camsaver				
  		)		
  		else
  		(	
  		local rootpath = theMaxFilePath + (currentcam.name 	+ " Camera")
  		savenodes currentcam rootpath
  		destroydialog camsaver	
  		)
  	)
  	
  	on btncncl pressed do (destroydialog camsaver)
  	
  )
  try(callbacks.removeScripts id:#CAMAssist)catch()
  callbacks.addScript #filePostOpen "registerCAMCallback()" id:#CAMAssist
  
  createdialog camcontrol cwidth cheight style:#(#style_toolwindow, #style_sysmenu) 

PEN,

Yes I did :). I left the post information up for people to review if they wanted to see what was wrong.

LongRobot,

Thanks for your code! It looks pretty intense, Im going to check it out today. Thanks again