Jump to content

Dimension between two polylines


ysezgul

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by hanhphuc
3d - nil
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...