Margusrebase Posted October 10, 2019 Posted October 10, 2019 Hi Could enyone write autolisp that annotate differences between two points! Br. Margus Quote
Lee Mac Posted October 10, 2019 Posted October 10, 2019 I would suggest representing the symbol using an attributed dynamic block, with the attributes populated with the coordinate differences - this way, the symbols may be manipulated as a single object and the attribute values may be extracted to an external file if required. Quote
CHLUCFENG Posted October 10, 2019 Posted October 10, 2019 Just for fun, I thought I would dig through the old toolbox. There are some basic tools that everyone should already have when new writing routines. I attempted to make this simple to understand, with many variables that are named as to their function, and comments within the code to follow what is going on. (defun c:2Pnts (/ pnt1 pnt2 deltaX deltaY deltaZ midpt dist vertex lineX lineY txtPntX txtPntY txthgt ) ;; First, start with the basic toolbox (setq pnt1 (getpoint "\nSelect first point: ")) (setq pnt2 (getpoint "\nselect second point: ")) (setq deltaX (- (car pnt2) (car pnt1))) ;this is the change in x coords (setq deltaY (- (cadr pnt2) (cadr pnt1))) ;this is the change in y coords (setq deltaZ (- (caddr pnt2) (caddr pnt1))) ;this is the change in z coords (setq midpt ;this will calculate the midpoint (list (+ (car pnt1) (* deltaX 0.5)) (+ (cadr pnt1) (* deltaY 0.5)) (+ (caddr pnt1) (* deltaZ 0.5)) ) ) (setq dist (sqrt (+ (expt deltaX 2) (expt deltaY 2) (expt deltaZ 2)))) ;this will calculate the distance between points ;; Second, we can print this information to the text screen ;;(textscr) ;this can be uncommented to make the text screen pop-up (princ "\nPoint 1 location: ") (princ pnt1) (princ "\nPoint 2 location: ") (princ pnt2) (princ (strcat "\nChange in x direction: " (rtos deltaX 2 1)) ) (princ (strcat "\nChange in y direction: " (rtos deltaY 2 1)) ) (princ (strcat "\nChange in z direction: " (rtos deltaZ 2 1)) ) (princ "\nMidpoint between points: ") (princ midpt) (princ (strcat "\nDistance between points: " (rtos dist 2 5)) ) (princ (strcat "\nDistance to midpoint: " (rtos (/ dist 2) 2 5)) ) (princ (strcat "\nAngle from point A to point B: " (rtos (angle pnt1 pnt2) 2 5) " radians or " (rtos (/ (* (angle pnt1 pnt2) 180.0) pi) 2 2) " degrees. " ) ) (princ (strcat "\nAngle from point B to point A: " (rtos (angle pnt2 pnt1) 2 5) " radians or " (rtos (/ (* (angle pnt2 pnt1) 180.0) pi) 2 2) " degrees. " ) ) ;; Now, we can look at what to do with all this information (vl-cmdf "_.point" pnt1) (vl-cmdf "_.point" pnt2) (setq vertex (list (car pnt1) (cadr pnt2))) ;vertex of symbol (setq lineX (list (+ (car pnt1) (/ deltaX 2)) (cadr pnt2))) ;endpoint of line in x-direction (setq lineY (list (car pnt1) (+ (cadr pnt2) (/ deltaY 2)))) ;endpoint of line in y-direction (setvar "osmode" 0) ;turn off snaps ;;make x/y lines (vl-cmdf "_.line" lineX vertex lineY "") ;;make arrow in x-direction (if (< (car pnt1) (car pnt2)) (vl-cmdf "_.line" ;first/fourth quadrant (list (- (car lineX) (abs (* 0.125 deltaX))) (+ (cadr lineX) (abs (* 0.0625 deltaY))) ) lineX (list (- (car lineX) (abs (* 0.125 deltaX))) (- (cadr lineX) (abs (* 0.0625 deltaY))) ) "" ) ;;else (vl-cmdf "_.line" ;second/third quadrant (list (+ (car lineX) (abs (* 0.125 deltaX))) (+ (cadr lineX) (abs (* 0.0625 deltaY))) ) lineX (list (+ (car lineX) (abs (* 0.125 deltaX))) (- (cadr lineX) (abs (* 0.0625 deltaY))) ) "" ) ) ;end if ;;make arrow in y-direction (if (< (cadr pnt1) (cadr pnt2)) (vl-cmdf "_.line" ;first/second quadrant (list (+ (car lineY) (abs (* 0.0625 deltaY))) (- (cadr lineY) (abs (* 0.125 deltaX))) ) lineY (list (- (car lineY) (abs (* 0.0625 deltaY))) (- (cadr lineY) (abs (* 0.125 deltaX))) ) "" ) ;;else (vl-cmdf "_.line" ;third/fourth quadrant (list (- (car lineY) (abs (* 0.0625 deltaY))) (+ (cadr lineY) (abs (* 0.125 deltaX))) ) lineY (list (+ (car lineY) (abs (* 0.0625 deltaY))) (+ (cadr lineY) (abs (* 0.125 deltaX))) ) "" ) ) ;end if ;; add text to drawing (setq txtPntX (list (+ (car lineX) (* 0.21875 deltaX)) (cadr lineX) 0.0) ) (setq txtPntY (list (car lineY) (+ (cadr lineY) (* 0.21875 deltaY)) 0.0) ) (setq txthgt (abs (* 0.0625 deltaX))) (entmakex (list (cons 0 "TEXT") (cons 10 txtPntX) (cons 40 txthgt) (cons 71 0) (cons 72 4) (cons 11 txtPntX) (cons 73 0) (cons 1 (rtos deltaX 2 2)) ) ) (entmakex (list (cons 0 "TEXT") (cons 10 txtPntY) (cons 40 txthgt) (cons 71 0) (cons 72 4) (cons 11 txtPntY) (cons 73 0) (cons 1 (rtos deltaY 2 2)) ) ) (princ) ) That should be enough to get you started. Quote
BIGAL Posted October 11, 2019 Posted October 11, 2019 This question was also answered somewhere else as well. I am like lee Quote
hanhphuc Posted October 16, 2019 Posted October 16, 2019 On 10/10/2019 at 10:29 PM, Margusrebase said: Hi Could enyone write autolisp that annotate differences between two points! Br. Margus old thread? -> Theorical & actual point another idea is to draw a line between 2 points, then FIELD query 'delta' properties (WCS) haven't tried dynamic block sounds good idea, with arrow shx (shape file) ? Quote
jose costa Posted October 23, 2020 Posted October 23, 2020 Hi All. i have a point cloud and i need to know the height of trees. So i have to pick 2 points in the point cloud and as result the text from that diference should apear in the drawing clicking where i want it o be. can you help me please. is so send to my email. Thank you! Quote
Recommended Posts
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.