HTML Control, send commands back to autocad?

Started by techjunkie80, March 20, 2011, 05:45:03 AM

Previous topic - Next topic

techjunkie80

Okay, so I've figured out a fairly easy way of sending commands from autocad directly to an html interface by changing the url to something like
javascript:my_command()
however I'm not sure how I'd go about calling an autocad command from javascript on the html page.

For anyone else attempting this the best method I've got so far is to send a command to the window via the syntax above and then use the html page's title attr to communicate back with autocad, basically
1. autocad sends command to html window via the syntax above
2. html window sets title to "received"
3. autocad loops waiting for the title to change to something other than "received", e.g. "done" or command line code to run
4. autocad sends a "javascript:recieved()" message after it detects the above change
5. html sets window title back to "waiting"

but this won't allow me to initiate an action by a user clicking on a button the html page(only works if autocad initiates the communication), is there a way I can setup an event handler to detect changes to the title field or some ActiveX snippet that would allow the javascript -> autocad communication?

Thanks.

owenwengerd

Please identify what you mean by "html interface" and "html window". Perhaps some sample code would help explain what you're trying to do.
Owen Wengerd (Outside The Box) / ManuSoft

techjunkie80

#2
Quote from: owenwengerd on March 20, 2011, 09:10:19 AM
Please identify what you mean by "html interface" and "html window". Perhaps some sample code would help explain what you're trying to do.
The OpenDCL HTML object. Basically I want to click an html <button> in the html page of the OpenDCL HTML object and have it run an autocad command.

<html><body>
<button>Draw Line</button>
</body></html>

and when I click Draw Line (on the html page inside the OpenDCL HTML object) it will draw a line in autocad.

I can access the html page of the OpenDCL HTML object by altering the url to a 'javascript:' url, but I need to do the reverse and affect AutoCAD using the html page of the OpenDCL HTML object.

owenwengerd

Try triggering your command from within the OnNavigationComplete handler.  You could reload the page to trigger it on demand.
Owen Wengerd (Outside The Box) / ManuSoft

techjunkie80

Quote from: owenwengerd on March 20, 2011, 01:56:24 PM
Try triggering your command from within the OnNavigationComplete handler.  You could reload the page to trigger it on demand.
The OnNavigationComplete handler only appears to fire when the page has finished loading after the (dcl_Html_Navigate ) function, forcing a page refresh using javascript or manually refreshing via F5 on the html page itself doesn't seem to fire the handler.

I'm afraid my only option left is to figure out an activex way to send the commands from javascript to autocad.

Thanks for the suggestions though ;)

owenwengerd

Hmm, in that case, I would try using the Microsoft Web Browser ActiveX control instead of the built in HTML control. That one should expose a lot more events, one of which would surely work for this purpose.
Owen Wengerd (Outside The Box) / ManuSoft