Resize to Frame

Answered by: Trevor Hendricks Last Updated: 2006-07-06

This is a macro Trevor Hendricks created using some of his own stuff and meeting a forum member's request.

Description
Basically, start the macro by having something selected. It then resizes the selection to fit the frame. This is a simplified version. Here are the things to note.

1) The 'bordersize" variable is used to keep the art smaller than the frame. You can play with this variable and see the effects.

2) Biggest item is that, as mentioned, this is simplified. If you have items on multiple layers, it will put them on the active layer. It doesn't keep them in their individual layers. It's possible, but a longer macro.

Code
Download the .ism file (tar).

Macro Resize_to_Frame_Specify_Border Define LeftCoord as Float Define RightCoord as Float Define TopCoord as Float Define BottomCoord as Float Define Height as Float Define Width as Float Define ScalePercentage as Float Define BorderSize as Float BorderSize = .1 Group Selection Create object_Info ActiveDoc.FirstSelectedElement ActiveDoc.FirstSelectedElement.Info.View_Context.type = "extent" Leftcoord = ActiveDoc.FirstSelectedElement.Info.View_Context.Rectangle.Left RightCoord = ActiveDoc.FirstSelectedElement.Info.View_Context.Rectangle.Right TopCoord = ActiveDoc.FirstSelectedElement.Info.View_Context.Rectangle.Top BottomCoord = ActiveDoc.FirstSelectedElement.Info.View_Context.Rectangle.Bottom Height = TopCoord - BottomCoord Width = RightCoord - LeftCoord If (Height > Width) then ScalePercentage = ActiveDoc.window.pageY/(Height+BorderSize) Else ScalePercentage = ActiveDoc.window.pageX/(Width+BorderSize) End If 	Scale Selection LeftCoord BottomCoord ScalePercentage ScalePercentage Cut Zoom Page Paste Ungroup Selection Select None End Macro
 * 1) Groups selection.
 * 1) Determines all sides of grouped art.
 * 1) Determines height and width of grouped art.
 * 1) Determines resize scale.
 * 1) Scales the grouped art to proper size.
 * 1) Recentered the art.
 * 1) Clears temp grouping.
 * 1) Clears selection.