How read lisp variable (point) in vb.net ?

How read lisp variable (point) in vb.net ?

Anonymous
Not applicable
767 Views
2 Replies
Message 1 of 3

How read lisp variable (point) in vb.net ?

Anonymous
Not applicable

Hello there. I found below lisp in internet. What is does is , It will find the bounding box of selected object and it put those data in minpoint and maxpoint variable and show them in command prompt.

with this format ( x1 y1 z1 , x2  y2 z2)

I believe , right term is " Buffer ".

 

Now my question is , how can I can read  X,Y

coordinates of those point in  vb net.

 

Or at least write them in a file.

I nice example would be helpful because I am not a pro.

Thanks for all help.

 

;;=============================

(defun C:minmax()
(setq BarEname (cdr (car (entget (car (entsel "\nselect your object "))))))
(ucs-bbox BarEname)
)

 

;; can be used with vla-transformby to
;; transform objects from the UCS to the WCS
(defun UCS2WCSMatrix ()
(vlax-tmatrix
  (append
    (mapcar '(lambda (vector origin) (append (trans vector 1 0 t) (list origin)) )
              (list '(1 0 0) '(0 1 0) '(0 0 1))
              (trans '(0 0 0) 0 1) )
    (list '(0 0 0 1))
    )
  )
)

;; transform objects from the WCS to the UCS
(defun WCS2UCSMatrix ()
  (vlax-tmatrix
    (append
      (mapcar '(lambda (vector origin)(append (trans vector 0 1 t) (list origin)))
               (list '(1 0 0) '(0 1 0) '(0 0 1))
               (trans '(0 0 0) 1 0)
               )
      (list '(0 0 0 1))
      )
    )
)

;; Returns the UCS coordinates of the object bounding box about UCS
;; Argument
;;   obj : a graphical object (ename or vla-object)
;; Return
;;   a list of left lower point and right upper point UCS coordinates
(defun ucs-bbox (obj / minpoint maxpoint)
  (vl-load-com)
  (and (= (type obj) 'ENAME)
       (setq obj (vlax-ename->vla-object obj))
       )
  (vla-TransformBy obj (UCS2WCSMatrix))
  (vla-getboundingbox obj 'minpoint 'maxpoint)
  (vla-TransformBy obj (WCS2UCSMatrix))
  (list (vlax-safearray->list minpoint)
        (vlax-safearray->list maxpoint)
        )
)

0 Likes
768 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

It would probably be eaiser to use.

 

Entity.GeometricExtents.MinPoint
Entity.GeometricExtents.MaxPoint

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hello Jeffrey.

Thanks for Reply.

 "Entity" has been picked in lisp environment by user , and that lisp belongs to a third party application on top of autocad.

How can I access that entity. in dot net  SelectLast and SelectPrevious didn't help.that is how I comeup to find that coordination I need in lisp and then pass it to vb.  Becuase in Dot net select  will picks the last Autocad objects. Not the last object created by that third party program.  Any Suggestion ? Thanks.

 

0 Likes