save Names to Maxfile - help please

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2011   #1
save Names to Maxfile - help please

I want to be able to run this script and it populate the drop down list with the Job Names , if they already exists in the maxfile. And if not then it will create the parameters to make it possible to save them in the file when a new one is created.
I've had some directional help pointed out by Anubis over on Script Spot but I have been unsuccessful in developing what I was hoping to achieve so far.
Below are two sets of code. The first one contains the UI that I have built for the creating of names and whatnot. Below that is the direction pointed out by other users to save those names with the maxfile. What is needed now is to combine the two and get something that works. I hope this all makes sense and that someone can help out.
Thanks
John


try(destroyDialog rlTestStore)catch()
rollout rlTestStore "Store with Maxfile"
(
	local lstNamesArr = #()
 
	fn fnUpdateNames =
	(
		rlTestStore.dlJobNames.items =  lstNamesArr
	)
 
	button btnAddName "Add Name"width:124 height:18 pos:[10,6]
	dropdownlist dlJobNames items:#() pos:[10,28]
 
	on btnAddName pressed do
	(
		try(destroyDialog rlNewName)catch()
		rollout rlNewName "New Name"
		(
			edittext etNewName "New Name: "
			
			on etNewName entered txt do
			(
				appendifUnique lstNamesArr txt
				fnUpdateNames()
				try(destroyDialog rlNewName)catch()
			)
		)
		createDialog rlNewName
	)
)
createDialog rlTestStore 150 54



 
CA = attributes Names
(
	parameters main
	(
		theNames type:#stringTab tabSizeVariable:true
	)
)
 
--// variant #1 > add to rootNode
custAttributes.add rootNode CA
custAttributes.add rootscene CA
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 07 July 2011   #2
may i show how i would do this task:

try(destroydialog str_list) catch()
rollout str_list "Names" width:200
(
	local data_ch = 1967
	local jobs = #()
	
	dotNetControl ui_list "ComboBox" width:191 height:22 pos:[4,4] 
	
	on ui_list KeyUp s e do 
	( 
		case e.keyCode of
		(
			(e.keyCode.Enter): if finditem jobs s.text == 0 do 
				(
					append jobs s.text
					ui_list.items.add s.text
				)
		)
	)

	on str_list close do
	(
		setappdata rootnode data_ch (with printallelements on jobs as string)
	)
	on str_list open do
	(
		jobs = try (execute (getappdata rootnode data_ch)) catch(#())
		if not iskindof jobs Array do jobs = #()  
		ui_list.items.addrange jobs
	)
)
createdialog str_list 


the thing #1 is to use most appropriate ui control. i'm using .net ComboBox
the thing #2:
i don't like to add CA to the scene root node. It works but might cause some problems.
i'm trying to use more safe way to store the data (specially if the data can be stored as string value) - AppData.
 
Old 07 July 2011   #3
denisT

That was the problem I was having when I was trying to hack together the max combo box which isn't exactly the most user friendly. I'm not to familiar with dotNet controls. I've found myself getting more and more into them considering there controls and functionality is much better. I appreciate you taking the time to put together this example script. I'll be sure to learn from it. It makes complete sense on what way your doing it.
I didn't want to use the CA either because it just seems like a hackish way of doing things but sometimes those ways work best.

In this case i think what you've written here will work great.
Thanks again denisT

John
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 07 July 2011   #4
property

Is there a way to have it add the name to the array after hitting enter on the keyboard?

on ui_list entered txt do
(
append in unique
)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com

Last edited by JokerMartini : 07 July 2011 at 07:40 PM.
 
Old 07 July 2011   #5
Originally Posted by JokerMartini: Is there a way to have it add the name to the array after hitting enter on the keyboard?

on ui_list entered txt do
(
append in unique
)


if we talking about dotnetcontrol ComboBox the control doesn't have Entered event. In my sample i use KeyUp event where check if the Enter key was pressed.
 
Old 07 July 2011   #6
Alright

That works. I ended up getting it to work out great.
Thanks for your help.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 07 July 2011   #7
What problems have you had with scene Defs Denis?
__________________
Paul Neale
http://paulneale.com
 
Old 07 July 2011   #8
Originally Posted by PEN: What problems have you had with scene Defs Denis?

it was a bug i max (hopefully it's fixed in 2012)... when you merge or xref object or xref scene the system replace all current global CAs with merged one. so it's posible to replace most recent with its old version.
if i have CA added to rootnode, and the logic of the attribute designed for current scene, the xrefed scene might change the logic a bit, and it might crash the system.
what happens... you xref some scene into the current. fine... you don't see a catch in it. you save the file...
but there is a big chance to never open it again. and it's very hard to fine the problem.
usually this happens if new definition of CA and the old one have different param blocks.
does it make sense?
 
Old 07 July 2011   #9
Is this on the scene root node only or also if you create a custom trackview node.
I'm in the process of storing much data under a new trackviewnode, lets call it the NMTrix node.


newTrackViewNode "NMTrix"


Under this node I will store all our pipeline data, so now I'm working on a layer manager, which serializes all (most) layer properties in a string, so I can have multiple layer setups stored. This is stored in a CA with a stringTab param. Will I be in trouble when merging or Xreffing. I though this is safe as I see more tools do store to a custom trackviewnode, like SME for example, and I think RPM does it too.

Thanks,
-Johan
__________________
Online: LinkedIn
 
Old 07 July 2011   #10
the problem with replacing of CA after merge/xref occurs for any type of CA for any max version before 2012 (+ sp)
fatal crash was happened for me when i applied CA to rootnode or material. XrefMaterial system has a problem similar to rootnode. i didn't know about Global Tracks. it might be OK.
 
Old 07 July 2011   #11
Having two of them?

I'm having an issue when trying to store two variables on the rootnode? Why is that?
Here is my code.


try(destroyDialog ::rlNewJobName)catch()
rollout rlNewJobName "New Job Name"
(
	local data_ch = 2000
	local data_jL = 2001
	local jobNames = #()
	local jobLocation = ""
	
	edittext etNewJobName "New:" fieldwidth:150 top:true pos:[10,10]
	listbox lbJobNames "" items:#() width:179 height:6 pos:[10,34]
	edittext etLocation "Location: " fieldwidth:128 top:true pos:[10,120]
	
	on etNewJobName entered txt do --//Job Names
	(
		appendIfUnique jobNames txt
		lbJobNames.items = jobNames
		etNewJobName.text = ""
	)
	
	on etLocation entered txt do --//Save Location
	(
		etLocation.text = jobLocation = txt
	)
	
	on lbJobNames doubleClicked itm do 
	(
		temp = lbJobNames.items 
		deleteItem temp itm
		lbJobNames.items = temp 
	)
	
	on rlNewJobName close do
	(
		setappdata rootnode data_ch (with printallelements on jobNames as string)
		setappdata rootnode data_jL (jobLocation as string)
	)
	
	on rlNewJobName open do
	(
		jobNames = try (execute (getappdata rootnode data_ch)) catch(#()) 
		jobLocation = 	try (execute (getappdata rootnode data_jL)) catch("") 
		etLocation.text = jobLocation as string
		lbJobNames.items = 	jobNames
		print jobNames
	)
)
createDialog rlNewJobName 200 160
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 07 July 2011   #12
Originally Posted by JokerMartini: I'm having an issue when trying to store two variables on the rootnode? Why is that?
Here is my code.


 ...
 		jobLocation =  try (execute (getappdata rootnode data_jL)) catch("") 
 ...
 

you don't need to execute string from channel data_jL. it's already string... it should by something:

local path = getappdata rootnode data_jL
if path == undefined or not doesfileexist path do path = ""
 
Old 07 July 2011   #13
undefined.....

It is always showing up undefined.....?


try(destroyDialog ::rlNewJobName)catch()
rollout rlNewJobName "New Job Name"
(
	local data_ch = 2000
	local data_jL = 2001
	local jobNames = #()
	local jobLocation = ""
	
	edittext etNewJobName "New:" fieldwidth:150 top:true pos:[10,10]
	listbox lbJobNames "" items:#() width:179 height:6 pos:[10,34]
	edittext etLocation "Location: " fieldwidth:128 top:true pos:[10,120]
	
	on etNewJobName entered txt do --//Job Names
	(
		appendIfUnique jobNames txt
		lbJobNames.items = jobNames
		etNewJobName.text = ""
	)
	
	on etLocation entered txt do --//Save Location
	(
		etLocation.text = jobLocation = txt
	)
	
	on lbJobNames doubleClicked itm do 
	(
		temp = lbJobNames.items 
		deleteItem temp itm
		lbJobNames.items = temp 
	)
	
	on rlNewJobName close do
	(
		setappdata rootnode data_ch (with printallelements on jobNames as string)
		setappdata rootnode data_jL (jobLocation as string)
	)
	
	on rlNewJobName open do
	(
		jobNames = try (execute (getappdata rootnode data_ch)) catch(#())
			
		local path = getappdata rootnode data_jL	
		if path == undefined or not doesfileexist path do path = ""
			
		etLocation.text = jobLocation as string
		lbJobNames.items = 	jobNames
	)
)
createDialog rlNewJobName 200 160
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 07 July 2011   #14
Originally Posted by JokerMartini:

  ...
  		jobLocation = getappdata rootnode data_jL	
  		if jobLocation == undefined or not doesfileexist jobLocation do jobLocation = ""
 ...
  createDialog rlNewJobName 200 160
  


you didn't set jobLocation variable.
 
Old 07 July 2011   #15
Nice

You know what,
I was just randomly typing text in to test it out not realizing there was a test for doesFileExist.


Thanks denisT for the help once again!
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:46 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.