Scale to the parent object

Guys help.
Find the script that will scale to the parent object.

Example attached.

Thanks

AttachmentSize
2019-03-22_12-04-03.jpg65.23 KB

Comments

Comment viewing options

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

.

child  = pickObject()
parent = pickObject()
 
if isValidNode child and isValidNode parent do
(
 
  about child.center
  (
		local target_scale = (parent.max - parent.min) / (child.max - child.min)
 
		if (abs target_scale[1]) < 0.0001 or bit.isNAN target_scale[1] do target_scale[1] = 0
		if (abs target_scale[2]) < 0.0001 or bit.isNAN target_scale[2] do target_scale[2] = 0
		if (abs target_scale[3]) < 0.0001 or bit.isNAN target_scale[3] do target_scale[3] = 0
 
		child.scale *= target_scale
  )
 
 
-- comment this line if you don't need to move child to parent center
  child.center = parent.center
 
)
ibm's picture

Thanks for the reply

It is possible that the parent can be not only a square, but also a rectangle.
It is desirable that the child was not tied to the parent.

and what would the properties of the child was loose, now they are blocked

sorry for my English, it's all mechanical translation :)

jahman's picture

.

maybe this thread could help you

  scale child ((parent.max - parent.min) / (child.max - child.min))
  child.center = parent.center

Comment viewing options

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