Author Topic: Adding a web-page as a document tab in AutoCAD 2016  (Read 2401 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
Adding a web-page as a document tab in AutoCAD 2016
« on: January 28, 2016, 09:52:12 AM »
Here is post from Kean's blog.(Thanks again Kean I enjoy reading it.) Adding a web-page as a document tab in AutoCAD 2015 using .NET.
In 2016 when I run this or any add any webpage, it will sometimes cause 2 more document tabs to show up where closing one of them first will cause a crash. Other times it will not at tabs but will add them to dropdown list(one at far right clicking down arrows) and again will cause a crash on closing tab.

I do not have 2015 to see if there is a difference but has anyone noticed  difference between 2015 and 2016?

 

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #1 on: January 28, 2016, 05:44:50 PM »
OH, I want to play!

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #2 on: January 28, 2016, 06:49:49 PM »
Also I am unable to resize modal windows in 2016 with persistSizeAndPosition set to false.

Displaying Modal and Modeless HTML Pages in AutoCAD



kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #4 on: January 28, 2016, 07:05:50 PM »
Hi Jeff,
I recall thinking at the time that this would be as useful as teats on a bull.

Care to share your goals with it  ... other than geekiness.

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #5 on: January 28, 2016, 07:29:44 PM »
this kind of works, but you have to close the tab before exiting, or acad crashes

Code: [Select]
public class WebDoc
    {
        class HeadClient : WebClient
        {
            protected override WebRequest GetWebRequest(Uri address)
            {
                var req = base.GetWebRequest(address);
                if (req.Method == "GET")
                    req.Method = "HEAD";
                return req;
            }
        }
        public class Commands
        {
            private static bool PageExists(string url)
            {
                Uri uriResult;
                if (!Uri.TryCreate(url, UriKind.Absolute, out uriResult) || uriResult.Scheme != Uri.UriSchemeHttp)
                    return false;
                try
                {
                    using (var client = new HeadClient())
                    {
                        client.DownloadString(url);
                    }
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }
            [CommandMethod("Doit")]
            public static void OpenPage()
            {
                const string url = "http://www.theswamp.org/";
                if (PageExists(url))
                {
                    Application.DocumentWindowCollection.AddDocumentWindow("TheSwamp", new System.Uri(url));
                }
                else
                {
                    var doc = Application.DocumentManager.MdiActiveDocument;
                    var ed = doc.Editor;
                    ed.WriteMessage("\nCould not load url: \"{0}\".", url);
                }
            }
        }
    }

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #6 on: January 28, 2016, 07:37:40 PM »
Hi Jeff,
I recall thinking at the time that this would be as useful as teats on a bull.

Care to share your goals with it  ... other than geekiness.

Regards,

Not responding for Jeff but I've tinkered with this sort of thing using the web control in .net to create dialogs. I like the idea of using html/css to create dialogs and I guess WPF was designed just for this.
I think html/css with javascript is a lot easier IMO than WPF but that's just me :)
(aside: For some reason MS always has to make their own version of something that already works and is a standard??)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #7 on: January 28, 2016, 08:02:00 PM »
Hi daniel,

I can understand using the .net controls but not using a doc page built into AutoCAD.

What happens when a user tries to use the page without an internet connection to honor the href live links for js, bootstrap, jquery etc ?

The fact that it's broken in 2016 without anyone noticing is an indicator of the attention AutoDesk is paying to the technology and a measure of how many developers/clients are using the feature.


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #8 on: January 28, 2016, 08:19:02 PM »

I suppose we could use a fall-back to a local source in case the CDN fails.

something like
Code: [Select]
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>if (typeof jQuery === 'undefined') {
  document.write(unescape('%3Cscript%20src%3D%22/path/to/your/scripts/jquery-2.1.4.min.js%22%3E%3C/script%3E'));
}
</script>
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #9 on: January 28, 2016, 08:34:26 PM »
I like the idea of being able to add your own document + tab, it adds a new workspace that’s not intrusive to the drawing editor, and gives more room to work over a palette or dialog.

I hadn’t seen this before, and as soon as I did, a few ideas popped into my head.  Bummer, in .NET it seems limited to DocumentWindow(URL) and WPFDocumentWindow as I’m not a fan of either.  I see AcApDocWindow in Arx, that may give more control


If it wasn’t broke lol  :|

BlackBox

  • King Gator
  • Posts: 3770
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #10 on: January 29, 2016, 10:07:08 AM »
While working at my former employer (large international design firm), I ended up developing a WPF Browser app, which sat on the server and consolidated various pertinent design resources.

Having that 'resource' (WPF) load as a Document tab within CAD in lieu of a web browser *might* be useful - one day - but nowhere as useful as having it (the resource/content) displayed in a window unto itself, either side-by-side CAD, on a second monitor, etc.

Unless Autodesk is going to implement 'tear away' Document windows, each residing in their own process, that can float/minimize/maximize outside of the main application window (like Chrome) - which implicitly requires AutoCAD products to be thread-safe - methinks this is a fruitless API. :-(
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Adding a web-page as a document tab in AutoCAD 2016
« Reply #11 on: January 29, 2016, 09:48:12 PM »
Been on the road all day, but initial plan was to automate and customize some things with clients that are working on same projects, but see too many things not working and not gonna fool with it.
Here is sample of headache if you used this page the combo box does work in AutoCAD browser
http://hpadwebapplication.azurewebsites.net/WireSizingData/WireSizeCalculator