cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Isodraw 7.2, macro to add the "filename" to graphic window?

hdoubet
1-Visitor

Isodraw 7.2, macro to add the "filename" to graphic window?

I have a multitude of graphics in which the filename (i.e. "drawing1.cgm, drawing2.cgm, etc) needs to be added within the image area of the graphic. Can a macro be created to specifically target each file in the location they reside, copy the filename, open the graphic and paste into the graphic window?

I can make a macro to "singly" do that task to one file...but now sure how to have it continuously go thru the files in a consecutive order.

Thanks

ACCEPTED SOLUTION

Accepted Solutions
TimSharp
12-Amethyst
(To:hdoubet)

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

View solution in original post

7 REPLIES 7
thendricks
12-Amethyst
(To:hdoubet)

You'd want to use the batch tool that is native to IsoDraw. You can select the directory containing your files, the macro you want to run against it, and then the destination folder (must be different from source).

Think its more than I bargained for. I did a "record macro" in IsoDraw for what i want done, but its very basic and limits it to one graphic for the "change" since I am copying the specific filename and pasting in the specific graphic. I dont know how to have the macro recognize the rest of the incrementing "filenames" and do the function I require (i.e. copy the filename, paste it into the graphic frame as an graphic ID, and locate the graphic ID at the lower right hand corner at the extent of the illustration).

Try this as we do the same thing when you are authoring the document. Copy this to note pad, rename to ism and place it in your macros folder. When you repoen isodraw you should now have a macro in your macro tab. Macro Add_FileName Define h As Integer Define w As Integer w = activeDoc.window.pageX-2 h = 2 #Message "The height is " + h #Message "The width is " + w #Added below command to ensure number is placed on the Illustation number layer ACTIVATE LAYER "Illustration Number" Select none Text Align Left Text font 'Arial' Text size 6 Create Text w h stripext(activeDoc.name) Rotate selection w h 90 BRyon

Thank you very much! I will give it a try.

hdoubet
1-Visitor
(To:hdoubet)

Bryon. I took the info you sent me and the macro works in my testing as it pulls the "filename" of the file and puts it on the IsoDraw graphic. The "filename" appears at the lower right of the graphic window...but I need the "filename" to be located below the lower right extent of the actual graphic. Can the macro be made to "find" that location? Thanks.

Macro Add filename_test

Define docname as String

docname = stripExt(activeDoc.name)

Define h As Integer

Define w As Integer

w = activeDoc.window.pagex-2

h = 2

#Message "The height is " + h

#Message "The width is " + w

Text font "arial"

Text size 6

Create Text w h docname

end macro

ICN-12345-001-01.jpg

TimSharp
12-Amethyst
(To:hdoubet)

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

Tim,

Thank you very much. Modified it with what I need and it works great.

Announcements

Top Tags