[Query] Vraylight to Spline Rectangle ... Will I be able ?


#1

Spline Rectangle ->>> Vraylight…


#2

easy, just get the position of the vray light and the dimension properties, then create a new rectangle shape with those dimensions.


#3

Select your Vray Light plane.

Rectangle length:($.size1 * 2) width:($.size0 * 2) cornerRadius:0 transform:$.transform

#4

Multi Select your Spline VrayLight

VrayLight to Edittable Spline


#5

hehe…let’s see if I say right:

for i in selection where (classOf i==VRayLight) do if i.type==0 do rectangle length:(i.size1 * 2) width:(i.size0 * 2) cornerRadius:0 transform:i.transform

#6

Spline => VRayLight


#7

try this…

(
	newselection = #()
	for i in selection do
	(
		if classof i == rectangle do
		(
			light = vraylight()
			light.size0 = i.width/2
			light.size1 = i.length/2
			light.transform = i.transform
			append newselection light
		)
	)
	deselect $*
	select newselection
)

#8

< x > Multi Select Rectangle -> VRayLight
< o > Multi Select Editable Spline -> VRayLight


#9

here’s a quick way of doing it…


(
	try (delete $vraylightfromsplineshape*) catch()
	newselection = #()
	for i in selection do 
	(
		if (classof i) == splineshape do
		(
			extrudeMod = extrude amount:0
			addmodifier i extrudeMod
			light = vraylight()
			light.type = 3			
			light.mesh_source = i
			light.transform = i.transform
			light.multiplier = 2		
			--light.mesh_flip = false
			--light.mesh_flip = true
			light.doubleSided = true
			light.name = uniquename "VrayLightFromSplineShape"
			deletemodifier i extrudeMod
			append newselection light
		)
	)
	deselect $*
	select newselection
)


#10

ERROR…


#11

works fine for me… hmm maybe its because of version difference (select a vray light and type

show $

in the listener and paste the result here)


#12

Version is used…
3dsmax 8.0 & Vray RC3


#13

i think rc3 didn’t have mesh support for vray lights… anyways try this… maybe it will work…

(
	newselection = #()
	try (delete $vraylightfromsplineshape*) catch()
	for j in selection do
	(
		if classof j == splineshape do 
		(
			xArr = #()
			yArr = #()
			zArr = #()
			for k = 1 to (numsplines j) do
			(
				for i = 1 to (numknots j k) do 
				(
					xArr[i] = (getknotpoint j k i).x
					yArr[i] = (getknotpoint j k i).y
					zArr[i] = (getknotpoint j 1 i).z
				)
				shapeWidth = (amax xArr) - (amin xArr)
				shapeLength = (amax yArr) - (amin yArr)
				vlight = vraylight()
				vlight.size0 = shapeWidth /2 
				vlight.size1 = shapeLength/2
				vlight.transform = j.transform
				vlight.pos = [(((amax xArr) + (amin xArr))/2),(((amax yArr) + (amin yArr))/2),(((amax zArr) + (amin zArr))/2)]
				vlight.name = uniquename "VraylightFromSplineShape"
				append newselection vlight
			)
		)
	)
	deselect $*
	select newselection
)
 


#14

here’s a more sophisticated approach (the advantage of this script is it calculates the correct transformation matrix irrespective of the transformations applied to the pivot or the spline sub-object of the Spline shape) the script assumes that all the spline shapes are “rectangular” i.e adjacent sides are perpendicular and the shape has 4 knot points :

(
	global o,a,b,c
	try (delete $vrayLightFromSplineShape*) catch()
	newSelection = #()
	fn computeTm v1 v2 ss = 
	(
		n = normalize (cross (normalize v1) (normalize v2))
		maxX = amax o.x a.x b.x c.x
		minX = amin o.x a.x b.x c.x
		maxY = amax o.y a.y b.y c.y
		minY = amin o.y a.y b.y c.y
		maxZ = amax o.z a.z b.z c.z
		minZ = amin o.z a.z b.z c.z
		center = [(maxX + minX)/2 , (maxY + minY)/2, (maxZ + minZ)/2]
		tm = matrix3 (normalize v1) (normalize v2) n center
		shapewidth = length v1
		shapelength = length v2	
		Vlight = vraylight size0:(shapewidth/2) size1:(shapelength/2) transform:tm name:(uniqueName "vrayLightFromSplineShape")
		append newselection Vlight
	)

	for i in selection do
	(
		if ((classOf i) == SplineShape) do 
		(
			for j = 1 to numsplines i do
			(
				o = getknotpoint i j 1
				a = getknotpoint i j 2
				b = getknotpoint i j 3
				c = getknotpoint i j 4
				v1 = (a - o)
				v2 = (b - o)
				v3 = (c - o)
				angle1 = acos (dot (normalize v1) (normalize v2))
				angle2 = acos (dot (normalize v1) (normalize v3)) 
				angle3 = acos (dot (normalize v2) (normalize v3)) 	
				if ((angle1 as string) == "90.0") do (computeTM v1 v2 i)
				if ((angle2 as string) == "90.0") do (computeTM v1 v3 i) 
				if ((angle3 as string) == "90.0") do (computeTM v2 v3 i) 
			)
			
		)
		
	)
	deselect $*
	select newselection
	"OK"
)

note: for some reason angle1 == 90.0 always yields false even when angle is 90.0 :S so i had to convert it to string to make the comparison :S

here’s a snap :


#15

Thank you very much for your help

plastic ^^
DaveWortley ^^
HornBerger ^^

해결되었습니다…
HornBerger님 앞으로 잘 부탁드리겠습니다. 감사합니다.


#16

glad it worked!

해결되었습니다…
HornBerger님 앞으로 잘 부탁드리겠습니다. 감사합니다.

lol me and my browser (safari) both don’t understand korean :wink:


#17

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.