PDA

View Full Version : Intermediate points height for profile



aijazahmed
2013-09-22, 09:25 AM
Hi all
Is there any lisp program to create the intermediate points between high & low point with equal space.
I have attached sample drawings & excel file which I am using for preparing intermediate points (height).
Please advise me.


Thanks

marko_ribar
2013-09-22, 07:42 PM
I did this code, based on DWG you provided, but my calculation differs from your... See my attachment of your DWG...



(defun c:interpoints ( / osm k ld ldh n nd nhig nl nlow npl p pl pthi ptlw segs ts x )
(setq osm (getvar 'osmode))
(setvar 'osmode 35)
(initget 7)
(setq segs (getint "\nSpecify number of divisions : "))
(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 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 (fix n) nl))
)
(setq nl (reverse nl))
(setq k 0.0)
(repeat (- segs 1)
(setq p (mapcar '+ ptlw (mapcar '* (list (setq k (1+ k)) k k) (mapcar '/ (mapcar '- pthi ptlw) (list (float segs) (float segs) (float segs))))))
(setq pl (cons p pl))
)
(setq pl (reverse pl))
(setq npl (mapcar '(lambda (n p) (list n p)) nl pl))
(initget 7)
(setq ld (getdist "\nPick length of point marker : "))
(initget 6)
(setq ts (getdist "\nPick or input text size <ENTER - 300.0> : "))
(if (eq ts nil) (setq ts 300.0))
(setq ldh (/ ld 2.0))
(foreach np npl
(entmake (list '(0 . "LINE") (cons 62 256) '(8 . "Bar Chair - X") (cons 10 (polar (cadr np) (* pi -0.5) ldh)) (cons 11 (polar (cadr np) (* pi 0.5) ldh))))
(entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") (cons 62 256) '(8 . "Bar Chair - X") '(100 . "AcDbText") (cons 10 (polar (cadr np) (* pi 0.5) ld)) (cons 40 ts) (cons 1 (itoa (car np))) (cons 50 (* pi 0.5)) '(41 . 0.7) '(51 . 0.0) '(7 . "PT_PROFILE") '(71 . 0) '(72 . 0) (cons 11 (polar (cadr np) (* 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.

aijazahmed
2013-09-23, 09:29 AM
Hi Marko,
Thanks for replay. I appreciate for your logic, it works fine. But mate I need it should work in all angel as I shown in my attachment and mate the point is can you please round off the intermediate point value to “0 & 5”. And I want to be fixe 250 mm line lengths for “mark line length” and 300mm for “text height”.


Thank You,

marko_ribar
2013-09-23, 11:23 AM
Here are my modifications to the code... Notice that now also there is slight difference in calculations from those that you provided, and now you must watch if you have to reverse curve entity in order for text to be made on right side of the curve - to match orientation of low and high points... Check my DWG and see the differences I explained - it is on curved example you posted...



(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 ( / 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)
(initget 7)
(setq segs (getint "\nSpecify number of divisions : "))
(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 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 (fix 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))
(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) '(7 . "PT_PROFILE") '(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


M.R.

marko_ribar
2013-09-23, 12:21 PM
Yes, I've found my mistake... It was on first rounding evaluation - I used (fix) function to trim trailing decimals, but I should fix it on higher number if trailing decimals are >= 0.5... Now fixed that - our results are identical... So here is my final code, also you should watch on curve path orientation (should it be reversed or not, because of text markers orientation)...



(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 ( / 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)
(initget 7)
(setq segs (getint "\nSpecify number of divisions : "))
(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 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))
(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) '(7 . "PT_PROFILE") '(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


Start it with : Command: IP

M.R.

aijazahmed
2013-09-24, 05:59 AM
Thanks a lot Marko exactly i needed this program only.

Thanks

aijazahmed
2013-09-29, 08:33 PM
dear all
Can anybody help me on below replied thread. I need some modification on program received from marko_ribar. The program will start with command IP and first it will ask to enter the number of divisions then select the high point, low point and to give there’s values respectively. My point is instate of asking the number of divisions it should calculate based on the distance between high point and low point. The minimum and maximum distance between inter mediate point should be (800 and 1150).
For example:
1) If the distance between (HP & LP) = 3000mm then number divisions will be 3.
2) If the distance between (HP & LP) = 3500mm then number divisions will be 4.


Any help will be more appreciate.

Thanks.

aijazahmed
2014-03-29, 12:14 PM
dear all
Can anybody help me on below replied thread. I need some modification on program received from marko_ribar. The program will start with command IP and first it will ask to enter the number of divisions then select the high point, low point and to give there’s values respectively. My point is instate of asking the number of divisions it should calculate based on the distance between high point and low point. The minimum and maximum distance between inter mediate point should be (800 and 1150).
For example:
1) If the distance between (HP & LP) = 3000mm then number divisions will be 3.
2) If the distance between (HP & LP) = 3500mm then number divisions will be 4.


Any help will be more appreciate.

Thanks.


Thanks............

aijazahmed
2014-04-11, 01:41 PM
Hi All

Please help me on this.

Thanks

Opie
2014-04-11, 03:11 PM
Hi All

Please help me on this.

Thanks

This line in Marko's last code post can be commented out by prefixing the line with a semi-colon ";"


(setq segs (getint "\nSpecify number of divisions : "))

Of course, with that line commented out, you will need to assign a valid value to the segs variable. So right below this line...


(setq nd (- nhig nlow))

... we will need to calculate the value for segs.


(setq minRange 800) ; Assign minimum range to variable
(setq maxRange 1150) ; Assign maximum range to variable
(setq segs 1) ; Assign default value to segs
(while ; Start loop
(not ; Condition to check if the opposite of the follow criteria is true
(and ; All of the following criteria must be true
(> (/ nd segs) minRange) ; Does the distance fall above the minimum range
(< (/ nd segs) maxRange) ; Does the distance fall above 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
)

aijazahmed
2014-04-19, 05:45 PM
thanks opie sir for reply
sir, really I don't know how to edit the program. But I tried to modified as you advise and when run the program it showing error "ip ; error: bad argument type: numberp: nil".
may be I am wrong. please advise me.



(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 ( / 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)
(initget 7)
(setq nd (- nhig nlow):)
(setq minRange 800) ; Assign minimum range to variable
(setq maxRange 1150) ; Assign maximum range to variable
(setq segs 1) ; Assign default value to segs
(while ; Start loop
(not ; Condition to check if the opposite of the follow criteria is true
(and ; All of the following criteria must be true
(> (/ nd segs) minRange) ; Does the distance fall above the minimum range
(< (/ nd segs) maxRange) ; Does the distance fall above 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 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 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))
(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) '(7 . "PT_PROFILE") '(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


Thanks....

marko_ribar
2014-04-20, 04:31 PM
Couldn't you learn to use
Your code... Code tags... Opie explained very well what should you do...



(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 800) ; Assign minimum range to variable
(setq maxRange 1150) ; 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
(and ; All of the following criteria must be true
(> (/ nd segs) minRange) ; Does the distance fall above the minimum range
(< (/ nd segs) maxRange) ; Does the distance fall above 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))
(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) '(7 . "PT_PROFILE") '(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


HTH, M.R.

aijazahmed
2014-04-21, 06:06 PM
Thanks Mr. Marko_ribar for reply
sure i will start to learn the lisp program.
but please check below its showing some error. when run i run the program after giving all input data its getting hang and when I press Escape its showing error. please advise me.

Command: ip
Pick curve path along witch markers are to be placed
Pick low point
Input low value : 55

Pick high point
Input high value : 255
; error: Function cancelled

Thanks,,

marko_ribar
2014-04-21, 08:30 PM
Difference between high value and low value must be greater than minRange variable (800) and lower than maxRange (1150), and your input was (255-55=200<800)... Try again with : Input low value : 55; Input high value : 1255 and tell me is it good - it should return the same error (1255-55=1200>1150)... Finally try with : Input low value : 55; Input high value : 1055 - it should work (1055-55=1000; 800<1000<1150)... Or try different : Input low value : 1055; Input high value : 2055 - it should work (2055-1055=1000; 800<1000<1150)...

HTH, M.R.

marko_ribar
2014-04-21, 10:03 PM
Having this in mind what was your request...


dear all
Can anybody help me on below replied thread. I need some modification on program received from marko_ribar. The program will start with command IP and first it will ask to enter the number of divisions then select the high point, low point and to give there’s values respectively. My point is instate of asking the number of divisions it should calculate based on the distance between high point and low point. The minimum and maximum distance between inter mediate point should be (800 and 1150).
For example:
1) If the distance between (HP & LP) = 3000mm then number divisions will be 3.
2) If the distance between (HP & LP) = 3500mm then number divisions will be 4.


Any help will be more appreciate.

Thanks.

And having this in mind what Opie's condition intervention means - what I've just explained...


Difference between high value and low value must be greater than minRange variable (800) and lower than maxRange (1150), and your input was (255-55=200<800)... Try again with : Input low value : 55; Input high value : 1255 and tell me is it good - it should return the same error (1255-55=1200>1150)... Finally try with : Input low value : 55; Input high value : 1055 - it should work (1055-55=1000; 800<1000<1150)... Or try different : Input low value : 1055; Input high value : 2055 - it should work (2055-1055=1000; 800<1000<1150)...

HTH, M.R.

I've modified the code, but be aware that difference between high and low value must be in ranges (800<difference<1150; or 2*800=1600<difference<2*1150=2300; or 3*800=2400<difference<3*1150=3450;... and so on (segs*800<difference<segs*1150)...

For this new explanation this code should work :



(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 800.0) ; Assign minimum range to variable
(setq maxRange 1150.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))
(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) '(7 . "PT_PROFILE") '(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


HTH, M.R.
P.S. If following explained criteria isn't fulfilled (intervals for difference values), routine may and should fail...

marko_ribar
2014-04-22, 05:40 AM
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 :



(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.

aijazahmed
2014-04-22, 05:38 PM
Hi Mr. Marko_ribar
I fill very grateful after when I saw your replies thanks mate.
but Sorry mate still there is a some problem. Because my range (800 to 1150) is not for height wise its for the distance between point markers.
The code was fine which is replied by you on post no:5.

there is some nice steps like,

1) Command: ip

2) Specify number of divisions : ..........

3) Pick curve path along witch markers are to be placed
4) Pick low point
5) Input low value : .....

6) Pick high point
7) Input high value : ........

8) Pick or input length of point marker <ENTER - 250.0> :

9) Pick or input text size <ENTER - 300.0> :

And after that i requested for modification in step (2) like,
instate of asking the number of divisions it should calculate the number of divisions (point markers) based on the distance between "low point"(step 4) and "high point"(step 6)
with in the range minimum and maximum distance between point markers must be (800 and 1150).

For example:
1) If the distance of curve between step (4 & 6) = 3000mm then number divisions will be 3 (markers).
2) If the distance of curve between step (4 & 6) = 3500mm then number divisions will be 4 (markers).

and the program should be continue until press enter or escape.

Now I hope it will be clear for you.

Thank you..

marko_ribar
2014-04-22, 06:48 PM
Never mind on what values ranges refer, again the same explanation : What if distance is 1255? It's not in range 800<dist<1150, so it's not 1 division, and it's in range 800<dist<1600, so it should be 1 division...

Here is my final version - it uses just divRange=800.0 and according to that value it calculates number of segments - divisions...


(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 ( / divRange 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 divRange 800.0)
(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 lowd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path ptlw)))
(setq higd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path pthi)))
(setq segs (1+ (fix (/ (- higd lowd) divRange))))
(setq nd (- nhig nlow))
(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)
(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))


Regards, M.R.

Opie
2014-04-22, 06:51 PM
In your code in post #11, you have an extra character that needs to be removed.

Find this line...


(setq nd (- nhig nlow):)

... and remove the semi-colon. That line should read as ...


(setq nd (- nhig nlow))


I have not tested the remainder of your code to see if there are any other errors.

Good luck.

aijazahmed
2014-04-24, 05:49 PM
Hi Mr.Marko
Your code in post # 18 is working fine with (setq divRange 800.0). Same thing I need with range 800 to 1200 (for safer side I taken 1150).
because from design drawing I will get curves high and low point(chair) values like,
( 140....35....125...55...205....185...35....140) these are main point of curve and minimum distance between these main point is 1500, for safer side will consider 1600.
And in practically to maintain the curve with cable we will provide intermediate chairs (points). At least one chair must be needed between main points.

So if curve distance is,

Distance division Range
1600 / 2 = 800 (1 point) is my minimum range.
2300 / 2 = 1150 (2 points)
2400 / 2 = 1200 (2 points)
2500 / 2 = 1250 then I will go for three point 2500/3=833(3 points)
5000 / 5 = 1000 (5 points).

And no need to mark the main points it will be there already.


Thanks..

marko_ribar
2014-04-24, 07:09 PM
Hi Mr.Marko
Your code in post # 18 is working fine with (setq divRange 800.0). Same thing I need with range 800 to 1200 (for safer side I taken 1150).
because from design drawing I will get curves high and low point(chair) values like,
( 140....35....125...55...205....185...35....140) these are main point of curve and minimum distance between these main point is 1500, for safer side will consider 1600.
And in practically to maintain the curve with cable we will provide intermediate chairs (points). At least one chair must be needed between main points.

So if curve distance is,

Distance division Range
1600 / 2 = 800 (1 point) is my minimum range.
2300 / 2 = 1150 (2 points)
2400 / 2 = 1200 (2 points)
2500 / 2 = 1250 then I will go for three point 2500/3=833(3 points)
5000 / 5 = 1000 (5 points).

And no need to mark the main points it will be there already.


Thanks..

Just change : (setq divRange 800.0) to : (setq divRange 1200.0) and your request will be satisfied...

0-1200 (1000 / 1200 = 0 points (1 segment); segment length = 1000 / 1 = 1000 (800-1150))
1200 (distance between main points) / 1200 (divRange) = 1 points (2 segments) ; segment length = 1200 / 2 = 600 (800-1150)
600 is minimal value and it occur only when 2 segments are in main distance range (1200 - 1600)

1600 (distance between main points) / 1200 (divRange) = 1 points (2 segments) ; segment length = 1600 / 2 = 800 (800-1150)

in ranges from 1600 - ... 800 is minimal range of segment length

2300 (distance between main points) / 1200 (divRange) = 1 points (2 segments) ; segment length = 2300 / 2 = 1150 (800-1150)

2350 (distance between main points) / 1200 (divRange) = 1 points (2 segments) ; segment length = 2350 / 2 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 2300 - 2400)

2400 (distance between main points) / 1200 (divRange) = 2 points (3 segments) ; segment length = 2400 / 3 = 800 (800-1150)
2500 (distance between main points) / 1200 (divRange) = 2 points (3 segments) ; segment length = 2500 / 3 = 833.33 (800-1150)

4600 (distance between main points) / 1200 (divRange) = 3 points (4 segments) ; segment length = 4600 / 4 = 1150 (800-1150)

4700 (distance between main points) / 1200 (divRange) = 3 points (4 segments) ; segment length = 4700 / 4 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 2x2300=4600 - 2x2400=4800)

4800 (distance between main points) / 1200 (divRange) = 4 points (5 segments) ; segment length = 4800 / 5 = 960 (800-1150)

5000 (distance between main points) / 1200 (divRange) = 4 points (5 segments) ; segment length = 5000 / 5 = 1000 (800-1150)

6900 (distance between main points) / 1200 (divRange) = 5 points (6 segments) ; segment length = 6900 / 6 = 1150 (800-1150)

7050 (distance between main points) / 1200 (divRange) = 5 points (6 segments) ; segment length = 7050 / 6 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 3x2300=6900 - 3x2400=7200)

7200 (distance between main points) / 1200 (divRange) = 6 points (7 segments) ; segment length = 7200 / 7 = 1028.57 (800-1150)

9200 (distance between main points) / 1200 (divRange) = 7 points (8 segments) ; segment length = 9200 / 8 = 1150 (800-1150)

9400 (distance between main points) / 1200 (divRange) = 7 points (8 segments) ; segment length = 9400 / 8 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 4x2300=9200 - 4x2400=9600)

9600 (distance between main points) / 1200 (divRange) = 8 points (9 segments) ; segment length = 9600 / 9 = 1066.66 (800-1150)

11500 (distance between main points) / 1200 (divRange) = 9 points (10 segments) ; segment length = 11500 / 10 = 1150 (800-1150)

11750 (distance between main points) / 1200 (divRange) = 9 points (10 segments) ; segment length = 11750 / 10 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 5x2300=11500 - 5x2400=12000)

12000 (distance between main points) / 1200 (divRange) = 10 points (11 segments) ; segment length = 12000 / 11 = 1090.90 (800-1150)

13800 (distance between main points) / 1200 (divRange) = 11 points (12 segments) ; segment length = 13800 / 12 = 1150 (800-1150)

14100 (distance between main points) / 1200 (divRange) = 11 points (12 segments) ; segment length = 14100 / 12 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 6x2300=13800 - 6x2400=14400)

14400 (distance between main points) / 1200 (divRange) = 12 points (13 segments) ; segment length = 14400 / 13 = 1107.69 (800-1150)

16100 (distance between main points) / 1200 (divRange) = 13 points (14 segments) ; segment length = 16100 / 14 = 1150 (800-1150)

16450 (distance between main points) / 1200 (divRange) = 13 points (14 segments) ; segment length = 16450 / 14 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 7x2300=16100 - 7x2400=16800)

16800 (distance between main points) / 1200 (divRange) = 14 points (15 segments) ; segment length = 16800 / 15 = 1120 (800-1150)

17250 (distance between main points) / 1200 (divRange) = 14 points (15 segments) ; segment length = 17250 / 15 = 1150 (800-1150)

17625 (distance between main points) / 1200 (divRange) = 14 points (15 segments) ; segment length = 17625 / 15 = 1175 (800-1150)
1175 is approximately 1150 (here is gap 14x1200=16800 - 15x1200=18000) (segment gap 1120 - 1200)

18000 (distance between main points) / 1200 (divRange) = 15 points (16 segments) ; segment length = 18000 / 16 = 1125 (800-1150)

Final conclusion of this analysis is that when divRange=1200, minimal segment length is divRange/2=600, and maximal is 1200=divRange...

So maybe divRange=1400 (min. seg. = 1400/2 = 700; max. seg. = 1400)... And to be exact from what's your request (800-1150) => divRange= ((800+1150)/2)x(4/3)=1300 => (min. seg. = 1300/2 = 650 ; (975-650=325); max. seg. = 1300 ; (1300-975=325))

My calculation shows that for condition (800-1150), divRange=1300, and I suggest you to use it...

P.S. If you're unsatisfied with results, you should change your ranges condition (800-1150), and calculate divRange according to my calculation...
P.S.S. If you want to stick to unchangeable lower bound 800.0... Then ranges condition should be (800 - 2*800=1600) => divRange= ((800+1600)/2)x(4/3)=1600 => (min. seg. = 1600/2 = 800 ; [((800+1600)/2)-800=400]; max. seg. = 1600 ; [1600-((800+1600)/2)=400]
So if 800 must be respected as min. seg. - condition (800-1600), my suggestion is that divRange=1600...


P.S.S.S. As I showed if you don't have any main distances from 1200 to 1600, where seg. would be 600-800, and you want to stick and with upper bound 1200 - condition (800-1200), then my final suggestion is divRange=1200... As you said that in most distances you'll have to insert minimum 1 point - for divRange=1200 that range is (1200-2400), so in your drawing make sure that minimal distance is actually 1200 and desirable (1600-2400)... And for conclusion use divRange=1200 - that way your upper and lower bounds will be satisfied...

As for marking main points (unmarking), just comment those paragraphs with starting ;| sign and ending |; sign...

Good luck.
M.R.

aijazahmed
2014-04-25, 01:30 PM
Hi Mr.Marko

Thanks a lot mate for your best support. I know there is problem to fix divRange (800 to 1150) but we can manage this range by manual method.
So now finally I decided that we will go through the code which you posted in post #5. And lets the program ask to specify number of division.
And before this step its show the distance between main points by mark or in command line. So I can decide division number base on the distance.

sorry I change the program concept. because we cant change the range and we have design curve value with minimum points so we can save something.

Thanks...

marko_ribar
2014-04-25, 02:02 PM
(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 ( / 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 lowd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path ptlw)))
(setq higd (vlax-curve-getdistatpoint path (vlax-curve-getclosestpointto path pthi)))
(prompt (strcat "\nDistance between picked low and hig points is : " (rtos (- higd lowd) 2 15)))
(initget 7)
(setq segs (getint "\nSpecify number of divisions (segments) (1=>0 points;2=>1 point;3=>2 points): "))
(setq nd (- nhig nlow))
(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)
(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))
(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)))
)
(setvar 'osmode osm)
(princ)
)

(defun c:ip nil (c:interpoints))


HTH, M.R.

aijazahmed
2014-05-03, 03:58 PM
Thanks M.r Marko
Its working fine. I was need same.
Thank you so much.