PDA

View Full Version : Get a point between 2 points


bmonk
2008-07-11, 09:12 PM
Im trying to write a routine that will basically draw in a series of polylines that give me the subdivision of a land section, down to quarter quarter.

Basically I want to pick the 4 corners of a section, and have it draw all the lines needed to divide it up by qtr qtr.

Im learning lisp as i go along here, and so far I know how to get the points for the 4 corners, but how do i get the point between the for corners to start drawing the division lines.

any help would be appreciated.

thanks

miff
2008-07-11, 11:11 PM
This will return the midpoint between 2 points.

(defun midpt (p1 p2)
(mapcar '/ (mapcar '+ p1 p2) '(2.0 2.0 2.0))
)

Adesu
2008-07-15, 08:07 AM
Why not post to here your drawing.

Im trying to write a routine that will basically draw in a series of polylines that give me the subdivision of a land section, down to quarter quarter.

Basically I want to pick the 4 corners of a section, and have it draw all the lines needed to divide it up by qtr qtr.

Im learning lisp as i go along here, and so far I know how to get the points for the 4 corners, but how do i get the point between the for corners to start drawing the division lines.

any help would be appreciated.

thanks

Tom Beauford
2008-07-15, 04:25 PM
To intersect the Center of section and subsequent quarters use the "inters" lisp function.

alanjt
2008-07-26, 05:32 AM
i know i'm giving you the fish, but here it is anyway. i didn't write it, but i use it every once in a while.

;;; CADALYST 07/07 Tip 2219: Quadline.lsp Section Lines (c) 2007 Steve Schenck

;;Steve Schenck.......................................................March 2004
;;Draws the Section Lines, Qtr Lines , and Qtr-Qtr lines from four user defined corners
;;It also adds a layer to place Section Line related text on.
;;
(defun c:Quadline (/ PT1 PT2 PT3 PT4 OLAY OCOL
DWSL PT1X PT2X PT3X PT4X PT1Y PT2Y
PT3Y PT4Y
)
(setq PT1 (getpoint "\nPick UL corner....: "))
(setq PT2 (getpoint "\nPick UR corner....: "))
(setq PT3 (getpoint "\nPick LR corner....: "))
(setq PT4 (getpoint "\nPick LL corner....: "))
(setq OSNP (getvar "osmode"))
(setvar "osmode" 0)
(setq OLAY (getvar "clayer"))
(setq OCOL (getvar "cecolor"))
(command "-layer" "M" "NWTN-Section-Lines-Text"
"C" "5" "" ""
"._color" bylayer
)
(initget "Y y N n")
(setq DWSL (getkword "\nDraw Section Lines Y/N <N>: "))
(if (= DWSL nil)
(setq DWSL "N")
)
(Cond
((or (= DWSL "Y") (= DWSL "y"))
(command "-layer" "M" "NWTN-Section-Lines"
"C" "2" "" ""
"._color" bylayer
)
(command "line" PT1 PT2 PT3 PT4 PT1 "")
)
)
(setq PT1X (car PT1))
(setq PT1Y (car (cdr Pt1)))
(setq PT2X (car PT2))
(setq PT2Y (car (cdr Pt2)))
(setq PT12X (/ (+ PT1X PT2X) 2.0))
(setq PT12XS (rtos PT12X))
(setq PT12Y (/ (+ PT1Y PT2Y) 2.0))
(setq PT12YS (rtos PT12Y))
(SETQ PT12 (STRCAT PT12XS "," PT12YS))
(setq PT3X (car PT3))
(setq PT3Y (car (cdr Pt3)))
(setq PT4X (car PT4))
(setq PT4Y (car (cdr Pt4)))
(setq PT34X (/ (+ PT3X PT4X) 2.0))
(setq PT34XS (rtos PT34X))
(setq PT34Y (/ (+ PT3Y PT4Y) 2.0))
(setq PT34YS (rtos PT34Y))
(SETQ PT34 (STRCAT PT34XS "," PT34YS))
(command "-layer" "M" "NWTN-Section-Lines-Qtr"
"C" "1" "" ""
"._color" bylayer
)
(command "line" PT12 PT34 "")
(setq PT14X (/ (+ PT1X PT4X) 2.0))
(setq PT14XS (rtos PT14X))
(setq PT14Y (/ (+ PT1Y PT4Y) 2.0))
(setq PT14YS (rtos PT14Y))
(SETQ PT14 (STRCAT PT14XS "," PT14YS))
(setq PT23X (/ (+ PT2X PT3X) 2.0))
(setq PT23XS (rtos PT23X))
(setq PT23Y (/ (+ PT2Y PT3Y) 2.0))
(setq PT23YS (rtos PT23Y))
(SETQ PT23 (STRCAT PT23XS "," PT23YS))
(command "line" PT14 PT23 "")
(command "-layer" "M" "NWTN-Section-Lines-Qtr-Qtr"
"C" "5" ""
"" "._color" bylayer
)
(setq PT12XQ (- PT12X (/ (- PT2X PT1X) 4.0)))
(setq PT12XQS (rtos PT12XQ))
(setq PT12YQ (- PT12Y (/ (- PT2Y PT1Y) 4.0)))
(setq PT12YQS (rtos PT12YQ))
(SETQ PT12Q (STRCAT PT12XQS "," PT12YQS))
(setq PT34XQ (- PT34X (/ (- PT3X PT4X) 4.0)))
(setq PT34XQS (rtos PT34XQ))
(setq PT34YQ (- PT34Y (/ (- PT3Y PT4Y) 4.0)))
(setq PT34YQS (rtos PT34YQ))
(SETQ PT34Q (STRCAT PT34XQS "," PT34YQS))
(setq PT12XQQ (+ PT12X (/ (- PT2X PT1X) 4.0)))
(setq PT12XQQS (rtos PT12XQQ))
(setq PT12YQQ (+ PT12Y (/ (- PT2Y PT1Y) 4.0)))
(setq PT12YQQS (rtos PT12YQQ))
(SETQ PT12QQ (STRCAT PT12XQQS "," PT12YQQS))
(setq PT34XQQ (+ PT34X (/ (- PT3X PT4X) 4.0)))
(setq PT34XQQS (rtos PT34XQQ))
(setq PT34YQQ (+ PT34Y (/ (- PT3Y PT4Y) 4.0)))
(setq PT34YQQS (rtos PT34YQQ))
(SETQ PT34QQ (STRCAT PT34XQQS "," PT34YQQS))
(command "line" PT12Q PT34Q "")
(command "line" PT12QQ PT34QQ "")
(setq PT14XQ (- PT14X (/ (- PT1X PT4X) 4.0)))
(setq PT14XQS (rtos PT14XQ))
(setq PT14YQ (- PT14Y (/ (- PT1Y PT4Y) 4.0)))
(setq PT14YQS (rtos PT14YQ))
(SETQ PT14Q (STRCAT PT14XQS "," PT14YQS))
(setq PT23XQ (- PT23X (/ (- PT2X PT3X) 4.0)))
(setq PT23XQS (rtos PT23XQ))
(setq PT23YQ (- PT23Y (/ (- PT2Y PT3Y) 4.0)))
(setq PT23YQS (rtos PT23YQ))
(SETQ PT23Q (STRCAT PT23XQS "," PT23YQS))
(setq PT14XQQ (+ PT14X (/ (- PT1X PT4X) 4.0)))
(setq PT14XQQS (rtos PT14XQQ))
(setq PT14YQQ (+ PT14Y (/ (- PT1Y PT4Y) 4.0)))
(setq PT14YQQS (rtos PT14YQQ))
(SETQ PT14QQ (STRCAT PT14XQQS "," PT14YQQS))
(setq PT23XQQ (+ PT23X (/ (- PT2X PT3X) 4.0)))
(setq PT23XQQS (rtos PT23XQQ))
(setq PT23YQQ (+ PT23Y (/ (- PT2Y PT3Y) 4.0)))
(setq PT23YQQS (rtos PT23YQQ))
(SETQ PT23QQ (STRCAT PT23XQQS "," PT23YQQS))
(command "line" PT14Q PT23Q "")
(command "line" PT14QQ PT23QQ "")
(setvar "osmode" OSNP)
(command "._LAYER" "s" OLAY "")
(command "._color" OCOL)
)

alanjt
2008-07-26, 05:36 AM
To intersect the Center of section and subsequent quarters use the "inters" lisp function.

hey tom, nice to see a fellow panhandler.