Skip to main content
18-Opal
January 25, 2017
Solved

macro to export cgm to users pictures folder

  • January 25, 2017
  • 1 reply
  • 1824 views

What does the code need to look like? Folder location would be C:\users\username\pictures\, how does it change for each individual user as the username changes.

Macro export CGM to user pictures folder

# recorded with Arbortext IsoDraw 7.3

  app.interaction=false

  Save

  Define final2 as string

    final2="X:\Photos\" + stripext(activedoc.name) + ".jpg"

    Export final2 "JPEG"

  app.interaction=true

  app.interaction=false

  Save

  Define final as string

    final="C:\users\username\pictures\" + stripext(activedoc.name) + ".cgm"

    Export final "cgm"

  app.interaction=true

End Macro

Thanks

Bryon

    Best answer by thendricks

    Check to ensure you have a C:\temp folder on your computer. It's pretty standard but...

    This is also assuming you used macro exactly. If not, please post the contents of your macro.

    1 reply

    12-Amethyst
    January 25, 2017

    If I understand, you want the following line to vary depending on who is running the macro. Correct?

         final="C:\users\username\pictures\" + stripext(activedoc.name) + ".cgm"

    If I'm understanding, I do not believe there is a way to capture the user name. There is a 'system' type command.

    Try this as an alternative. Hopefully the comments all make sense.

    Macro myExports

        #Define variables.

        Define JPGLocal as string

        Define CGMLocal as string

        Define fileName as string

        Define CMDLocal as string

        Define tempLocal as string

        Define tempCGM as string

       

        #Define cmd.exe.

        CMDLocal = "C:\WINDOWS\system32\cmd.exe"

       

        #Define local temp Local.

        tempLocal = "C:\temp\"

       

        #Turn off possible error/warning prompts during export.

        app.interaction=false

       

        #Save file to current Local.

        Save

       

        #Define variable for file name

        fileName = stripext(activedoc.name)

           

        #Set export Local for jpg.

        JPGLocal="X:\Photos\" + fileName + ".jpg"

       

        #Export jpg.

            Export JPGLocal "JPEG"

     

            #Set temp CGM export path.

            tempCGM = tempLocal + filename + ".cgm"

           

            #Set final cgm Local using cmd format (%variables%).

        CGMLocal = "%userprofile%\pictures\" + stripext(activedoc.name) + ".cgm"

        #Export CGM to temporary location.

            Export tempCGM "CGM"

           

            #Calls a cmd window and runs a move command to move the file to the final location.

            Launch CMDLocal "/c move /Y " + tempCGM + " " + CGMLocal

           

            #Turns prompts on.

            app.interaction=true

    End Macro

    bfriesen18-OpalAuthor
    18-Opal
    January 26, 2017

    Thanks Trevor, I am getting an error log that states

    MacDon_macros.ismexport CGM to User Pictures folder

    The file '%ls' is not open. "Export tempCGM "CGM""

    Thanks

    Bryon

    12-Amethyst
    January 26, 2017

    Check to ensure you have a C:\temp folder on your computer. It's pretty standard but...

    This is also assuming you used macro exactly. If not, please post the contents of your macro.