Here is a macro that I think fits your needs.
It’s a modified version of a macro that I got back in 2006 from the old ITEDO forums
Credit goes to the original author.
global FWidth as float
global FHeight as float
global MoveX as float
global GRP as element
global MoveY as float
global Width as float
global Height as float
global DestWidth as float
global Destheight as float
global ScaleX as float
global ScaleY as float
global Scale as float
global LLpt as point
global ScaledWidth as float
global ScaledHeight as float
global NHFrame as point
global MoveScaledX as float
global MoveScaledY as float
#################
Macro Center all
Select None
Unlock all
# Get and set page Size
FWidth = activeDoc.window.pageX
FHeight = activeDoc.window.pageY
#Select all for Move calculations and create a copy to keep layers (Note: grouping removes layers ... we don't want this)
Select all
Duplicate
Group Selection
GRP = activeDoc.firstSelectedElement
#Determine Image's Width and Height
Width = GRP.box.right - GRP.box.left
Height = GRP.box.top - GRP.box.bottom
#Size of NH Frame in mm
DestWidth = Width
Destheight = Height
#Delete original selection (the copy is still there, copy has layer control which we want)
Delete Selection
#Select all for moving calculations and create a copy to keep layers (Note: grouping removes layers ... we don't want this)
Select all
Duplicate
Group Selection
GRP = activeDoc.firstSelectedElement
#Set Lower Left point (0,0) to move the geometry to
LLpt.x = 0
LLpt.y = 0
#Determine values to move geometry to 0,0
MoveX = -(GRP.box.left-LLpt.x)
MoveY = -(GRP.box.bottom-LLpt.y)
#Delete original selection (the copy is still there, copy has layer control which we want)
Delete Selection
#Move temporarily to 0,0 then will calculate final destination of geometry
Select all
Move selection MoveX MoveY no_Patterns
select none
#Select all for moving calculations and create a copy to keep layers (Note: grouping removes layers ... we don't want this)
Select all
Duplicate
Group Selection
GRP = activeDoc.firstSelectedElement
#Determine Scaled geometry's Width and Height
ScaledWidth = GRP.box.right - GRP.box.left
ScaledHeight = GRP.box.top - GRP.box.bottom
#Set Dimensions (mm) for Center of NH Frame
NHFrame.x = fWidth/2
NHFrame.y = fHeight/2
#Determine the final move values to move the Scaled geometry to the center of the NH Frame
MoveScaledX = (NHFrame.x-(ScaledWidth/2))
MoveScaledY = (NHFrame.y-(ScaledHeight/2))
#Delete original selection (the copy is still there, copy has layer control which we want)
Delete Selection
#Final move to move the Scaled geometry to the center of the NH Frame
Select all
Move selection MoveScaledX MoveScaledY no_Patterns
Select None
Zoom page
End Macro