<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing absolute path of hyperlinks to relative path in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-absolute-path-of-hyperlinks-to-relative-path/m-p/13753358#M165618</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6218966"&gt;@dani_cs&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should do for ya:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;;; Hyperlink Update (Absolute --&amp;gt; Relative)
(defun c:HUAR ( / LM:XRef:Full-&amp;gt;Relative ss cnt len e eg exData urlData url)
  ;;-------------=={ Full Path to Relative Path }==-------------;;
  ;;                                                            ;;
  ;;  Converts a Full XRef path to a Relative Path.             ;;
  ;;------------------------------------------------------------;;
  ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  ;;------------------------------------------------------------;;
  ;;  Arguments:                                                ;;
  ;;  dir  - Directory of the Drawing in which the Xref resides ;;
  ;;  path - Full Xref Path                                     ;;
  ;;------------------------------------------------------------;;
  ;;  Returns:  Relative XRef Path                              ;;
  ;;------------------------------------------------------------;;
  (defun LM:XRef:Full-&amp;gt;Relative ( dir path / p q )
      (setq dir (vl-string-right-trim "\\" dir))
      (cond
          (   (and
                  (setq p (vl-string-position 58  dir))
                  (setq q (vl-string-position 58 path))
                  (not (eq (strcase (substr dir 1 p)) (strcase (substr path 1 q))))
              )
              path
          )
          (   (and
                  (setq p (vl-string-position 92  dir))
                  (setq q (vl-string-position 92 path))
                  (eq (strcase (substr dir 1 p)) (strcase (substr path 1 q)))
              )
              (LM:Xref:Full-&amp;gt;Relative (substr dir (+ 2 p)) (substr path (+ 2 q)))
          )
          (   (and
                  (setq q (vl-string-position 92 path))
                  (eq (strcase dir) (strcase (substr path 1 q)))
              )
              (strcat ".\\" (substr path (+ 2 q)))
          )
          (   (eq "" dir)
              path
          )
          (   (setq p (vl-string-position 92 dir))
              (LM:Xref:Full-&amp;gt;Relative (substr dir (+ 2 p)) (strcat "..\\" path))
          )
          (   (LM:Xref:Full-&amp;gt;Relative "" (strcat "..\\" path)))
      )
  )
  ;; ------- Main Work -------
  (if (null (setq ss (ssget "_A" '((0 . "INSERT") (-3 ("PE_URL"))))))
    (progn (alert (princ "\nNo objects with Hyperlinks found. Exiting.")) (exit))
  )
  (setq cnt (sslength ss) len cnt)
  (repeat cnt
    (setq e (ssname ss (setq cnt (1- cnt))))
    (setq eg (entget e '("PE_URL")))
    (setq exData (assoc -3 eg))
    (setq urlData (cadr exData))
    (setq url (cdr (assoc 1000 (cdr urlData))))
    (setq url (LM:XRef:Full-&amp;gt;Relative (getvar 'DWGPREFIX) url))
    (setq urlData (subst (cons 1000 url) (assoc 1000 (cdr urlData)) urlData))
    (setq exData (subst urlData (cadr exData) exData))
    (setq eg (subst exData (assoc -3 eg) eg))
    (entmod eg)
  );repeat
  (alert
    (princ
      (strcat "\nSuccessfully updated " (itoa len) " hyperlinks.")
    )
  )
  (setq ss nil)
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
    <pubDate>Mon, 04 Aug 2025 21:53:57 GMT</pubDate>
    <dc:creator>CodeDing</dc:creator>
    <dc:date>2025-08-04T21:53:57Z</dc:date>
    <item>
      <title>Changing absolute path of hyperlinks to relative path</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-absolute-path-of-hyperlinks-to-relative-path/m-p/13753260#M165617</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my issue. I have a drawing with 637 blocks. Each one has a hyperlink attached to a .JPG image file. Those hyperlink follow an absolute path, so, is there a way to global change the absolute path to a relative path of each hyperlink?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried "hyperlink base" from "drawing properties" and find and replace in .dxf format with not success.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 20:24:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-absolute-path-of-hyperlinks-to-relative-path/m-p/13753260#M165617</guid>
      <dc:creator>dani_cs</dc:creator>
      <dc:date>2025-08-04T20:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Changing absolute path of hyperlinks to relative path</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-absolute-path-of-hyperlinks-to-relative-path/m-p/13753358#M165618</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6218966"&gt;@dani_cs&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should do for ya:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;;; Hyperlink Update (Absolute --&amp;gt; Relative)
(defun c:HUAR ( / LM:XRef:Full-&amp;gt;Relative ss cnt len e eg exData urlData url)
  ;;-------------=={ Full Path to Relative Path }==-------------;;
  ;;                                                            ;;
  ;;  Converts a Full XRef path to a Relative Path.             ;;
  ;;------------------------------------------------------------;;
  ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  ;;------------------------------------------------------------;;
  ;;  Arguments:                                                ;;
  ;;  dir  - Directory of the Drawing in which the Xref resides ;;
  ;;  path - Full Xref Path                                     ;;
  ;;------------------------------------------------------------;;
  ;;  Returns:  Relative XRef Path                              ;;
  ;;------------------------------------------------------------;;
  (defun LM:XRef:Full-&amp;gt;Relative ( dir path / p q )
      (setq dir (vl-string-right-trim "\\" dir))
      (cond
          (   (and
                  (setq p (vl-string-position 58  dir))
                  (setq q (vl-string-position 58 path))
                  (not (eq (strcase (substr dir 1 p)) (strcase (substr path 1 q))))
              )
              path
          )
          (   (and
                  (setq p (vl-string-position 92  dir))
                  (setq q (vl-string-position 92 path))
                  (eq (strcase (substr dir 1 p)) (strcase (substr path 1 q)))
              )
              (LM:Xref:Full-&amp;gt;Relative (substr dir (+ 2 p)) (substr path (+ 2 q)))
          )
          (   (and
                  (setq q (vl-string-position 92 path))
                  (eq (strcase dir) (strcase (substr path 1 q)))
              )
              (strcat ".\\" (substr path (+ 2 q)))
          )
          (   (eq "" dir)
              path
          )
          (   (setq p (vl-string-position 92 dir))
              (LM:Xref:Full-&amp;gt;Relative (substr dir (+ 2 p)) (strcat "..\\" path))
          )
          (   (LM:Xref:Full-&amp;gt;Relative "" (strcat "..\\" path)))
      )
  )
  ;; ------- Main Work -------
  (if (null (setq ss (ssget "_A" '((0 . "INSERT") (-3 ("PE_URL"))))))
    (progn (alert (princ "\nNo objects with Hyperlinks found. Exiting.")) (exit))
  )
  (setq cnt (sslength ss) len cnt)
  (repeat cnt
    (setq e (ssname ss (setq cnt (1- cnt))))
    (setq eg (entget e '("PE_URL")))
    (setq exData (assoc -3 eg))
    (setq urlData (cadr exData))
    (setq url (cdr (assoc 1000 (cdr urlData))))
    (setq url (LM:XRef:Full-&amp;gt;Relative (getvar 'DWGPREFIX) url))
    (setq urlData (subst (cons 1000 url) (assoc 1000 (cdr urlData)) urlData))
    (setq exData (subst urlData (cadr exData) exData))
    (setq eg (subst exData (assoc -3 eg) eg))
    (entmod eg)
  );repeat
  (alert
    (princ
      (strcat "\nSuccessfully updated " (itoa len) " hyperlinks.")
    )
  )
  (setq ss nil)
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 21:53:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-absolute-path-of-hyperlinks-to-relative-path/m-p/13753358#M165618</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-08-04T21:53:57Z</dc:date>
    </item>
  </channel>
</rss>

