Jump to content

Hyperlinks created with LISP not working on PDF.


Shavee

Recommended Posts

Hello,

 

Please help me with this issue... I have been on Google for an hour and find nothing.

 

If I manually hyperlink a block to a layout, that hyperlink works on PDF after publishing the project.

 

So, I developed a LISP routine that generates those hyperlinks automatically according to what I need. The generated hyperlinks work flawlessly in CAD, but when I publish the project to PDF they doesn't work there for some reason.

 

I think the problem could be in the "Convert DWG hyperlinks to DWF" option, but after generating the hyperlinks with the LISP, that option is marked in all hyperlinks.

 

The code I'm using is very rudimentary, here's a chunk:

 

(setq i 0)
(repeat (sslength nb)
	(setq tempb (LM:getattributevalue (ssname nb i) "SHF"))
	(command "-hyperlink" "_I" "_O" (ssname nb i) "" "" (strcat "#," tempb) tempb)
	(setq i (1+ i))
)

 

As you can see, I have a selection set with all blocks I need, named nb. Then I use one of Master LeeMac's routines to get the value on attribute SHF for each of them - Those attributes correspond with layout names.

 

Then, I just run the command -HYPERLINK for every block and add #,(value) as a link. Works on CAD... but not on PDF.

 

Any ideas?

Link to comment
Share on other sites

It looks like nobody knows the answer to your question Shavee 😟 , I know I don't because I never use hyperlinks in my drawings. Mainly because where I work , IT department love 2 things : block things (like card games & porn sites) and once a year or so change things (like server paths). May have played with them once or twice but thats about it I'm afraid.

 

That being said , have you read this : https://www.cadforum.cz/cadforum_en/how-to-export-pdf-with-hyperlinks-from-autocad-tip10301

 

Hope there is someone somewhere out there that can help you better. Good luck.

Link to comment
Share on other sites

Thank you for the comment, but the export process doesn't seem to be the problem.

 

I finally found a solution! It took me so long because there is absolutely NO info on Google about that. So, I'll leave it here:

 

(command "-hyperlink" "_I" "_O" (ssname selset i) "" "" (strcat "," val) val)

That goes into a loop. SELSET is the selection set containing all blocks I want to add hyperlinks to; I is the incremental value for the loop; and VAL is the name of the layout.

 

But that is SUPER cool. Now all my section marks are linked to layouts, so I can just click any section mark in the PDF and it flies to the page where they are, as Revit does natively.

 

Some weirdness I found in that matter:

 

- You need that comma to refer to a layout. Then, Autocad for some reason adds a hashtag sign to the URL.

- The SETURL Lisp command doesn't work, for some reason. If I want to link to, say, layout P2, and I add a hyperlink to ",P2" it throws an error saying "Hyperlink destination cannot be found".

- I also tried adding a hyperlink via VLA-ADD, but I couldn't make that work either. Same example... it created a hyperlink to ",P2" but when clicking it just opens the dwg file's folder. Weirdly, if you open the hyperlink dialog box on that object after that, and just click Ok without changing any parameter, the hyperlink suddently works.

- And I also found this guy from 2008 that had the exact same problem, in his case in VBA.

Edited by Shavee
  • Thanks 1
Link to comment
Share on other sites

I won't pretend I completely understand everything you wrote without an example but I'm glad you got it working , and better yet, you accomplished this yourself, those are the moments that make you sleep well at night, bravo! I'm sure others will profit from your post. 👍

Link to comment
Share on other sites

18 hours ago, Shavee said:

Thank you for the comment, but the export process doesn't seem to be the problem.

 

I finally found a solution! It took me so long because there is absolutely NO info on Google about that. So, I'll leave it here:

 


(command "-hyperlink" "_I" "_O" (ssname selset i) "" "" (strcat "," val) val)

That goes into a loop. SELSET is the selection set containing all blocks I want to add hyperlinks to; I is the incremental value for the loop; and VAL is the name of the layout.

 

But that is SUPER cool. Now all my section marks are linked to layouts, so I can just click any section mark in the PDF and it flies to the page where they are, as Revit does natively.

 

Some weirdness I found in that matter:

 

- You need that comma to refer to a layout. Then, Autocad for some reason adds a hashtag sign to the URL.

- The SETURL Lisp command doesn't work, for some reason. If I want to link to, say, layout P2, and I add a hyperlink to ",P2" it throws an error saying "Hyperlink destination cannot be found".

- I also tried adding a hyperlink via VLA-ADD, but I couldn't make that work either. Same example... it created a hyperlink to ",P2" but when clicking it just opens the dwg file's folder. Weirdly, if you open the hyperlink dialog box on that object after that, and just click Ok without changing any parameter, the hyperlink suddently works.

- And I also found this guy from 2008 that had the exact same problem, in his case in VBA.

Glad you figured this out for yourself! Does this code below work for you?

 

(defun c:foo (/ lyt s)
  ;; RJP » 2020-09-09
  (cond	((setq s (ssget ":L"))
	 (regapp "PE_URL")
	 ;; This is where you define the layout to link to
	 (setq lyt (car (layoutlist)))
	 (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (entmod (append (entget x)
			   (list (list -3
				       (list "PE_URL"
					     '(1000 . "")
					     '(1002 . "{")
					     (cons 1000 (strcat "#," lyt))
					     (cons 1000 (strcat "," lyt))
					     '(1002 . "{")
					     '(1071 . 1)
					     '(1002 . "}")
					     '(1002 . "}")
				       )
				 )
			   )
		   )
	   )
	 )
	)
  )
  (princ)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...