+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member brawleyman's Avatar
    Computer Details
    brawleyman's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision T3500
    CPU:
    Intel Xeon W3530 (4x2.8Ghz)
    RAM:
    6Gb DDR3
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    250Gb
    Monitor:
    Asus 20" 1680x1050, Samsung 24" 1920x1080
    Using
    AutoCAD 2010
    Join Date
    Oct 2008
    Location
    Bentonville, AR
    Posts
    100

    Default A "Help me with this drawing" email link

    Registered forum members do not see this ad.

    I am constantly getting requests to help others with their drawings. Pretty much every time, I could get into the drawing, make the change or fix it and save out before the other person can even begin to troubleshoot the problem.

    Basically, I am looking for a big "Help Me!" button that I can put on everyone's shared toolbar that will automatically send an email to me with a link to the file they are working in. I have a couple of lines of code that almost get me to where I want, but, I am having trouble with the "%20" for spaces in the file path. When you just get the path, it stops at the first space, using vl-string-translate spaces to %20 messes up the path totally, and using underscore won't get me anywhere either.

    You can copy each line separately in order in my code below to quickly test and see what the issue is I am having with it.

    Code:
    (setq dwglocation (strcat (getvar "dwgprefix")(getvar "dwgname")))
    (command "start" (strcat "mailto:me.myself.and.i@someemail.com?body=Here%20is%20the%20file:%20file:///"(vl-string-translate " " "_" dwglocation)))
    I guess I am basically needing a different way to translate the string or something so that it populates properly in Outlook for the hyperlink.

    Oh, and also, for whatever reason, I cannot get mailto to put in a subject and body at the same time, it is either one or the other, so I just left off the subject for now.
    Guess what? I got a fever! And the only prescription.. is more Cad Lines!

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Maybe:

    Code:
    (defun _mailfile ( filepath )
        (while (vl-string-position 32 filepath)
            (setq filepath (vl-string-subst "%20" " " filepath))
        )
        (setq filepath (vl-string-translate "\\" "/" filepath))
        (command "_.start"
            (strcat
                "mailto:me.myself.and.i@someemail.com?body=Here%20is%20the%20file:%20file:///"
                filepath
            )
        )
        (princ)
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Senior Member brawleyman's Avatar
    Computer Details
    brawleyman's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision T3500
    CPU:
    Intel Xeon W3530 (4x2.8Ghz)
    RAM:
    6Gb DDR3
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    250Gb
    Monitor:
    Asus 20" 1680x1050, Samsung 24" 1920x1080
    Using
    AutoCAD 2010
    Join Date
    Oct 2008
    Location
    Bentonville, AR
    Posts
    100

    Default

    Thanks for the quick response Lee! I am trying to call it from a macro and it says it is an unknown command. I tried changing it to c:_mailfile and still doesn't come up. How do I need to call this command?


    ***EDIT***
    Okay, I added a line to set the filepath to the dwgprefix and dwgname to find the drawing. When I try to run the command "emailme", it creates the link and displays the full path, but only underlines and creates the link out of the path up to the first space.

    Code:
    (defun c:emailme ()
        (setq filepath (strcat (getvar "dwgprefix")(getvar "dwgname")))
        (while (vl-string-position 32 filepath)
            (setq filepath (vl-string-subst "%20" " " filepath))
        )
        (setq filepath (vl-string-translate "\\" "/" filepath))
        (command "_.start" (strcat"mailto:me.myself.and.i@someemail.com?body=Here%20is%20the%20file:%20file:///" filepath))
        (princ)
    )
    Here is an example of a filepath: "E:\\FP Department\\Group Resources FP\\_FP CAD Standards\\CUI\\LISP\\MEP Design\\CIRCUIT TYPICAL.dwg".

    The resulting link in Outlook comes out like this: "Here is the file: file:///E:/FP Department/Group Resources FP/_FP CAD Standards/CUI/LISP/MEP Design/CIRCUIT TYPICAL.dwg".

    What am I doing wrong?
    Last edited by brawleyman; 9th May 2012 at 02:51 pm.
    Guess what? I got a fever! And the only prescription.. is more Cad Lines!

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Quote Originally Posted by brawleyman View Post
    I am trying to call it from a macro and it says it is an unknown command. I tried changing it to c:_mailfile and still doesn't come up. How do I need to call this command?
    The code I posted is a function that requires a single argument: the filename of the file to be linked, hence you would call it:

    Code:
    (_mailfile "C:\\Your File.dwg")
    Or:

    Code:
    (_mailfile (strcat (getvar 'dwgprefix) (getvar 'dwgname)))
    Quote Originally Posted by brawleyman View Post
    When I try to run the command "emailme", it creates the link and displays the full path, but only underlines and creates the link out of the path up to the first space.

    What am I doing wrong?
    I hadn't tested it, but I guess this is the behaviour of the mail client. Maybe you need to enclose the filepath with quotes, or some other special character.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  5. #5
    Senior Member brawleyman's Avatar
    Computer Details
    brawleyman's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision T3500
    CPU:
    Intel Xeon W3530 (4x2.8Ghz)
    RAM:
    6Gb DDR3
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    250Gb
    Monitor:
    Asus 20" 1680x1050, Samsung 24" 1920x1080
    Using
    AutoCAD 2010
    Join Date
    Oct 2008
    Location
    Bentonville, AR
    Posts
    100

    Default

    Ah, I understand how that works now with the parentheses after the defun, thanks Lee!

    Well, I suppose now I just have to figure out how to enclose the filepath. I don't know if it is going to be something specific to LISP or Outlook to input the file path correctly.


    From what little I can find, Outlook uses "<" and ">" to enclose links with spaces as one whole link. I have been trying to incorporate these symbols into the mailto link in lisp, but it comes up nil. I don't know if I am putting it into the right place or what.
    Last edited by brawleyman; 9th May 2012 at 04:28 pm.
    Guess what? I got a fever! And the only prescription.. is more Cad Lines!

  6. #6
    Senior Member brawleyman's Avatar
    Computer Details
    brawleyman's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision T3500
    CPU:
    Intel Xeon W3530 (4x2.8Ghz)
    RAM:
    6Gb DDR3
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    250Gb
    Monitor:
    Asus 20" 1680x1050, Samsung 24" 1920x1080
    Using
    AutoCAD 2010
    Join Date
    Oct 2008
    Location
    Bentonville, AR
    Posts
    100

    Default

    Sweet! I got it figured out! Here is my code that allows you to accomplish what I was wanting to do:

    Code:
    (defun c:emailme ()
      (setq getemail "me.myself.and.i@someemail.com");input email of helper
      (setq filepath (strcat "<file:///" (getvar "dwgprefix")(getvar "dwgname") ">"))
    
      ;;Conversion Table
      (while (vl-string-position 32 filepath)
        (setq filepath (vl-string-subst "%20" " " filepath))
      );end while
    ;  (while (vl-string-position 35 filepath)
    ;    (setq filepath (vl-string-subst "%23" "#" filepath))
    ;  );end while
      (while (vl-string-position 38 filepath)
        (setq filepath (vl-string-subst "%26" "&" filepath))
      );end while
      (while (vl-string-position 39 filepath)
        (setq filepath (vl-string-subst "%27" "'" filepath))
      );end while
      (while (vl-string-position 44 filepath)
        (setq filepath (vl-string-subst "%2C" "," filepath))
      );end while
      (while (vl-string-position 58 filepath)
        (setq filepath (vl-string-subst "%3A" ":" filepath))
      );end while
      (while (vl-string-position 60 filepath)
        (setq filepath (vl-string-subst "%3C" "<" filepath))
      );end while
      (while (vl-string-position 62 filepath)
        (setq filepath (vl-string-subst "%3E" ">" filepath))
      );end while
      (while (vl-string-position 92 filepath)
        (setq filepath (vl-string-subst "%5C" "\\" filepath))
      );end while
    
      (command "_.start" (strcat "mailto:" getemail "?Body=Here%20is%20the%20file%3A%20" filepath))
    );end defun
    Basically, you have to code for every possible symbol that may be used in a file path. The only one I cannot get to work is the "#" hash tag/pound/number sign. Apparently, it is a very special character in mailto links. When you have a file path with that symbol, it appears correct in the email, but clicking on it says "cannot find file". After looking at the actual address created from it when you edit the hyperlink, for some reason there is no space put before the "#" sign, even if %20 or a space is in front of it or you add an extra %20 before the %23 in the conversion setup.

    Very perplexing. I guess we won't be able to use that symbol in our folders, but it would be nice to be able to include it somehow. Anybody know?
    Guess what? I got a fever! And the only prescription.. is more Cad Lines!

  7. #7
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Localize your variables like this ...

    Code:
    (defun c:emailme (/ filepath getemail)
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  8. #8
    Senior Member brawleyman's Avatar
    Computer Details
    brawleyman's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision T3500
    CPU:
    Intel Xeon W3530 (4x2.8Ghz)
    RAM:
    6Gb DDR3
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    250Gb
    Monitor:
    Asus 20" 1680x1050, Samsung 24" 1920x1080
    Using
    AutoCAD 2010
    Join Date
    Oct 2008
    Location
    Bentonville, AR
    Posts
    100

    Default

    Thanks Tharwat! I am newer and self-taught with LISP. What exactly does localizing variables do? Does it still allow for other routines to reference values from other routines?
    Guess what? I got a fever! And the only prescription.. is more Cad Lines!

  9. #9
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    One reason , is that If you do not localize variables into your routine , variables would become globally into your current opened drawing , and if you have any other codes
    that are running in the same drawing and may have the same variable 's names , things would be mixed up and outcome of codes might become odd and illogically .
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  10. #10
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,007

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by brawleyman View Post
    Does it still allow for other routines to reference values from other routines?
    Those are called global variables and a recommended practice is to surround them by "*" characters.
    Code:
    *GlobalVariableName*
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

Similar Threads

  1. drawing "by block" not "by layer"
    By DoctorDrake in forum AutoCAD General
    Replies: 10
    Last Post: 8th Mar 2012, 09:21 pm
  2. Replies: 1
    Last Post: 25th Nov 2009, 06:35 pm
  3. "LINK template" icons "greyed out" -why?
    By Chrisjpritchard in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 2nd Mar 2007, 10:25 pm
  4. Misc: Interesting Presentation "Turning Email Upside Down" HMTP
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 8th Oct 2006, 07:32 am
  5. Look out for "Good Day" Email Virus.. :-(
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 25th Sep 2006, 08:40 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts