Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Perpendiculars between polylines

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Anonymous
992 Views, 10 Replies

Perpendiculars between polylines

Hello, cand you help me with the following:

I need a lisp to measure perpendicular distances (dim aligned) from Polyline1 vertices, perpendicular to Polilyne 2.

 

Thank you!

10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

Here is an example of the desired outcome.

 

Thank you again!

Message 3 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....I need a lisp to measure perpendicular distances (dim aligned) from Polyline1 vertices, perpendicular to Polilyne 2.

....


Welcome to these Discussion Boards!

 

In very simplest terms, something like this seems to do that with LWPolylines:

 

(defun C:TEST (/ pl1 pl2)

  (setq
    pl1 (car (entsel "\nSelect Polyline 1: "))
    pl2 (car (entsel "\nSelect Polyline 2: "))
  ); setq
  (setvar 'dimse1 1); not essential, but I think preferable
  (setvar 'dimse2 1); likewise
  (foreach ver (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pl1)))
    (command "_.dimaligned"
      ver
      (vlax-curve-getClosestPointTo pl2 ver)
      "@"
    ); command
  ); foreach

); defun

 

No allowance for running object snap, no verification of appropriate selection, no setting of desired Layer or Dimension Style, no saving/resetting of System Variables, etc., yet, but see what you think.

Kent Cooper, AIA
Message 4 of 11
Anonymous
in reply to: Anonymous

Hi cristianciocoi,

 

Something quick and dirty.

Is this what you are looking for:

 

 

(defun c:test (/ coords poly2)
  (setq cords (Poly-Pts (vlax-ename->vla-object(car (entsel "\nFirst poly:"))))
	poly2 (vlax-ename->vla-object (car (entsel "\nSecond poly:")))
	)
  (foreach x cords
    (vl-cmdf "dimaligned" x (vlax-curve-getclosestpointto poly2 x) x)
    )    
  )

;;; Poly-Pts (gile)
;;; Returns the vertices list of any type of polyline (WCS coordinates)
;;;
;;; Argument
;;; pl : a polyline (ename or vla-object)

(defun Poly-Pts	(pl / pa pt lst)
  (vl-load-com)
  (setq	pa (if (vlax-curve-IsClosed pl)
	     (vlax-curve-getEndParam pl)
	     (+ (vlax-curve-getEndParam pl) 1)
	   )
  )
  (while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))
    (setq lst (cons pt lst))
  )
)

 Hope it helps,

dicra

Message 5 of 11
Anonymous
in reply to: Kent1Cooper

Thank you for your help! You have saved me from a lot of tedious work. Again Thank You!

Message 6 of 11
Anonymous
in reply to: Anonymous

Thank you!

Message 7 of 11
Anonymous
in reply to: Anonymous

Hello every one.

I tried to use this lisp code for solving my soloution, but i cant use it for exactly my porpuse.

My solution:

I need PREPENDICULAR dimalined form all of polyline1 on polyline2(not polyline2 vertice!)

Polyline2 vertices is not important for me.just polyline1 vertices on nearest prependicular point of polyline2.

Sample image and dwg files are attached.

Thannks.

Message 8 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

 

....

I need PREPENDICULAR dimalined form all of polyline1 on polyline2(not polyline2 vertice!)

....


Since they're both labeled POLYLINE1, I'm not positive that I understand correctly, but if you pick the outer green one first, I think the "TEST" command does what you want, except perhaps that it puts the dimension text inside the curves rather than outside as in your example.  To get the text on the outside, just reverse the two dimension definition point lines in the code:

 

....

(command "_.dimaligned"
  (vlax-curve-getClosestPointTo pl2 ver)
  ver
  "@"
); command

....

Kent Cooper, AIA
Message 9 of 11
Anonymous
in reply to: Kent1Cooper

Thanks for your quick response.

Sorry,it was my mistake.now the polyline name corrected.

BUT The "TEST" lisp cant draw a dimention from vertices on along of green white curve(polyline).

here is the tried lisp result.

Please see it.

Thanks for your help.

Message 10 of 11
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....

BUT The "TEST" lisp cant draw a dimention from vertices on along of green white curve(polyline).

here is the tried lisp result.

....


I suspect you have some running Object-Snap mode(s) on.  Turn them off, and try again.  Turning them off can be built into the routine, so that you don't need to make sure you do that before you run it, but was one of several things I didn't spend the time to put in it originally.  The simplest way in this situation is probably:

....

(command "_.dimaligned"
  "_none" (vlax-curve-getClosestPointTo pl2 ver)
  "_none" ver
  "@"
); command

....

Kent Cooper, AIA
Message 11 of 11
Anonymous
in reply to: Kent1Cooper

Now,solved.Thank you very much.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report