Hi Harold
been away so just read this.
We have used a macro for years to add the drawing name at bottom right of our drawings. I was helped by Trevor Hendricks to work out the drawing extents, then made a variable of the lower right position and added the text there. Note that our macro moves the text up and left a bit, but you might want to move it down and to the right for your use - see the lines:
text_pos_x = (gl_RightCoord - 1)
text_pos_y = (gl_BottomCoord + 1)
This macro calls 2 other macros (also included below), so you need them all, but you just run drawing name text.
Macros below:
macro drawing name text
Select None
define textstring as element
textstring = stripExt(activeDoc.name)
# 1. WORKS OUT THE BOTTOM RIGHT LOCATION OF THE CURRENT DRAWING TO PLACE TEXT. IT THEN MOVES IT LEFT AND UP 1 IN CASE A NO-LINE FRAME IS DRAWN.
run find_drawing_extents
define text_pos_x as float
define text_pos_y as float
text_pos_x = (gl_RightCoord - 1)
text_pos_y = (gl_BottomCoord + 1)
Text size 6
Text font "arial"
Text align right
create text text_pos_x text_pos_y textstring
End macro
# FROM MACRO find_drawing_extents
global gl_move_dist as float
global gl_LeftCoord as float
global gl_RightCoord as float
global gl_TopCoord as float
global gl_BottomCoord as float
global gl_LeftCoordnext as float
global gl_RightCoordnext as float
global gl_TopCoordnext as float
global gl_BottomCoordnext as float
global gl_RemovePen as float
submacro find_drawing_extents NOT_IN_MENU
#Defines variables.
Define LastLayer as Layer
Define Frame_Top as Float
Define Frame_Right as Float
Define i as Integer
Define CurrentLayer as String
Define LayerName as String
#SO IT CAN GO BACK TO ORIGINAL LAYER AFTERWARDS
run get-active-Layer
#Unlocks everything.
Unlock
#Sets values of variables.
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
Frame_Right = ActiveDoc.window.pageX
Frame_Top = ActiveDoc.window.pageY
gl_LeftCoord = 999999999
gl_RightCoord = -999999999
gl_TopCoord = -999999999
gl_BottomCoord = 999999999
LastLayer = ActiveDoc.Layers["Background"]
#message gl_BottomCoord
#Starts loop that goes through all existing layers and locks each.
While (Exists(CurrentLayer) = True)
#Locks current layer.
CurrentLayer.Locked = 1
#Advances to the next layer.
CurrentLayer = CurrentLayer.PreviousSibling
End While
#Resets values of variables.
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
#Starts loop that goes through all existing layers.
While (Exists(CurrentLayer) = True)
#Unlocks current layer.
CurrentLayer.Locked = 0
LastLayer = CurrentLayer
LayerName = CurrentLayer.Name
#Groups the selection.
Activate layer LayerName
Select All
Group Selection
#Creates object info for the group and determines the extent.
Create object_info ActiveDoc.firstSelectedElement
ActiveDoc.firstSelectedElement.info.view_context.type = "extent"
gl_LeftCoordnext = ActiveDoc.firstSelectedElement.info.view_context.rectangle.left
gl_RightCoordnext = ActiveDoc.firstSelectedElement.info.view_context.rectangle.right
gl_TopCoordnext = ActiveDoc.firstSelectedElement.info.view_context.rectangle.top
gl_BottomCoordnext = ActiveDoc.firstSelectedElement.info.view_context.rectangle.bottom
#Ungroups the selection.
Ungroup Selection
Select None
#Compares Extent to existing to determine the farthest extents.
If (gl_LeftCoordnext < gl_LeftCoord)
gl_LeftCoord = gl_LeftCoordnext
End If
If (gl_RightCoordnext > gl_RightCoord)
gl_RightCoord = gl_RightCoordnext
End If
If (gl_TopCoordnext > gl_TopCoord)
gl_TopCoord = gl_TopCoordnext
End If
If (gl_BottomCoordnext < gl_BottomCoord)
gl_BottomCoord = gl_BottomCoordnext
End If
#Clears selection.
Select None
#Advances to the next layer.
CurrentLayer = CurrentLayer.PreviousSibling
LastLayer.Locked = 1
Select None
End While
#Resets values of variables.
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
#Starts loop that goes through all existing layers and unlocks each.
While (Exists(CurrentLayer) = True)
#Turns selected layer visibility on.
CurrentLayer.Locked = 0
#Advances to the next layer.
CurrentLayer = CurrentLayer.PreviousSibling
End While
#Clears selection.
Select None
#NOW GO BACK TO original_layer
Activate layer gl_active_layer
End submacro
global gl_active_layer as string
submacro get-active-Layer
Define layer_count as integer
Define CurrentLayer as string
gl_active_layer = ''
#Sets values of variables.
layer_count = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[layer_count]
#goes through all existing layers and checks which is currently active. Then sets gl_active_layer to that layer.
While (Exists(CurrentLayer) = True)
If (CurrentLayer.Active = True) Then
gl_active_layer = CurrentLayer.Name
Else
End If
CurrentLayer = CurrentLayer.PreviousSibling
End While
End submacro