ysezgul Posted January 9, 2016 Share Posted January 9, 2016 Hi, I'm new at lisp. Because of this I can create only simple things. I need a code to create dimensions from vertexes of a polyline to the other polyline perpendicularly. Could you help me please? Yusuf Quote Link to comment Share on other sites More sharing options...
hlammerts Posted January 9, 2016 Share Posted January 9, 2016 I think this is a two step rocket approach. First step would to create lines, face or volume to describe this distance. Did you this, and what techniques would be most appropriate? Dims (results) would follow then. What challange is it? Can you describe it a little more. Maybe a sample dwg file. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 9, 2016 Share Posted January 9, 2016 hlammerts your heading in wrong direction, if you do a manual line, perp, pick 2nd-pline, pick pt will give this answer. There is a lisp out there. Pretty sure a recent alignment lisp has the answer. Quote Link to comment Share on other sites More sharing options...
ysezgul Posted January 11, 2016 Author Share Posted January 11, 2016 I've attached a sample file. dimension.dwg Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted January 13, 2016 Share Posted January 13, 2016 (edited) I've attached a sample file. Since you are not coding for this project, my attemp only works for polyline without bulges, else can use vlax-curve-xx method more generic (defun c:dim2pl (/ *error* l l1 l2 lst mp os pt pts sz tmp vo vo2) ;hanhphuc 13.01.16 (defun *error* (msg) (if os (setvar 'osmode os)) (if (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) ) (setq os (getvar 'osmode )) (setvar 'osmode 0) (defun xyz (l 3d / ls) ; recursive inspired by - Lee Mac (if l (cons (mapcar ''((x) (nth x l)) (if 3d '(0 1 2)'(0 1))) (xyz ((if 3d cdddr cddr ) l ) 3d )))) (if(and (mapcar ''((a b c / ss)(princ (strcat "\nPick "c" POLYLINE.. ")) (if(while (not ss) (setq ss (ssget "_+.:E:S:L" '((0 . "*POLYLINE"))))) (progn(setq e (ssname ss 0))(set b (vlax-ename->vla-object e)) [color="#006400"];(vlax-property-available-p (eval b) 'coordinates)[/color] (set a (xyz (vlax-get (vlax-ename->vla-object e) 'coordinates) (= "POLYLINE" (cdr (assoc 0 (entget e)))) ) ) )))'(l1 l2)'(vo vo2)'("1st" "2nd")) (mapcar ''((x) (set x (mapcar ''((p) (trans p 0 1)) (eval x)))) '(l1 l2)) (setq l l1) l2 (not(equal vo vo2)) ) (repeat 2 (foreach p1 l2 (setq lst (vl-remove nil (mapcar ''((x) (hp:ptol p1 x [color="red"]nil[/color])) (mapcar ''((a b) (list a b)) l (cdr l))))) (if (setq pt (cadr (assoc (apply 'min (mapcar 'car lst)) lst))) (setq pts (mapcar ''((x) (list (car x) (cadr x))) (list p1 pt)) sz (* 0.05 (apply 'distance pts)) mp (apply 'mapcar (cons ''((a b) (* 0.5 (+ a b))) pts)) tmp (if (vl-cmdf "_dimaligned" p1 pt mp) (mapcar '(lambda (a b) (vlax-put (vlax-ename->vla-object (entlast)) a b)) '("TextHeight" "ArrowheadSize" "TextInside" ) (list sz sz 1) )))))(setq l l2 l2 l1)))(setvar 'osmode os) (princ)) ;[url="http://www.cadtutor.net/forum/showthread.php?94961-Calculating-max-z-value&p=650012&viewfull=1#post650012"]point to line [/url] (defun hp:ptol (p 2p 3d / ad d pp) ; hanhphuc - 29.10.2015 (setq ad (mapcar '(lambda (f) (apply f (mapcar ''((x) (list (car x) (cadr x))) 2p))) '(angle distance) ) ;_ end of mapcar d (vxv (mapcar '- p (car 2p)) (mapcar ''((f) (f (car ad))) (list cos sin))) pp (polar (car 2p) (car ad) d) ) ;_ end of setq (if (<= 0. d (cadr ad)) (list (distance p pp) (list (car pp) (cadr pp) (if 3d (+ (* (/ (apply '- (mapcar 'last (reverse 2p))) (cadr ad)) d) (caddr (car 2p))) (caddr p) ) ;_ end of if ) ;_ end of list ) ;_ end of list ) ;_ end of if ) ;_ end of defun ;; Vector Dot Product - Lee Mac ;; Args: u,v - vectors in R^n (defun vxv ( u v ) (apply '+ (mapcar '* u v)) ) Edited January 15, 2016 by hanhphuc 3d - nil Quote Link to comment Share on other sites More sharing options...
ysezgul Posted January 14, 2016 Author Share Posted January 14, 2016 Thank you very much hanhphuc. I appreciate you. Yusuf Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted January 15, 2016 Share Posted January 15, 2016 Though this routine can't work 100%, i'm pleased it solved your task welcome to CADTutor Quote Link to comment Share on other sites More sharing options...
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.