Jump to content
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 2

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
Posted (edited)

@ Roy_043  Isso foi perfeito !!! Estou enviando um exemplo de subfunção dwg e UTMGEO.

Muito obrigado! Você foi incrível !!!

Nota: se eu mudar o ângulo da seta, posso mudar o ângulo da streetview.

Sample.dwg

Edited by Anushka

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
mstg007

Guys, This is pretty incredible stuff. I was testing on your drawings and everything works smoothly. I went to start a new drawing and set my geolocation to another state, Then inserted the hightlighter block and ran the routine. As the browser opens to street view, it shows blank, But it seems to work (to me) only in the original location of the dwg.

Am I doing something different?

Share this post


Link to post
Share on other sites
Anushka
Posted (edited)
5 hours ago, mstg007 said:

Pessoal, isso é uma coisa incrível. Eu estava testando seus desenhos e tudo funciona bem. Fui iniciar um novo desenho e configurar minha localização geográfica para outro estado, depois inseri o bloco do hightlighter e executei a rotina. Quando o navegador abre a vista da rua, ele mostra em branco, mas parece funcionar (para mim) apenas no local original do dwg.

Eu estou fazendo algo diferente?

 

did you change the red for your zone?

 

(setq pt (utmgeo pt 6378160.0 298.25 18 "N"))

 

Really @Roy_043 It was perfect on this show !!!

Edited by Anushka

Share this post


Link to post
Share on other sites
mstg007

Below are the google address. I seem to only get a blank view within the browser when I switch the 18 to 16 as you mentioned.

 

https://www.google.com/maps/@5.1742203,-77.1325941,0a,90y,90h,90t/data=!3m1!1e1
(With Geoloation Set to State Plane Coordinate Ohio South (UTM 16)


https://www.google.com/maps/@39.9135077,-87.1481694,0a,90y,90h,90t/data=!3m1!1e1
This was on the Sample Drawing, (but I kept the 16 instead of the 18).


https://www.google.com/maps/@39.9135209,-75.1481514,3a,90y,90h,90t/data=!3m6!1e1!3m4!1s4itrl52xF6rnpc_OsUg2NA!2e0!7i16384!8i8192
This was on the Sample Drawing, (Moved the 16 Back to 18). works.

Share this post


Link to post
Share on other sites
mstg007

Just curious,

 

Quote

(setq pt (utmgeo pt 6378160.0 298.25 18 "N"))

What and how can you configure the 6378160.0 ? Does this give a window for an area?

Share this post


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

@mstg007

You have PM'd me regarding this topic. Sadly I do not know how the utmgeo function works or which parameters to use for Indiana.

Edited by Roy_043

Share this post


Link to post
Share on other sites
mstg007

Thank you for letting me know. I appreciate it!

Share this post


Link to post
Share on other sites
mstg007

Is there a away to replace the block to a leader by any chance. So I would guess it could prompt to select a leader that is drawn, and then act like it does currently with the block?

I do not think I am pulling the correct variable.

command: Select object: ; error: ActiveX Server returned the error: unknown name: "INSERTIONPOINT"

 

(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))
        (= "AcDbLeader" (vla-get-objectname obj))
;;        (prompt "\nError: this is not a block reference ")
        (prompt "\nError: this is not a Leader ")
      )
    )
    (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)
)

 

Share this post


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

A leader has coordinates, so you could use the first coordinate instead of the block's insertion point. But what property of the leader would you use for the rotation (the SV view direction)?

 

BTW: I assume you are indeed talking about a LEADER and not about an MLEADER.

Edited by Roy_043

Share this post


Link to post
Share on other sites
mstg007

When I dumped the properties for the leader, I get the following:

Is it possible to generate a rotation from the two coordinates of the leader?

Yup, you are correct about the L

52 minutes ago, Roy_043 said:

property of the leader would you use for the

eader and not a MLeader.

Command: (vlax-dump-object (vlax-ename->vla-object (car (entsel))) t)
Select object: ; IAcadLeader: AutoCAD Leader Interface
; Property values:
;   Annotation = nil
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000013f516558>
;   ArrowheadBlock = ""
;   ArrowheadSize = 0.18
;   ArrowheadType = 0
;   Coordinate = ...Indexed contents not shown...
;   Coordinates = (547.628 258.63 0.0 445.229 169.32 0.0)
;   DimensionLineColor = 0
;   DimensionLineWeight = -2
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000000ee96dd8>
;   EntityTransparency = "ByLayer"
;   Handle (RO) = "D465"
;   HasExtensionDictionary (RO) = -1
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 00000000a96238f8>
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal (RO) = (0.0 0.0 1.0)
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbLeader"
;   OwnerID (RO) = 43
;   PlotStyleName = "ByLayer"
;   ScaleFactor = 0.0
;   StyleName = "L80"
;   TextGap = 0.09
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 00000000a962e7b0>
;   Type = 2
;   VerticalTextPosition = 0
;   Visible = -1

 

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.


×
×
  • Create New...