Perfect Preview - Hyperlinks are Underrated!

Perfect Preview - Hyperlinks are Underrated!

CodeDing
Advisor Advisor
1,860 Views
17 Replies
Message 1 of 18

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

Accepted solutions (1)
1,861 Views
17 Replies
Replies (17)
Message 2 of 18

pendean
Community Legend
Community Legend

Slow.gif

Message 3 of 18

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
Message 4 of 18

В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.

 

Message 5 of 18

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
Message 6 of 18

DGCSCAD
Collaborator
Collaborator

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
Message 7 of 18

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
Message 8 of 18

DGCSCAD
Collaborator
Collaborator

@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
Message 9 of 18

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
Message 10 of 18

DGCSCAD
Collaborator
Collaborator

I get a border, but still no PDF.

 

F12 shows:

PP_Screen.png

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 11 of 18

DGCSCAD
Collaborator
Collaborator

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
Message 12 of 18

CodeDing
Advisor
Advisor
Accepted solution

;; 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)
;;----------------------------------------

Message 13 of 18

kmingH39H6
Contributor
Contributor

I got a question on how your MonRec command works? Do you have like a file that stores the locations of your docs with their paths that it calls to or something? 

 

Really like the other stuff you have made. Already added your Perfect Preview to our companies custom lisps and showed it off to the guys who like hyperlinking everything and they seemed to think it will be super beneficial.

 

Also think your Project Tracker Palette is really cool. We have a very similar setup as far as project numbers and field crew goes and I can't imagine all the work it would take to set all that up. Honestly with the amount of people running with Trimble equipment I think you could easily turn it into a Plug and Play setup that you sell to companies. 

Message 14 of 18

CodeDing
Advisor
Advisor

@kmingH39H6 ,

 

Thank you for the feedback!

The MONREC command I won't be posting since it has a lot of custom functions, files, paths, etc. But in essence, it does this:

- Retrieves bounding box from user

- finds county (or counties) within that bounding box [I need the county (counties) because, although the MONREC files are online, I have files of each county that contains JSON data locating the location(s) of the MONREC files].

- retrieves county file (saved on our network storage, as JSON file w/ locations and other data about monument record)

- searches county file for monument record & location

- for each monument record found, retrieves/inserts/creates MONREC block

- foreach block, determines how many monument records and determines where to place them, and inserts custom block which ultimately gets hyperlinked

 

I hope PERFECT PREVIEW treats your team well! If you have any issues, just post here so we can try to get them solved.

 

Best,

~DD

0 Likes
Message 15 of 18

kmingH39H6
Contributor
Contributor

No worries, I assumed you would have something setup like that based on the Project Palette workflow so the process alone is fine. 

 

I will definitely start working on creating our own version since this sounds like it'd be great. Thank you.

0 Likes
Message 16 of 18

BlackBox_
Advisor
Advisor

PP is pretty CAD-azz. 🍻 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

Message 17 of 18

kmingH39H6
Contributor
Contributor

Got another quick question after talking it over with a few others. How do you store the geolocations for the actual files? Is that something you have to do when you are pulling it from whatever service you use? 

0 Likes
Message 18 of 18

CodeDing
Advisor
Advisor

@kmingH39H6 ,

DM'd you

0 Likes