Notifications
Clear all

[Closed] Scale to fit Oblect

I have 2 object in the scene : Teapot001 and Teapot002 with diffenrent size and direction. I want a script : move and scale Teapot001 to fit Teapot002. Please help me , thank alot

6 Replies

this is not really the place were people solving for free anybody’s else homework.

but there are many very kind persons here, and someone can be kind enough to help you.

i suggest you to try yourself first, show us your code… and we will help you to fix it. ok?

I create Teapot001 and Teapot002 ; and when i move and rotate Teapot001 then run this code but, they don’t alwayTeapot002 fit Teapot001, How to fix this?

theObj = $Teapot001
theV = [1,0,0]
c = $teapot002
c.pos = theObj.pos
rm = rotateZMatrix a
theRotV = theV * rm

c.dir = theRotV
c.transform *= theObj.transform
theObj.center = c.center

is this what you want?

one = $Teapot001
two = $Teapot002
r1 = one.radius
two.transform = one.transform
two.radius = r1

Thank you Evil-Fish, it is very simple than i thought

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s just simple for teapots…

delete objects
t0 = teapot pos:[10,20,10] radius:30 wirecolor:blue
t1 = teapot pos:[20,10,20] radius:20 wirecolor:yellow

-- align with scale

size_t0 = t0.max - t0.min 
size_t1 = t1.max - t1.min 

t1.center = t0.center
in coordsys world about t0.center scale t1 (size_t0/size_t1)




------- no is the same with Z rotation -------

delete objects
t0 = dummy pos:[10,20,10] rotation:(eulerangles 0 0 90) boxsize:[90,60,80] wirecolor:blue
t1 = geosphere pos:[20,10,20] radius:20 wirecolor:yellow

-- align with scale

size_t0 = t0.max - t0.min 
size_t1 = t1.max - t1.min 

t1.center = t0.center
in coordsys world about t0.center scale t1 (size_t0/size_t1)

you have to know what bounding box and coordinate system are, to understand how things work in this snippet