; Program to Interpolate N Values between 2 Elevations - ISN
; Slightly modified by Igal Averbuh 2017 (added option to select attributes as boundary values)
(defun c:ISN()
(setvar "cmdecho" 0)
(Cre_Lay "000-Interpolated-Values" "1")
(setvar "cmdecho" 1)
(setq Text1(car (nEntsel "\nSelect the First Value :")))

(setq Text2(car (nEntsel "\nSelect the Second Value :")))

(setq TElev1(ExElevation Text1))
(setq TElev2(ExElevation Text2))
(setq NumRep(Getint "\nType the Number of Values :"))
(if (> NumRep 0)
(progn
(setq distBetText(distance (ExIns Text1) (ExIns Text2)))
(setq WAng(+ (/ pi 2) (Angle (ExIns Text1) (ExIns Text2))))
(setq smDist(/ distBetText (+ 1 NumRep)))
(setq rptCntr 1)
(repeat NumRep
(setq TInsPo(Polar (ExIns Text1) (Angle (ExIns Text1) (ExIns Text2)) (* rptCntr SmDist)))
(setq TDist(+ (Distance (ExIns Text1) TInsPo) (Distance (ExIns Text2) TInspo)))
(setq Dist1(- TDist (distance (ExIns Text1) TInsPo)))
(setq Dist2(- TDist (distance (ExIns Text2) TInsPo)))
(if (= (+ Dist1 Dist2) 0)
(progn
(alert "\nDistance between Points is Zero:")
)
(progn
(setq TWeighted(/ (+ (* Dist1 TElev1) (* Dist2 TElev2)) (+ Dist1 Dist2)))
(makeTexts (list TInsPo WAng (rtos TWeighted) "000-Interpolated-Values" "MC" 0.5) T)
)
)
(setq rptCntr (1+ rptCntr))
)
)
)

(princ)
)
(princ "\nType \"ISN\" at the command prompt") (princ)

(defun makeTexts(impList impflag)
(if (/= impList nil)
(setq TextList(append TextList (list impList)))
)
(if (or (> (length TextList) 500) (= impFlag T))
(progn
(foreach curPt TextList
(setq just(strcase (nth 4 curPt)))
(cond
((= just "TL") (progn (setq s2 0) (setq s3 3)))
((= just "TC") (progn (setq s2 1) (setq s3 3)))
((= just "TR") (progn (setq s2 2) (setq s3 3)))
((= just "ML") (progn (setq s2 0) (setq s3 2)))
((= just "MC") (progn (setq s2 1) (setq s3 2)))
((= just "MR") (progn (setq s2 2) (setq s3 2)))
((= just "BL") (progn (setq s2 0) (setq s3 1)))
((= just "BC") (progn (setq s2 1) (setq s3 1)))
((= just "BR") (progn (setq s2 2) (setq s3 1)))
(T (progn (setq s2 0) (setq s3 1)))
)
(setq cAng(nth 1 curPt))
(if (and (>= cAng (/ pi 2)) ( txg 0)
(setq textH txg)
(setq textH (nth 5 curPt))
)
(entmake
(list (cons 0 "TEXT")
(cons 10 (nth 0 curPt))
(cons 11 (nth 0 curPt))
(cons 50 cAng)
(cons 1 (nth 2 curPt))
(cons 8 (nth 3 curPt))
(cons 40 textH)
(cons 71 0)
(cons 72 s2)
(cons 73 s3)
)
)
)
(setq TextList '())
)
)
)

;Function to Extract the insertion point of the Text
(defun ExIns(TEnt)
(setq TDetails(entget Tent))
(setq check(assoc 11 TDetails))
(if (= check nil)
(setq Check(cdr (assoc 10 TDetails)))
(progn
(setq check(cdr check))
(if (and (= (car check) 0) (= (cadr check) 0))
(setq Check(cdr (assoc 10 TDetails)))
(setq Check(cdr (assoc 11 TDetails)))
)
)
)
(setq Check(list (car Check) (cadr Check)))
(setq return check)
)

;Function to Create a Layer with given color.
(defun Cre_Lay(lay_layn lay_laycol)
(if (= (tblsearch "Layer" lay_layn) nil)
(command "._Layer" "n" lay_layn "c" lay_laycol lay_layn "")
(command "._Layer" "t" lay_layn "on" lay_layn "c" lay_laycol lay_layn "")
)
(princ)
)

;Function to Extract Z Value (Text Content) From Text
(defun ExElevation(TEnt)
(setq TDetails(entget Tent))
(setq return(atof (cdr (assoc 1 TDetails))))
)
;(c:isn)

Advertisements