ScriptSpot

Forum topic · General Scripting

Refresh object parameter (more info...)

By Michele71 · 2015-03-05

Description

hi all man and thanks for and thanks for the visit :)

I have completed another script and I'm completing the final steps (debug and more options). Now it is a problem. The script provides for the creation of a obj plane "general" called mr_plane and a map environmet. With its creation of plane (and map env), I active every spinner etc .. because I want it to be created first. Now If I close the rollot and re-open it, the spinner ecc are desabled. I know many ways to refresh parameters ecc, but are now bogged down..

My question is:

How to recognize the presence of the plane (and evironment) and activate all parameters? The problem is if the plane is renamed AFTER its creation and if there exists a map environment different or equal...

Any suggestion is welcome! Thanks!!

P.S: I attach the script to be consulted :)

Attachments
Comments (20)

Michele71 · 2015-03-13

Ok, continue to update the discussion :) I found a way around the problem with the material editor:


for o = 1 to 24 do
(
if superclassof meditmaterials[o] == texturemap and classof Environment_Probe_Chrome_Ball__mi == texturemap do 
(
meditmaterials[o] =standardmaterial()
)
)

Now all work well and the script is almost finished, but...

When I close the rollout or reopen, the preview image appear even if I removed the CA and textureMap in the environmet. If I evalute this string:


envArr = for m in sceneMaterials where isProperty m #epcb_ca collect m

I have as a result:


#(Environment_Probe_Chrome_Ball__mi:Environment Probe/Chrome Ball (mi))

but I delete all!!

However, the strange thing is that if I wait a few minutes with the rollout closed,the described situation disappears !! All work well...

Why the textureMap remains in memory for a long time even if canceled?

Attach the script if you want to consult :D

Attachments

Michele71 · 2015-03-14

Well, I resolve the problem :) The variable epcb dont work during the delete of CA for the envirinment map; the material is delete but CA link to material no.. Now all work well (least I hope!!)

Michele71 · 2015-03-14

Thanks barygazi for reply. Yea, I suppose that have need of refresh something... Strange that cancel the CA for env map and mat in slot editor the problem disappear. However, I put the your fn in the script!!!

Thanks again for adviser!!!

barigazy · 2015-03-14

I you want to delete CA from any node (object, material, map etc.) try this fn


fn delCA node = if (caDefs = custAttributes.getDefs node) != null do
(
	if caDefs.count > 0 do (for i = 1 to caDefs.count do custAttributes.delete node caDefs[i])
)

This fn will delete all CA. But if you want to delete specific CA lets say by given name then it is a different story :). You can find by youreslf how to do that

Michele71 · 2015-03-14

ok thanks again barigazy!! I have used two form for delete CA ( material plane and environment map) but this fn appear to be more fast and symple!!

Thanks again!!!

Michele71 · 2015-03-12

Ok, I continued the script and I arrived in good punt :) Now I just can not figure out how to remove a material from Material Editor know the name or CA !! Too much information to script these days and I am exhausted :D

The problem is that the material associated to environment remain in memory, or if I copy or instance it in the material editor, the rollout update Always the info. i have create a button for clear this data, but dont even clean up the map in ME...

Any suggestions?

In practice: how I delete a material/map n Material Editor knowing only his name or state?

Attachments

Michele71 · 2015-03-10

Bah... the same function for material dont work... I've create (based on function for mrplane) a fn for probe ball material but without success. The same parameters put in "open do" work well.

In short, the access in texture_shader map dont work.... I to go on my study...

Michele71 · 2015-03-07

Thanks barigazy :) I study your solution for CA!!

I'm off to work two days but I bring the script as a book to read and study !!
Thanks again for your valuable support and help ;)

barigazy · 2015-03-07

I corrected some of your code and added some comments (--***) and function for mr_plane CA. Try this:
Open your script, create plane and change some plane and material properties.
Then close and reopen script. Voila! For EnvMap you need to write code by yourself

You need to do the same thing for enironment map. Create CA and add inside functions for creation of preview map for rollout UI.

Attachments

Michele71 · 2015-03-08

Hi Branko :)

Bad news, the your script (thanks again :)) dont work!! The parameters dont refresh... I try the function "defPlaneCA node" on new script very simple:


try (destroydialog :: tes) catch()

rollout tes "Test"
(
	Global Cubo 
	
	button pl  "Button"
	spinner sp1 "Sp1" range: [0,200,10]
	spinner sp2 "Sp2" range: [0,200,10]
	
					fn defCuboCA node =
	(
		local mrpCA = attributes cubo_piano
		(
			fn getMRPlaneData =
			(
				local mrp = (refs.dependentNodes ((refs.dependents this)[1]))[1]
				if isValidNode mrp and iskindOf tes RolloutClass and tes.open do
				(
					tes.sp1.value = Cubo.length; tes.sp2.value = Cubo.width

				)
			)
		)
		custAttributes.add node mrpCA
	)
	
	
	on pl pressed do
	(
		Cubo = box length:10 width:10
		Cubo.material = Arch___Design__mi ()
		defCuboCA Cubo
	)
	
	on sp1 changed val do if isValidNode Cubo do Cubo.length = sp1.value
		on sp2 changed val do if isValidNode Cubo do Cubo.width = sp2.value
	
		
		on tes open do
	(
		local mrpArr = for o in geometry where isProperty o #cubo_piano collect o
		if mrpArr.count > 0 do
		(
			Cubo = mrpArr[1]
			Cubo.cubo_piano.getMRPlaneData()
		)
	)
)
createdialog tes

The function here work well, but in your example, no.

I noticed that at the function (the first time in new script) gave me error "IsKindOf" where he found three but was looking for two!! Very strange because value is tes and class rolloutclass then right. I do not think that is the position of the function in the script is wrong... In your opinion, where is the error?

barigazy · 2015-03-08

Which parameters not refresh?
I did'nt make the code where you can change material properties in material editor and refresh parameters in rollout. Same things for plane render scale in command panel not refresh same spiner value in your rollout.
For that you can use Timer control bat this is another story.
Your example works because U declared your "Cubo" as global var. Your method not work if you save scene and close/open max and load the same scene and then run script again.
I "getMRPlaneData" function variable "mrp" represents your cube object which holds CA. So u can use


if isValidNode mrp and iskindOf tes RolloutClass and tes.open do
(
    tes.sp1.value = mrp.length; tes.sp2.value = mrp.width
)

One more thing. You use max2010. This version probably not supports many things which are available in max2014, related to mxs

Michele71 · 2015-03-08

Heheheeh the spinner, checkboxes ecc are disabled (as in the original) whe re-open the script. As you suggested, I opened the script, created the plane and changed some values in rollout. Closed and reopen the script. The rollout is "closed".

That's why I created a new script, to try to see if the fn that you wrote worked (I have not create any change in Material Editor etc.)
In my work, I have had a chance to test your test script in max2015 64bit, and does not work. Reading in the help, there are differences with the 2010 version (at least not dictated from Autodesk) about CA, but this can not be safely...

Honestly, this opportunity to refresh with CA fascinates me a lot, since it can be convenient in many cases. I discovered something new very useful.

Thanks for the suggestion referred to the "Cubo", I have not thought that if I save scene and close/open max and load the same scene its dont work.

Thanks again Branko and sorry for the trouble :(

P.S: your script for the grid, the first time I installed it worked very well!!!

Attachments

barigazy · 2015-03-08

You are right. It's very wierd. Function inside CA is ok but not works. I don't know why.
Anyway...I manage this to works. I left CA only for mr_plane recognition and for label :)

Attachments

Michele71 · 2015-03-09

Hahahah the function does not work in CA is really strange!!!

Thanks Branko, now work well :)Parameters and rollout refresh and and I'm happy!!!

Now try with the environment map, and I try to implement your recommendations and suggestions. I learned a lot, thanks! I leave this thread open for future updates ;)

I'm sorry again for the inconvenience and thank you very much!

barigazy · 2015-03-06

U can use custAttribute which contains all rollout parameters of the plane and env map. When u close rollout this CA will be added on the plane.When you load the script again in the "open" event you need to add fn that will check if plane CA exists and load all parameters back

Michele71 · 2015-03-06

Hi barigazy and thanks for you reply (sorry for delay). I have not thought of this way for re-check the parameters. Now I try and see if I can use CA, otherwise I must use another method :(

Thanks for reply and support :)

Michele71 · 2015-03-06

Thanks again, I check and study your tool. I hope to get on top of the problem :-D

Michele71 · 2015-03-06

Ok, I have understand how it works CA, but but I have a question that is not answered: I can enter a CA in a Rollout without create un modifier in the object?? Yes I can but...

If I check with


custAttributes.count p baseobject:false

the object plane, CA "testBox" is known and no modifier is applied (because obviously not created)

es.


rollout prova "Test"
(
	button bb ""
	spinner sp1 "L" range:[0,100,10] enabled:false
	spinner sp2 "W" range:[0,100,10] enabled:false
	
	
	on bb pressed do
	(
		p = plane name:"test_plane" 
		p.Length =sp1.value
		p.Width = sp2.value
		sp1.enabled = true
		sp2.enabled = true

		testBoxCA = attributes testBox
(
parameters main rollout:prova
			(

			)
rollout prova "Test" 
(

)
)
custAttributes.add p testBoxCA baseobject:false 
	
)
	on sp1 changed val do p.Length =sp1.value
	on sp2 changed val do p.Width = sp2.value
		
	on prova open do
		
	(
		
	)

)
createdialog prova

but I do not understand how the main "parameters" is updated, while if I create a modifier (attribute holder) con CA there are no problems... Where I am wrong?

PS: This is the first time I use a plug-in MAXScript and I have read dozens of pages helpscript tonight... every time I create a shred of script, opens a new world !! :-D