Notifications
Clear all

[Closed] for i = geometry issue

 eek

You could do something like this (roughly):


for o in geometry do
(
value = getUserProp o "VRay_Matte_Alpha" 
t = (float(value) - -1.0)/(1.0 - -1.0)
o.wirecolor = color (255 * t) (255 * t) (255 * t)
)

I normally just set the full Vray Props.

 if ( findstring (getUserPropBuffer o ) "VRay" )== undefined do 
 (
	setUSerPropBuffer $ "VRay_MoBlur_GeomSamples = 2
	VRay_GI_Generate = True
	VRay_GI_Receive = True
	VRay_GI_Multipier = 1.000000
	VRay_GI_GenerateMultipier = 1.000000
	VRay_GI_SubdivsMultiplier = 1.000000
	VRay_Caustics_Generate = True
	VRay_Caustics_Receive = True
	VRay_Caustics_Multipier = 1.000000
	VRay_MoBlur_DefaultGeomSamples = True
	VRay_Matte_Enable = False
	VRay_Matte_Alpha = 1.000000
	VRay_Matte_Shadows = False
	VRay_Matte_ShadowAlpha = False
	VRay_Matte_ShadowColor = [0,0,0]
	VRay_Matte_ShadowBrightness = 1.000000
	VRay_Matte_ReflectionAmount = 1.000000
	VRay_Matte_RefractionAmount = 1.000000
	VRay_Matte_GIAmount = 1.000000
	VRay_Matte_GI_OtherMattes = True
	VRay_GI_SurfaceID = 0
	VRay_GI_VisibleToGI = True
	VRay_GI_VisibleToReflections = True
	VRay_GI_VisibleToRefractions = True
	VRay_Mesh_Geometry = 2
	"
)

Cheers for that one Dave, I think I will throw that on the top of my script and then I can write the rest of my buttons knowing that all my objects will definitely have a vray property assigned.

Also just checked out your maxscript tutorials, they are brilliant, cheers for sharing the knowledge

No worries, I’ll post it up tomorrow morning

the same way as any other modal dialog… by using DialogMonitorOPS. you can find many samples on this forum. for example: http://forums.cgsociety.org/showpost.php?p=7358888&postcount=12

1 Reply
(@raytracer05)
Joined: 10 months ago

Posts: 0

Thanks for your help again I think I’ve got it working now.

(
	dialogMonitorOPS.unRegisterNotification id:#closeVRayProperties

	fn closeVP =
	(
		windowHandle = dialogMonitorOPS.GetWindowHandle()
		if (UIAccessor.getWindowText windowHandle) == "VRay object properties" do
		(
			UIAccessor.closeDialog windowHandle
		)
		true
	)

	dialogMonitorOPS.registerNotification closeVP id:#closeVRayProperties
	dialogMonitorOPS.Enabled = true
	doVRayObjectProperties()
	dialogMonitorOPS.Enabled = false
	dialogMonitorOPS.unRegisterNotification id:#closeVRayProperties
)

The Vray properties dialog definitely flashes up then disappears.

Everyone feel free to rip this to bits, wasn’t really made to be shared but everyone’s welcome to use, basically will change you wirecolour in scene to show a few features we use here, vis to camera, matt object, alpha level, what’s instanced, etc.

I have it as a macro within our own scripts menu but below should run as its own script.



----   Collect original wirecolors before you start changing them   

wirecolors = (for i = geometry collect i.wirecolor) as array   ---  collect original wirecolors




							--  ON CLOSE ROLLOUT   ----

rollout closedoors "do you want to revert to original colors ?"
	
(
	button revert "YES please"
	
	on revert pressed do 
		
	(
		for i = 1 to geometry.count do geometry[i].wirecolor = wirecolors[i]
			
	)
)




									---   POLY CHECKER ROLLOUT   ------




rollout myRoll "rt_Object_Properties_Viewer_v1.0"
	



	
(
	
	
	
 --                                     -----           menu buttons        --------
	
	
	
 	
 button originalwirecolors " return original wirecolors"  -- return original wirecolors
	
 button seeinstances "show instances"  --  shows objects that are instances

 button visabletocamera "show visable to camera"  --  shows objects that are visable to camera

 button selectvisabletocamera "select visable to camera"  --  shows objects that are visable to camera

 button selectnonvisabletocamera "select non-visable to camera"  --  shows objects that are visable to camera

 button alphacontribution "alphacontribution "  --  shows objects alpha contribution

 button matteobject "show matteobjects  "  --  shows objects that are Vray matte objects

 button selectmatteobject "select matteobjects  "  --  shows objects that are Vray matte objects

 button ObjectIds "ObjectIds   "  --  shows ObjectIds 








                                                                         --  Vray ObjectIds   --

on ObjectIds pressed do
	(
		randomcolours = (for i = 1 to 100 collect (mynumber = (color (random 0 255) (random 0 255) (random 0 255))))

		for i = geometry do if i.gbufferchannel == 0 then i.wirecolor = (color 0 0 0) else i.wirecolor =  randomcolours[i.gbufferchannel]

	)






                                                                         --  Vray select matteobject  --

on selectmatteobject pressed do
	(
		select (for i = geometry where getUserProp i"VRay_Matte_Enable" == true collect i)

	)






                                                                         --  Vray show matteobject  --

on matteobject pressed do
	(
		for i = geometry do if (getUserProp i"VRay_Matte_Enable" == true) then (i.wirecolor = (color 255 0 0)) else (i.wirecolor = (color 0 0 0))

	)






                                                                        --  Vray alpha Contribution  --

on alphacontribution pressed do
	(
		for i in geometry do if (getUserProp i"VRay_Matte_Alpha") == undefined then i.wirecolor = (color 255 255 255) else i.wirecolor = (color (((getUserProp i"VRay_Matte_Alpha") + 1)*(255/2))(((getUserProp i"VRay_Matte_Alpha") + 1)*(255/2))(((getUserProp i"VRay_Matte_Alpha") + 1)*(255/2)))

	)


	





                                                                       --  select non visable to camera  --

on selectnonvisabletocamera pressed do
	(
		select (for i = geometry where i.primaryvisibility == false collect i)
	)











                                                                       --  select visable to camera  --

on selectvisabletocamera pressed do
	(
		select (for i = geometry where i.primaryvisibility == true collect i)
	)






                                                                       --  show visable to camera  --

on visabletocamera pressed do
	(
		for i = geometry do if (i.primaryvisibility == true) then (i.wirecolor = (color 255 0 0)) else (i.wirecolor = (color 0 0 0))
	)






	
	
									--  show instances  --
	
on seeinstances pressed do

	(
		
		myinstances = #()

		for i = geometry do i.wirecolor = black

		for i = geometry do
		
		(
	
			(
				
				number = instancemgr.getinstances i &instances
				
			)
	
			if number > 1 then append myinstances instances
		)

		for i = myinstances do i.wirecolor = red
		
	)
	
	
									--  return original wirecolors   --
	
	on originalwirecolors pressed do 
		
	(
		for i = 1 to geometry.count do geometry[i].wirecolor = wirecolors[i]
	)
 
	
	
	
	
	
  
  
							               --   on close  --
  
  
  
  
  on myroll close do
	  
  (
	  createdialog closedoors width:300 height:30 pos:[200,100]
	  
  )
  
  
  
  
  
  
)
createdialog myRoll width:200 height:400 pos:[200,100]

)
Page 2 / 2