Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Perfect Preview - Hyperlinks are Underrated!

CodeDing
Advisor

Perfect Preview - Hyperlinks are Underrated!

CodeDing
Advisor
Advisor

In my opinion, one of the MOST underutilized features of AutoCAD is the hyperlink.

 

Why is it underutilized?

Well because it's clunky, slow, and doesn't seem usefully implemented to most people. To create a hyperlink, you need to click an object that you want hyperlinked, then browse to a file or add URL, then when you want to view that hyperlink, to have to Ctrl + Click, THEN sometimes AutoCAD decides to minimize itself while opening the hyperlink.

 

Why use hyperlinks if they're so clunky?
In a world where so much information is available at your fingertips, I have a very strong philosophy when trying to customize my AutoCAD environment:
Provide as many useful resources / tools to the AutoCAD user as possible that Prevent them from having to utilize / navigate other programs.

What does this mean? Well, for example, if we can add a note inside of AutoCAD instead of having to create a separate "README.txt" file, then this saves the user from having to navigate in File Explorer and open Notepad, when they could have the information available to them directly in AutoCAD... If you can add an image or snip and paste it into AutoCAD so that a user does not have to navigate to look at that resource, then that saves the user from having to navigate other programs also.
HYPERLINKS ALLOW USERS TO EASILY RETRIEVE EXTERNAL DOCUMENTS / INFORMATION WITHOUT HAVING TO LEAVE THE AUTOCAD ENVIRONMENT.

 

Then what's the problem you're trying to solve?
Hyperlinks have 2 problems in my opinion:
1) They're slow/difficult/unintuitive to create.
2) They're NOT useful to view with Ctrl + Click and only 1 at a time.
...I have created a solution for Problem #2, called Perfect Preview

 

What is Perfect Preview?
Perfect Preview evolved from a niche problem I was having when trying to view site photos, as seen from this post. My Photo Preview command was so effective within our company that it resonated with me that this could help us view MORE than just Photos from within AutoCAD; Why not PDFs? Why not text files? Audio files? Video files? etc. All of our users could be SO much more informed in a faster manner than having to navigate multiple times to resources that they could have available to them from right inside of AutoCAD.

 

How does it work?
When you run the PERFECTPREVIEW command (PP for short), you will be prompted to select ANY HYPERLINKED OBJECT. Literally anything with a Hyperlink (which can be ANY visible entity in AutoCAD). Then, the code will determine generally what the hyperlink is linking to (Image, PDF, url, txt file, etc). A Temporary HTML file is created via the (vl-filename-mktemp ...) function. And then we open the HTML file as a Tool Palette via the JavaScript API (see image below).

 

How should I use Perfect Preview?
Well, that's part of the beauty of it. If you want to have external resources available to you from within AutoCAD, then create a Hyperlinked object, then use Perfect Preview to easily view those items. I currently create special blocks that look like icons which I hyperlink to documents, images, etc.

 

But creating hyperlinks is slow...
Yes, This is problem #1 with hyperlinks and I hope to be creating some tool to help fix this in the future!

 

Try Perfect Preview for yourself!

I have attached the Lisp file "PERFECTPREVIEW.LSP"

 

Screenshot:

image.png

 

Live in Action:

 

Hope this helps somebody!

Best,

~DD

Reply
566 Views
11 Replies
Replies (11)

pendean
Community Legend
Community Legend

Slow.gif

CodeDing
Advisor
Advisor

There's currently 8 categories that can be populated + an "UNKNOWN" as a catch-all.

image.png

 

Some more screenshots:

c1.JPG

c2.JPG

c3.JPG

0 Likes

ВeekeeCZ
Consultant
Consultant

That's a nice idea. Thanks for sharing. 

Nicely elaborated code. Imho you could at least add a note to it that you are the author 🙂 

Edit: Ok, I see... I would expect that in the header.

 

CodeDing
Advisor
Advisor

A tool like this is especially useful when we create simple Lisp tools that find External Documents automatically. This allows us to easily and quickly create hyperlinks for the user and have an icon for them ready immediately showing information they were searching for.

 

Like this example,

I search an area using GIS coordinates to retrieve a particular type of document for that location. Then icons & hyperlinks are created automatically, allowing the user to have immediate access to external information, without ever leaving the AutoCAD environment.

 

Just a simple use case to get your creative juices flowing

 

 

Best,

~DD

0 Likes

DGCSCAD
Advocate
Advocate

Very nice! Yes, I agree about the underutilization.

 

I've been commiserating over using hyperlinks to customer spec PDFs on our drawings, which would speed up our current process. This (PerfectPreview) would be a great way to pull them into view without leaving AutoCad.

 

However, it doesn't want to show PDF's in vanilla 2018. No matter how wide I make the palette, it's not showing the PDF, or "controls inside PDF viewers". Everything else works great. I looked at the code to see if maybe having Acrobat Pro installed might be causing this behavior, but nothing stood out.

 

Still, very nice work, and I learned that you can use CSS inside Tool Palettes.

 

[Ed McMahon voice: "I did not know that." /Ed McMahon voice]

 

 

AutoCad 2018 (full)
Win 11 Pro

CodeDing
Advisor
Advisor

@DGCSCAD ,

 

Thanks for feedback! Yeah, older versions of Acad might be running different web/browser inside the Tool Palette. I don't have an older version to test on, but try this:

 

Go to the (PP_CreateTxtPDF ...) function...

 

Then, replace this line of code:

"<embed class=\"pdf\" type=\"application/pdf\" src=\"" link "#toolbar=1\">\n"

...for this line:

"<object class=\"pdf\" data= \"" link "#toolbar=1\">\n"

 

Update if that helps or not.

Best,

~DD

0 Likes

DGCSCAD
Advocate
Advocate

@CodeDing wrote:

@DGCSCAD ,

 

Thanks for feedback! Yeah, older versions of Acad might be running different web/browser inside the Tool Palette. I don't have an older version to test on, but try this:

 

Go to the (PP_CreateTxtPDF ...) function...

 

Then, replace this line of code:

 

"<embed class=\"pdf\" type=\"application/pdf\" src=\"" link "#toolbar=1\">\n"

 

...for this line:

 

"<object class=\"pdf\" data= \"" link "#toolbar=1\">\n"

 

 

Update if that helps or not.

Best,

~DD


No change in behavior.

AutoCad 2018 (full)
Win 11 Pro

CodeDing
Advisor
Advisor

@DGCSCAD ,

 

Last chance. Looks like this is the final boss of PDF embedding in HTML lol.

If this does not work, keep the Tool Palette open, then press F12, then go to the "Console" tab and show what it says.

 

          (strcat
            "<a class=\"pdf-label\" target=\"_blank\" title=\"" link "\" href=\"" link "\"><h4><i>" (strcat name ext) "</i></h4></a>\n"
            "<object class=\"pdf\" type=\"application/pdf\" data=\"" link "#toolbar=1\">\n"
            "  <embed class=\"pdf\" type=\"application/pdf\" src=\"" link "#toolbar=1\">\n"
            "    <iframe class=\"pdf\" src=\"" link "#toolbar=1\">\n"
            "      <p>Browser does not support PDF viewing.</p>\n"
            "    </iframe>\n"
            "  </embed>\n"
            "</object>\n"
          );strcat

 

0 Likes

DGCSCAD
Advocate
Advocate

I get a border, but still no PDF.

 

F12 shows:

PP_Screen.png

AutoCad 2018 (full)
Win 11 Pro
0 Likes

DGCSCAD
Advocate
Advocate

Console is showing this:

 

"Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources. SecurityError"

AutoCad 2018 (full)
Win 11 Pro

CodeDing
Advisor
Advisor

;; Displays hyperlink items in HTML Tool Palette within Acad.
;; Created by: Denon Deterding
;;----------------------------------------
;; v1 | 20241210 | Original public release
;; v2 | 20241216 | Updated (PP_CreateTxtPDF ...) HTML to support PDF in more browsers and
;;                 added ability to recognize & embed YouTube videos (multiple functions)
;;----------------------------------------