Resize to Frame
From AdeptersWiki
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 here (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 #Groups selection. Group Selection #Determines all sides of grouped art. 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 #Determines height and width of grouped art. Height = TopCoord - BottomCoord Width = RightCoord - LeftCoord #Determines resize scale. If (Height > Width) then ScalePercentage = ActiveDoc.window.pageY/(Height+BorderSize) Else ScalePercentage = ActiveDoc.window.pageX/(Width+BorderSize) End If #Scales the grouped art to proper size. Scale Selection LeftCoord BottomCoord ScalePercentage ScalePercentage #Recentered the art. Cut Zoom Page Paste #Clears temp grouping. Ungroup Selection #Clears selection. Select None End Macro