Change crooked lines into straight lines (delta x/y = 0)

Change crooked lines into straight lines (delta x/y = 0)

Sandervp
Advocate Advocate
2,206 Views
4 Replies
Message 1 of 5

Change crooked lines into straight lines (delta x/y = 0)

Sandervp
Advocate
Advocate

Hello everybody,

 

I'm changing an excisting P&ID. In this P&ID almost every line isn't perfectly horizontal or vertical.

What is the fastest way to change the delta X from every vertical line or the delta Y from every horizontal line into 0.

 

Is it possible (by using al lisp)  to select only the horizontal OR the vertical lines with a delta value of <1 for changing the different delta values into 0?

 

Thanks

0 Likes
Accepted solutions (1)
2,207 Views
4 Replies
Replies (4)
Message 2 of 5

dlanorh
Advisor
Advisor
I don't know what P&ID is?

For vertical lines you just need to check x coords of the start and end points. If the line is vertical they should be the same, and is relatively simple to change one end of the line to match the other

Conversely for horizontal lines you check the y coords against each other.

The knack will be working out which one is correct.

I am not one of the robots you're looking for

0 Likes
Message 3 of 5

Sandervp
Advocate
Advocate

Hello Dlanorh,

A P&ID is a "Piping and Instrument Diagram". It contains only lines, blocks and text. P@ID's can contain  dozens of lines but also thousands lines or even more.

 

My Piping and Instrument Diagram contains about 500 lines.

 

Select line by line to check and change the delta x or y value shall take a lot of time.

Using a lisp, is there is one, shall help me a lot

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:StraightenLines (/ ss i en ed x y)
  (if (setq ss (ssget ":L" '((0 . "LINE"))))
    (repeat (setq i (sslength ss))
      (setq en (ssname ss (setq i (1- i)))
	    ed (entget en)
	    x nil y nil)
      (if (or (and (> 1. (abs (- (cadr (assoc 10 ed)) (cadr (assoc 11 ed)))))
		   (setq x (/ (+ (cadr (assoc 10 ed)) (cadr (assoc 11 ed))) 2)))
	      (and (> 1. (abs (- (caddr (assoc 10 ed)) (caddr (assoc 11 ed)))))
		   (setq y (/ (+ (caddr (assoc 10 ed)) (caddr (assoc 11 ed))) 2))))
	(entmod (append ed
			(list (mapcar (function (lambda (a r) (if r r a))) (assoc 10 ed) (list nil x y nil))
			      (mapcar (function (lambda (a r) (if r r a))) (assoc 11 ed) (list nil x y nil))))))))
  (princ)
  )
0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

You may be able to use LinesRegularizeAngles.lsp with its LRA command, available >here<.  There are several other offerings on that same thread.

Kent Cooper, AIA
0 Likes