If I may suggest what you should do to avoid endless while looping if difference between high and low value is beyond specified intervals, you should put minRange variable to 0.1 and maxRange to 800.0... This way if :
1) 0<diff<800 there are no divisions
2) 800<=diff<1600 there is 1 division (very much like your desired 800<diff<1150, but now no empty gap between 1150 and 2*800=1600
3) 1600<=diff<2400 there are 2 divisions...
...
n+1) 800*n<=diff<800*(n+1) there are n divisions
With this trick you can ensure that routine won't fail in any situation, so your Low value : 55 and High value : 255 should be OK...
And if you don't want to make low/high markers, just remove ;;; signs before and after paragraphs that are marked with comments...
Here is newest code that should work in any case :
Code:
(defun fixx ( n / remi r )
(setq remi (- n (fix n)))
(if (< remi 0.5) (setq r (fix n)))
(if (>= remi 0.5) (setq r (+ (fix n) 1)))
r
)
(defun round ( n / ldig r )
(setq ldig (- n (* (fix (/ n 10.0)) 10)))
(if (< -0.5 ldig 3) (setq r (* (fix (/ n 10.0)) 10)))
(if (< 2 ldig 8) (setq r (+ (* (fix (/ n 10.0)) 10) 5)))
(if (< 7 ldig 9.5) (setq r (+ (* (fix (/ n 10.0)) 10) 10)))
r
)
(defun c:interpoints ( / minRange maxRange osm path lowd higd dd dst k a ld ldh n nd nhig nl nlow npl p pl pthi ptlw segs ts x )
(vl-load-com)
(setq osm (getvar 'osmode))
(setvar 'osmode 35)
(setq path (car (entsel "\nPick curve path along witch markers are to be placed")))
(setq ptlw (getpoint "\nPick low point"))
(initget 7)
(setq nlow (getint "\nInput low value : "))
(setq pthi (getpoint "\nPick high point"))
(initget 7)
(setq nhig (getint "\nInput high value : "))
(setq nd (- nhig nlow))
(setq minRange 0.1) ; Assign minimum range to variable
(setq maxRange 800.0) ; Assign maximum range to variable
(setq segs 1.0) ; Assign default value to segs
(while ; Start loop
(not ; Condition to check if the opposite of the follow criteria is true
(< (/ nd maxRange) segs (/ nd minRange)) ; Does the distance fall above the minimum range and below the maximum range
)
(setq segs (1+ segs)) ; Now that we know the above condition was true, increment the number of segments by 1 and repeat the condition check
)
(setq segs (fix segs))
(setq x (/ (float nd) (expt segs 2)))
(setq k -1.0)
(setq n nlow)
(repeat (- segs 1)
(setq n (+ (* x (setq k (+ k 2.0))) n))
(setq nl (cons (round (fixx n)) nl))
)
(setq nl (reverse nl))
(setq k 0.0)
(setq lowd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path ptlw)))
(setq higd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path pthi)))
(if (< lowd higd)
(setq dd (/ (- higd lowd) (float segs)) dst lowd)
(setq dd (/ (- lowd higd) (float segs)) dst higd nl (reverse nl))
)
(repeat (- segs 1)
(setq p (vlax-curve-getpointatdist path (+ dst (* (setq k (1+ k)) dd))))
(setq pl (cons p pl))
)
(setq pl (reverse pl))
(setq npl (mapcar '(lambda (n p) (list n p)) nl pl))
(initget 6)
(setq ld (getdist "\nPick or input length of point marker <ENTER - 250.0> : "))
(if (null ld) (setq ld 250.0))
(initget 6)
(setq ts (getdist "\nPick or input text size <ENTER - 300.0> : "))
(if (null ts) (setq ts 300.0))
(setq ldh (/ ld 2.0))
;;; If you don't want to make start low marker with low value, mark this paragraph with starting ;| sign and ending |; sign
;;; ;|
(setq a (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv path (vlax-curve-getparamatpoint path ptlw))))
(entmake (list '(0 . "LINE") (cons 62 256) '(8 . "Bar Chair - X") (cons 10 (polar ptlw (+ a (* pi -0.5)) ldh)) (cons 11 (polar ptlw (+ a (* pi 0.5)) ldh))))
(entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") (cons 62 256) '(8 . "Bar Chair - X") '(100 . "AcDbText") (cons 10 (polar ptlw (+ a (* pi 0.5)) ld)) (cons 40 ts) (cons 1 (itoa nlow)) (cons 50 (+ a (* pi 0.5))) '(41 . 0.7) '(51 . 0.0) (cons 7 (getvar 'textstyle)) '(71 . 0) '(72 . 0) (cons 11 (polar ptlw (+ a (* pi 0.5)) ld)) '(210 0.0 0.0 1.0) '(100 . "AcDbText") '(73 . 2)))
;;; |;
(foreach np npl
(setq a (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv path (vlax-curve-getparamatpoint path (cadr np)))))
(entmake (list '(0 . "LINE") (cons 62 256) '(8 . "Bar Chair - X") (cons 10 (polar (cadr np) (+ a (* pi -0.5)) ldh)) (cons 11 (polar (cadr np) (+ a (* pi 0.5)) ldh))))
(entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") (cons 62 256) '(8 . "Bar Chair - X") '(100 . "AcDbText") (cons 10 (polar (cadr np) (+ a (* pi 0.5)) ld)) (cons 40 ts) (cons 1 (itoa (car np))) (cons 50 (+ a (* pi 0.5))) '(41 . 0.7) '(51 . 0.0) (cons 7 (getvar 'textstyle)) '(71 . 0) '(72 . 0) (cons 11 (polar (cadr np) (+ a (* pi 0.5)) ld)) '(210 0.0 0.0 1.0) '(100 . "AcDbText") '(73 . 2)))
)
;;; If you don't want to make end high marker with high value, mark this paragraph with starting ;| sign and ending |; sign
;;; ;|
(setq a (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv path (vlax-curve-getparamatpoint path pthi))))
(entmake (list '(0 . "LINE") (cons 62 256) '(8 . "Bar Chair - X") (cons 10 (polar pthi (+ a (* pi -0.5)) ldh)) (cons 11 (polar pthi (+ a (* pi 0.5)) ldh))))
(entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") (cons 62 256) '(8 . "Bar Chair - X") '(100 . "AcDbText") (cons 10 (polar pthi (+ a (* pi 0.5)) ld)) (cons 40 ts) (cons 1 (itoa nhig)) (cons 50 (+ a (* pi 0.5))) '(41 . 0.7) '(51 . 0.0) (cons 7 (getvar 'textstyle)) '(71 . 0) '(72 . 0) (cons 11 (polar pthi (+ a (* pi 0.5)) ld)) '(210 0.0 0.0 1.0) '(100 . "AcDbText") '(73 . 2)))
;;; |;
(setvar 'osmode osm)
(princ)
)
(defun c:ip nil (c:interpoints))
M.R.