use javascript from html to draw objects in autocad

use javascript from html to draw objects in autocad

Anonymous
Not applicable
2,938 Views
7 Replies
Message 1 of 8

use javascript from html to draw objects in autocad

Anonymous
Not applicable

Hello,

 

With AutoCAD 2016 or/and the A360? Can we now use javascript from html to draw objects in the active autocad DWG?

 

If yes. Please provide a simple example.

 

Thank You.

 

Kevin.

 

 

 

 

0 Likes
2,939 Views
7 Replies
Replies (7)
Message 2 of 8

StormyC
Advocate
Advocate

Not sure if this is what your looking for however, here is a link to the javascript reference guide for autocad which shows you how to run javascript code thats hosted within an html page.

 

http://app.autocad360.com/jsapi/v2/docs/JavaScript_Reference_Guide.html

 

And a link to a document using Jawin - no idea if this will work in later releases of autocad though.

 

http://www.east.utcluj.ro/mb/mep/antal/Articole/acadjava_2010.pdf

 

http://jawinproject.sourceforge.net/jawin.html - link to Jawin

 

 

 

 

0 Likes
Message 3 of 8

StormyC
Advocate
Advocate
Missed this link which is the start of a series about JS and AutoCAD .. hope it all helps...

http://through-the-interface.typepad.com/through_the_interface/2013/03/zooming-to-an-autocad-entity-...
0 Likes
Message 4 of 8

Anonymous
Not applicable

: (  

not what I was looking for ... Kean's example is loaded within AutoCAD with the WEBLOAD command.

I was hoping to control AutoCAD from outside by using javascript.

Looks like it is not possible.

 

But thanks for the reply.

 

0 Likes
Message 5 of 8

Anonymous
Not applicable

Kean responded to an email I sent him, in the email Kean indicated that this is possible.

 

Now I need help trying to get it to work...

 

I started acad 2015 and tried the following

(draw a circle in AutoCAD, from HTML, opened HTML in IE, clicked on button) 

.. nothing happened.. no error message ... nada .. nothing.

What have I missed?

 

Thanks for reading.

 

Kevin.

 

<html>
  <head>
     <script
      type="text/javascript"
      src="http://app.autocad360.com/jsapi/v2/Autodesk.AutoCAD.js">
    </script>
    <script type="text/javascript">
       function DrawCircle() {
            Acad.Editor.executeCommand(
              '_.CIRCLE 0,0,0 10.0'
            );
      }
     </script>
   </head>
  <body>
    <input
      type='button'
      onclick='DrawCircle()'
    >
  </body>
</html>

 

0 Likes
Message 6 of 8

StormyC
Advocate
Advocate

Your code doesn't pick up a reference to AutoCAD or create a new instance so without using WEBLOAD it will not 'do' anything...

 

I dont know how to create a ref or pick up an active instance, however that information must be burried in one of the links above... (Hopefully)

 

Oh, if you do manage to get somthing working let me know - would be very interested.

0 Likes
Message 7 of 8

StormyC
Advocate
Advocate
Although I understand that you don't wish to WEBLOAD the js, using WEBLOAD produced no effect also because there isn't a way to get the code to run.

0 Likes
Message 8 of 8

Anonymous
Not applicable

: (     Looks like its not possible yet.

Let's leave this thread as "without solution" to get an answer from Autodesk.

 

0 Likes