OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: juan on March 23, 2012, 03:56:22 AM

Title: html
Post by: juan on March 23, 2012, 03:56:22 AM
translation google EspaƱol Ingles

Hello I am new to OpenDCL and I want to thank you for this program,
my question is if I can from a html page to a command to the drawing. this is a draw button html for example the following command

(command "_line" "0,0,0" 10,10,20 "" "" ")

A greeting and thanks
Title: Re: html
Post by: Fred Tomke on March 23, 2012, 03:56:18 PM
Hm, what did you want to tell us?
Fred
Title: Re: html
Post by: roy_043 on March 24, 2012, 03:23:11 AM
I think the OP wants to know if you can use a button on a HTML page to trigger a lisp action. If this is possible it would be a strange way to use ODCL.
Title: Re: html
Post by: Danner on March 26, 2012, 08:55:21 AM
It's way beyond me, but a chap called Techjunkie80 has attempted this.  See the thread below:

http://www.opendcl.com/forum/index.php?topic=1603.0 (http://www.opendcl.com/forum/index.php?topic=1603.0)
Title: Re: html
Post by: juan on March 26, 2012, 08:55:45 AM
yes I want that, I would like to insert blocks from a html page, is it possible?
Title: Re: html
Post by: roy_043 on March 27, 2012, 02:10:41 AM
Quote from: juan on March 26, 2012, 08:55:45 AM
yes I want that, I would like to insert blocks from a html page, is it possible?
But in your original post you mention the line command?
Title: Re: html
Post by: juan on March 27, 2012, 04:06:57 AM
yes, I wanted to give an example, the project I want to do is insert blocks in a database, execute it with pages. asp
Title: Re: html
Post by: Danner on March 27, 2012, 04:30:44 AM
Yes, sounds very do-able in my opinion. 

1. Press the  relevant button on the HTML page.
2. The Html Control navigates to a dedicated page which triggers the control's NavigationComplete event.
3. The NavigationComplete event triggers your lisp code which determines the desired block name and then inserts the actual block itself into your drawing from an ftp server.



Title: Re: html
Post by: juan on March 27, 2012, 06:20:40 AM
Thanks I will try and tell you
Title: Re: html
Post by: Danner on March 27, 2012, 06:34:45 AM
Yes please. Step 3 will be the fun bit.
Title: Re: html
Post by: juan on March 29, 2012, 01:09:27 AM
Sorry but I can not do it, try it with javascript

<script language="javascript" type="text/javascript">
function Aplicar()
{
insertblock23();
}
</script>


<script language="javascript" type="text/javascript">
function Aplicar()
{
insertblock23();
}
</script>


or

window.parent.location.href='insertblock23'

You can set an example?
Title: Re: html
Post by: Danner on March 29, 2012, 07:36:06 AM
I was thinking of avoiding javascript and doing it through lisp.  You would need to configure your website so when you click on the relevant "Insert Block" button on the web page it navigates to a particular webpage (with the same name as your block) and triggers the OnNavigationComplete event for the Html control.

You would need a naming convention for your blocks/web pages such as "Juan_Block1" etc.  The below is untested and may not be how you want to do it, but hopefully it gives you an idea of the approach I was thinking of.

Code (autolisp) Select
;;on navigation complete event for the html control
(defun c:HTMLTest_Form1_Html1_OnNavigationComplete URL / WebPageName BlockName)
 ;get the location of new page
 (setq WebPageName (dcl_Html_GetLocationName HTMLTest_Form1_Html1))
 ;check the location name corresponds to a block name
 (if (wcmatch (strcase WebPageName) "JUAN_*")
   (progn;then
     ;get the block name and path
     (setq BlockName (strcat "http://www.YourWebsite.com/Blocks/" WebPageName ".dwg"))
     ;now insert the block into the drawing
     (INSERT_REMOTE_FILE BlockName)
     ;navigate back to the original web page
     (dcl_Html_Navigate HTMLTest_Form1_Html1 "www.YourWebsite.com[url=http://][/url][url=http://][/url]")
   );endprogn
 );endif
);endfun

;;subroutine to download then insert a block from a ftp server
(defun INSERT_REMOTE_FILE (RemoteFile / TempInternetFile NewFile sym *acad* *doc* *util*)
 (vl-load-com)
 (setq *acad* (vlax-get-acad-object))
 (setq *doc* (vla-get-activedocument *acad*))
 (setq *util* (vla-get-utility *doc*))
 (vl-catch-all-apply
   'vla-getremotefile
    (list *util* RemoteFile 'TempInternetFile actrue)
 )
 (if TempInternetFile
   (progn;then
     ;Rename the temporary internet file as dwg
     (setq NewFile (strcat (vl-filename-directory TempInternetFile) "\\" (vl-filename-base RemoteFile) ".dwg"))
     (vl-file-rename TempInternetFile NewFile)
   );endprogn
 );endif
 (if (findfile NewFile)
   (progn;then
     ;insert the file
     (command "_.insert" NewFile "_scale" 1 pause "")
     ;then delete the old File if you wish
     (vl-file-delete NewFile)
   );endprogn
 );endif
);endfun
Title: Re: html
Post by: BazzaCAD on March 29, 2012, 09:57:29 AM
Great looking code Danner, I'll have to try it out myself.
I edited your code with the line #9 change & removed the last post to avoid confusion.

thx for the contribution. If this works it should go into "Show & Tell"
Title: Re: html
Post by: Danner on March 30, 2012, 01:26:47 AM
Thanks Barry, very much appreciated.

There is probably a bug or three in there to be ironed out.  I want to develop it and test it further when I get a chance and then possibly put it in "Show and Tell" in due course (assuming it actually works!).