pBe Posted June 6, 2012 Posted June 6, 2012 (edited) Nice code too.. Thanks pBe. Its not that all great really, i just tested the theory based on the pseudo code i posted earlier This one for straight segments only [first pseudo code] (defun c:KP1 ( / _testwhere _insert pline inspts anglesP i v att d) (vl-load-com) (defun _testwhere (pt lst e / ang) (setq ang (vl-some '(lambda (r) (if (< (vlax-curve-getDistAtPoint e pt) (car r)) (cadr r))) lst)) ang ) (defun _insert (pt bn ro) (vlax-invoke (vlax-get (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object))) 'Block) 'InsertBlock pt bn 1 1 1 ro)) (if (and (setq pline (car (entsel))) (setq b (cond ((getdist (strcat "Specify KP interval in metres or [Pick two points] <" (rtos (setq b (cond ( b ) ( 100 )) ) 2 2) ">: " ))) ( b )) )) (progn (setq points (mapcar 'cdr (vl-remove-if-not '(lambda (j) ( = (car j) 10)) (setq ent (entget pline))))) (setq anglesP (mapcar '(lambda (k l ) (list (setq d (if (null d) (distance k l) ( + (distance k l) d))) (angle k l))) points (cdr points))) (setq i b) (while (setq v (vlax-curve-getPointAtDist pline i)) (setq inspts (append inspts (list v)) i (+ i b)) ) (mapcar (function (lambda (m / att) (setq att (_insert m "KP" (_testwhere m anglesP pline))) (mapcar '(lambda (h) (if (eq (vla-get-tagstring h) "KP") (vla-put-textstring h (rtos (/ (vlax-curve-getDistAtPoint pline m) 1000) 2 1)))) (vlax-invoke att 'GetAttributes)))) (cons (vlax-curve-getStartPoint pline) inspts) ) ) ) (princ) ) Hey pBe, your rouine is very nice,Regards, Oleg Thank you Oleg, it means a lot coming from you Edited June 6, 2012 by pBe Quote
aaryan Posted June 7, 2012 Author Posted June 7, 2012 Thanks pBe and Oleg. both of your code working fine and very much suits my requirement. Is it possible. Suppose if i want to give Kp interval as 250m, then the attribute inserted should be "0.25" Kp and if i give 25m it should be "0.025" Kp. Or simply ask the user for decimal place. 1, When i use Oleg's code the rotation of the KP block differs (when the polyline picked is zig zag from north to south or curvy) from the measure command. Can this be fixed Oleg Please... 2, When i use pBe's code and gives the interval as 250m, sometimes the KP starts from other end even after picking the nearest point from the desired direction and sometimes not. Am i doing something wrong. Reference drawing is inserted. Comparison.dwg Regards Aaryan Quote
pBe Posted June 7, 2012 Posted June 7, 2012 Thanks pBe and Oleg. both of your code working fine and very much suits my requirement.When i use pBe's code and gives the interval as 250m, sometimes the KP starts from other end even after picking the nearest point from the desired direction and sometimes not. Am i doing something wrong. Reference drawing is inserted. [ATTACH]35237[/ATTACH] Regards Aaryan You are not doing anything wrong, its the code thats causing the all the chaos , I knew i should've test it more thoroughly I will look into it later. If i were you, i'll stick with Olegs code, mine is somewhat on experimental stage. Quote
aaryan Posted June 7, 2012 Author Posted June 7, 2012 Thanks pBe I will do the same as you suggests. Regards. 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.