Bbox Border plane and attach all mesh

Hi !
I looking for to create a little script who makes planes around my bounding box : like this picture ...

http://img15.hostingpics.net/pics/230428bboxplane.jpg

I don't need the top and bottom plane.

And I need too another script can attach all mesh together without lost Texture Information.

Someone know how I can do this?

Regards

Kasimashi

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Yep. :) I forgot it. :)

Yep. :) I forgot it. :)

barigazy's picture

...

Now you have both versions complited

fn createBoxAsCage obj = if isValidNode obj do
(
	local bb = in coordsys local nodeLocalBoundingBox obj
	local wX = abs((bb[1]-bb[2]).x) , lY = abs((bb[1]-bb[2]).y) , hZ = abs((bb[1]-bb[2]).z)
	local cage = convertToPoly (box width:wX length:lY height:hZ mapcoords:on name:"Cage" wirecolor:black)
	CenterPivot cage
	local tm = obj.transform
	tm.row4 = obj.center
	cage.transform = tm
	polyop.deleteFaces cage #{1,2}
	local mtlArr = #()
	for m = 4 to 1 by -1 do
	(
		id = (polyop.getFaceMatID cage m) - 2
		side = ("Side_"+m as string)
		polyop.setFaceMatID cage m id
		polyop.detachFaces cage #{m} delete:true asNode:true node:boxAsCage name:side
		(getnodebyname side).material = standard name:("Mtl_" + m as string) diffuse:(random black white)
		CenterPivot (getnodebyname side)
	)
	delete cage
)
-- example
delete objects
tea = Teapot pos:[20,50,30] dir:[0.616459,-0.51929,0.591875] scale:[.8,.8,.8]
createBoxAsCage tea

barigazy

Kasimashi's picture

Thanks !!!!

Thanks you miauu and barigazy but I need 4 Planes :) I don't need a box :p How can I detach face ?

Thanks again for your help !

What about "attach all mesh"?

Regards friend!

miauu's picture

Local BBox of the selected

Local BBox of the selected object or world bbox?

This is for world bbox:

(
	selObj = selection[1]
	theWidthX = abs (selObj.max.x - selObj.min.x)
	theLengthY = abs (selObj.max.y - selObj.min.y)
	theHeightZ = abs (selObj.max.z - selObj.min.z)
	boxAsCage = box width:theWidthX length:theLengthY height:theHeightZ --boxMode:true
	CenterPivot boxAsCage
	boxAsCage.pos = selObj.center
	boxAsCage.pivot = selObj.pivot
	convertToPoly boxAsCage
	polyop.deleteFaces boxAsCage #{1..2}
)

It will create a editable poly box around your object. If you want planes - detach the faces of the created box.

What is texture information?

barigazy's picture

:)

A bit acurate. This time I will consider object orientation, scale and mtlID's

fn createBoxAsCage obj = if isValidNode obj do
(
	local bb = in coordsys local nodeLocalBoundingBox obj
	local wX = abs((bb[1]-bb[2]).x) , lY = abs((bb[1]-bb[2]).y) , hZ = abs((bb[1]-bb[2]).z)
	local cage = convertToPoly (box width:wX length:lY height:hZ mapcoords:on)
	CenterPivot cage
	local tm = obj.transform
	tm.row4 = obj.center
	cage.transform = tm
	polyop.deleteFaces cage #{1,2}
	local mtlArr = for m = 1 to 4 collect
	(
		local id = (polyop.getFaceMatID cage m) - 2
		polyop.setFaceMatID cage m id
		standard name:("Mtl_" + m as string) diffuse:(random black white)
	)
	cage.material = Multimaterial materialList:mtlArr
	cage
)
-- example
delete objects
tea = Teapot pos:[20,50,30] dir:[0.616459,-0.51929,0.591875] scale:[.8,.8,.8]
createBoxAsCage tea

barigazy

miauu's picture

Your code works with local

Your code works with local bbox, mine with world bbox, so he can combine both methods.

barigazy's picture

Yup. Both solutions are

Yup. Both solutions are good
Regards friend!

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.