html

Started by juan, March 23, 2012, 03:56:22 AM

Previous topic - Next topic

juan

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

Fred Tomke

Hm, what did you want to tell us?
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

roy_043

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.

Danner

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

juan

yes I want that, I would like to insert blocks from a html page, is it possible?

roy_043

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?

juan

yes, I wanted to give an example, the project I want to do is insert blocks in a database, execute it with pages. asp

Danner

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.




juan

Thanks I will try and tell you

Danner

Yes please. Step 3 will be the fun bit.

juan

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?

Danner

#11
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

BazzaCAD

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"
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Danner

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!).