Jump to content
Sign in to follow this  
Anushka

showhtmlmodalwindow -> Block or Browser

Recommended Posts

Anushka

Hello everyone, it is possible to update a text in the showhtmlmodalwindow or browser
so that when the entity undergoes changes the value is updated. Something like a reactor.

Example: I insert a block, the coordinate of that block will be written to my browser. (picture 1)
If I move this block the text will be updated automatically.

capture-20190620-143907.png

Share this post


Link to post
Share on other sites
Roy_043

Can you explain why you want to achieve this?

  • Like 1

Share this post


Link to post
Share on other sites
Anushka

Thank you @Roy_043
Simple I would like to insert a marker in my drawing this marker will open google streetview. If I move my marker I would like the page to refresh and update to the correct location.

;;----------------------------------------------------------------------------------;;
(defun Openlinkinchrome (link / sa)
  (and (strcat link)
       (setq sa (vlax-get-or-create-object "Shell.Application"))
       (null (vlax-invoke sa 'shellexecute "chrome.exe" link))
       (vlax-release-object sa)
      )
 )
;;----------------------------------------------------------------------------------;;

(defun c:Demo (/ pnt)
  (if (not (tblsearch "BLOCK" "highlighter"))
    (alert "OOoops! Block does not exist in drawing!")
    (progn
      (command "_.Insert" "highlighter" pause 1 1 0)
      (setq pnt (utmgeo (getvar "lastpoint") 6378160.0  298.25 18 "N"))
      (setq a (rtos (cadr pnt) 2 8) b (rtos (car pnt ) 2 8))
      (Openlinkinchrome (strcat "https://www.google.com/maps?ie=UTF8&layer=c&cbll=" a "," b "&cbp=1,0,,0,5&z=16"))
      )
    )
  )
;;------------------------------------END-------------------------------------------;;

 

utmgeo.VLX

  • Thanks 1

Share this post


Link to post
Share on other sites
Roy_043

Your biggest problem may be communicating with Chrome. When you run the Openlinkinchrome function multiple times are URLs opened in the same window? Or can you set a preference to accomplish this?

  • Like 1

Share this post


Link to post
Share on other sites
Anushka
17 hours ago, Roy_043 said:

Your biggest problem may be communicating with Chrome. When you run the Openlinkinchrome function multiple times are URLs opened in the same window? Or can you set a preference to accomplish this?

 

No, they always open in a new window !!

I have no idea how to achieve this. lol

 

Share this post


Link to post
Share on other sites
Roy_043

Using Internet Explorer for this type of automation would be easier as you can then use ActiveX.

  • Like 1

Share this post


Link to post
Share on other sites
Anushka

@Roy_043 That's a possibility! but how to do this?

Share this post


Link to post
Share on other sites
Roy_043
Posted (edited)

Try the code below.

Note 1:

I haven't fully tested the code. I cannot run utmgeo.VLX as I use BricsCAD instead of AutoCAD. Also I would probably need a sample dwg with the highlighter block inserted in a 'feasible' location. If you have the source of the VLX and such a dwg please post them.

Note 2:

The highlighter block has to already be inserted before calling the SvUpdate command.

(vl-load-com)

(defun KGA_Sys_Apply (expr varLst / ret)
  (if (not (vl-catch-all-error-p (setq ret (vl-catch-all-apply expr varLst))))
    ret
  )
)

(defun KGA_Sys_ApplyAlt (expr varLst)
  (not (vl-catch-all-error-p (vl-catch-all-apply expr varLst)))
)

; (SvUpdate_Browser "https://www.cadtutor.net/forum/forum/15-autolisp-visual-lisp-amp-dcl/")
(defun SvUpdate_Browser (url)
  (if
    (or
      (and
        *SvUpdate_browser*
        (KGA_Sys_ApplyAlt 'vlax-get-property (list *SvUpdate_browser* 'visible)) ; Check if object is still available.
        (princ "\nUpdating StreetView in browser ")
      )
      (and
        (princ "\nStarting StreetView in browser. Please wait... ")
        (or
          (setq *SvUpdate_browser* (KGA_Sys_Apply 'vlax-get-or-create-object '("internetexplorer.application")))
          (prompt "\nError: Internet Explorer cannot be started ")
        )
        (progn
          (setvar 'cmdecho 0)
          (command "_.delay" 2000)
          (setvar 'cmdecho 1)
        )
      )
    )
    (progn
      (vlax-put-property *SvUpdate_browser* 'visible :vlax-true)
      (vlax-invoke-method *SvUpdate_browser* 'navigate url)
    )
  )
)

(defun SvUpdate_CallBackModified (obj rea lst / pt)
  (if
    (and
      (vlax-read-enabled-p obj)
      (not (equal (vlr-data rea) (setq pt (vlax-get obj 'insertionpoint)) 1e-8)) ; Perhaps higher fuzz?
    )
    (progn
      ; (print "SvUpdate_CallBackModified")
      (vlr-data-set rea pt)
      (SvUpdate_Move pt)
    )
  )
)

(defun SvUpdate_Move (pt)
  (setq pt (utmgeo pt 6378160.0  298.25 18 "N"))
  (SvUpdate_Browser
    (strcat
      "https://www.google.com/maps?ie=UTF8&layer=c&cbll="
      (rtos (cadr pt) 2 8)
      ","
      (rtos (car pt) 2 8)
      "&cbp=1,0,,0,5&z=16"
    )
  )
)

(defun c:SvUpdate ( / obj pt ss)
  (if
    (and
      (or
        (setq ss (ssget "_X" '((2 . "highlighter"))))
        (prompt "\nError: 'highlighter' block not found ")
      )
      (or
        (= 1 (sslength ss))
        (prompt "\nError: more than 1 'highlighter' block found ")
      )
    )
    (progn
      (if *SvUpdate_objectReactor*
        (vlr-remove *SvUpdate_objectReactor*)
      )
      (setq *SvUpdate_objectReactor*
        (vlr-object-reactor
          (list (setq obj (vlax-ename->vla-object (ssname ss 0))))
          (setq pt (vlax-get obj 'insertionpoint)) ; Reactor data.
          '(
            (:vlr-modified . SvUpdate_CallBackModified)
          )
        )
      )
      (SvUpdate_Move pt)
    )
  )
  (princ)
)

 

Edited by Roy_043
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Anushka

@Roy_043 That was perfect !!! I am sending an example of dwg and UTMGEO subfunction.

Thank you very much! You were incredible !!!

Note: if I change the angle of the arrow I can change the angle of the streetview.

Sample.dwg utmgeo.LSP

Share this post


Link to post
Share on other sites
Roy_043
Posted (edited)

Thanks for those files. It works on my machine as well.😀

 

Here is a new version of the code. The angle of the block is now translated to the heading in SV.

The code assumes a (static) block containing an arrow pointing east. 

(vl-load-com)

(defun KGA_Math_LimitAngleRange (ang)
  (rem (+ (rem ang (+ pi pi)) pi pi) (+ pi pi))
)

(defun KGA_Math_Rad_To_Dgr (rad)
  (* (/ rad pi) 180.0)
)

(defun KGA_Sys_Apply (expr varLst / ret)
  (if (not (vl-catch-all-error-p (setq ret (vl-catch-all-apply expr varLst))))
    ret
  )
)

(defun KGA_Sys_ApplyAlt (expr varLst)
  (not (vl-catch-all-error-p (vl-catch-all-apply expr varLst)))
)

; 20190626: Revised.
; 20190625
(defun SvUpdate_CallBackModified (obj rea lst / dat)
  (if
    (and
      (vlax-read-enabled-p obj)
      (setq dat
        (list
          (vlax-get obj 'insertionpoint)
          (vlax-get obj 'rotation)
        )
      )
      (not (equal dat (vlr-data rea) 1e-8)) ; Perhaps higher fuzz?
    )
    (progn
      ; (print "SvUpdate_CallBackModified")
      (vlr-data-set rea dat)
      (SvUpdate_ChangeView (car dat) (cadr dat))
    )
  )
)

; 20190626: Revised.
; 20190626: Renamed.
; 20190625
; https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45
(defun SvUpdate_ChangeView (pt ang)
  (setq pt (utmgeo pt 6378160.0  298.25 18 "N"))
  (setq ang (KGA_Math_Rad_To_Dgr (KGA_Math_LimitAngleRange (- (* 0.5 pi) ang))))
  (princ "\nPlease wait... ")
  (SvUpdate_Navigate
    (strcat
      "https://www.google.com/maps/@?api=1"
      "&map_action=" "pano"
      "&viewpoint="  (rtos (cadr pt) 2 8) "," (rtos (car pt) 2 8)
      "&heading="    (rtos ang 2 0)
    )
  )
)

; 20190626: Removed some prompts.
; 20190626: Renamed.
; 20190625
; (SvUpdate_Navigate "https://www.cadtutor.net/forum/forum/15-autolisp-visual-lisp-amp-dcl/")
(defun SvUpdate_Navigate (url)
  (if
    (or
      (and
        *SvUpdate_browser*
        (KGA_Sys_ApplyAlt 'vlax-get-property (list *SvUpdate_browser* 'visible)) ; Check if object is still available.
      )
      (and
        (or
          (setq *SvUpdate_browser* (KGA_Sys_Apply 'vlax-get-or-create-object '("internetexplorer.application")))
          (prompt "\nError: Internet Explorer cannot be started ")
        )
        (progn
          (setvar 'cmdecho 0)
          (command "_.delay" 2000)
          (setvar 'cmdecho 1)
        )
      )
    )
    (progn
      (vlax-put-property *SvUpdate_browser* 'visible :vlax-true)
      (vlax-invoke-method *SvUpdate_browser* 'navigate url)
    )
  )
)

; 20190626: Revised.
; 20190625
; The selected (static) block should contain an arrow pointing east.
(defun c:SvUpdate ( / dat enm obj)
  (if
    (and
      (setq enm (car (entsel)))
      (setq obj (vlax-ename->vla-object enm))
      (or
        (= "AcDbBlockReference" (vla-get-objectname obj))
        (prompt "\nError: this is not a block reference ")
      )
    )
    (progn
      (if *SvUpdate_objectReactor*
        (vlr-remove *SvUpdate_objectReactor*)
      )
      (setq *SvUpdate_objectReactor*
        (vlr-object-reactor
          (list obj)
          (setq dat ; Reactor data.
            (list
              (vlax-get obj 'insertionpoint)
              (vlax-get obj 'rotation)
            )
          )
          '(
            (:vlr-modified . SvUpdate_CallBackModified)
          )
        )
      )
      (SvUpdate_ChangeView (car dat) (cadr dat))
    )
  )
  (princ)
)

 

Sample_new.dwg

Edited by Roy_043
  • Thanks 1

Share this post


Link to post
Share on other sites
Anushka

This works great! @Roy_043
Thank you very much!
simply incredible !!!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...