Arrange Drawing

Arrange Drawing

Anonymous
Not applicable
1,190 Views
10 Replies
Message 1 of 11

Arrange Drawing

Anonymous
Not applicable

i have to arrange drawing specific "X" and "Y" distance. Please help this topic

 

Thank you in advance.

0 Likes
1,191 Views
10 Replies
Replies (10)
Message 2 of 11

SeeMSixty7
Advisor
Advisor

It looks like your drawings have some typical elements to make it possible.

 

I would create a lisp routine to grab each of the areas you wish to arrange. Luckily they all use a PLINE border on the OUTLINE layer.

 

Grab all of those using

(setq (ssget "X" '((0 . "LWPOLYLINE")(8 . "OUTLINE"))))

 

then loop through the pline selection set, use the pline points as a window crossing or some form to make a selection set. Move that set to position 1. Then use the extents of that selection set to establish your 2000 unit offsets and systematically move each set to their new location. If you are moving them to locations that may overlap each other be sure and keep track of all entities or move them out of range of that happening.

 

Hope that helps get you going.

 

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Dear sir,

      According to customer needs, we are submitted drawing into systematically.
I don't know much about coding autolisp. Therefore if possible you please Lisp file.

 

sorry for my bad english.

0 Likes
Message 4 of 11

SeeMSixty7
Advisor
Advisor

I was offering some advice on how to automate the process using autolisp. Since that is not something you are versed in, not to worry.

 

Using just good old fashion AutoCAD commands you can accomplish the same thing.

 

Since you apparently already know the size of each polyline set of entities, start by creating a grid of lines.

 

Draw a vertical line from 0,0,0 Straight up to say 0,10000

LINE[Enter]

0,0,0[Enter]

@5000<90[Enter]

[Enter]

 

Next use the offset command

Offset[Enter]

4503.58171203[Enter]

[Pick the line we just drew and offset it to the right then repeat the process until you have however many horizontal instance you will need.

 

Then create the horizontal lines of your grid.

LINE[Enter]

0,0,0[Enter]

PER[Enter] Pick the last line you offset in the previous step

[Enter]

 

Then offset that line as needed

Offset[Enter]

3230.42834255[Enter]

[Select line drawn in previous step and offset up, repeat as often as needed]

 

Then just use the good ole move command to grab the contents of each drawing use the lower left base point and then pick your first location of 0,0,0

 

Repeat the process until you are done using the line intersections on the grid you created to place each one.

 

Hope that helps you get going. Over all it should only take a couple of minutes to format the drawing contents that you have to the desired arrangement.

 

 

 

0 Likes
Message 5 of 11

Anonymous
Not applicable

Hi,

 

this is code arrange X, i think similar X, Y

 

(defun c:test (/ ss cnt vlist vlist1 rec_1 rec_2 pt1_1 pt1_3 pt2_1 pt2_3 pt)
  (command "-layer" "unlock" "*" "")
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (8 . "OUTLINE"))))
    (progn
      (setq ss (sort_x ss))
      (setq cnt 0)
      (repeat (- (length ss) 1)
	(setq vlist nil vlist1 nil ssm nil)
	(setq rec_1 (nth cnt ss))
	(setq rec_2 (nth (1+ cnt) ss))

	(setq vlist (mAssoc 10 (entget rec_1)))
	(setq pt1_1 (append (car vlist) (list 0.0)))
	(setq pt1_3 (append (car (cdr (cdr vlist))) (list 0.0)))

	(setq vlist1 (mAssoc 10 (entget rec_2)))
	(setq pt2_1 (append (car vlist1) (list 0.0)))
	(setq pt2_3 (append (car (cdr (cdr vlist1))) (list 0.0)))

	(setq pt (polar pt1_1 0. 4500.)) ; 4.71239 2000.))
	(setq pt (append (list (car pt) (cadr pt) 0.0)))
	
	(setq ssm (ssget "_C" pt2_3 pt2_1))
	
	(command "_move" ssm "" "_non" pt2_1 "_non" pt)
	
	(setq cnt (1+ cnt))
	
      )

    )
  )
)
(defun sort_x (ss / n ss1)
  (setq n 0)
  (repeat (sslength ss)
    (setq ss1 (append ss1 (list (ssname ss n))))
    (setq n (1+ n))
  )					;repeat
  (setq	ss1 (vl-sort ss1
		     '(lambda (e1 e2)
			(< (car (cdr (assoc 10 (entget e1))))
			   (car (cdr (assoc 10 (entget e2))))
			)
		      )
	    )
  )					;setq
)
(defun mAssoc (key lst)
  (setq l nil)
  (foreach x lst
    (if	(= key (car x))
      (setq l (cons (cdr x) l))
    )
  )
  (reverse l)

You can modify ^_^

 

 

Message 6 of 11

ВeekeeCZ
Consultant
Consultant

Nice work @Anonymous!

 

By copy-paste job you have lost the last parenthesis.

 

I run the the on the sample file... One issue I see... see SCREENCAST

 

@Anonymous just move a first drawing in some free space... now positions of drawing can't cover the current ones at any time.

Message 7 of 11

Anonymous
Not applicable

HI BeekeeCZ,

 

I was not test all. Thanks for point me.

 

1 question: what is the error "SCREENCAST." ?

0 Likes
Message 8 of 11

ВeekeeCZ
Consultant
Consultant

gametv.himo wrote:

... 

1 question: what is the error "SCREENCAST." ?


No error. Just a screen capture. Click on it!

 

Screencast is the AutoDESK's tool for screen capturing, available HERE

 

Cheers!

0 Likes
Message 9 of 11

Anonymous
Not applicable

Okey, BeekeeCZ. Smiley Very Happy

0 Likes
Message 10 of 11

Anonymous
Not applicable

Thank you sir excellent work.

Can you add options manually input of spacing "X", spacing "Y" and no of column grid.

 

sorry for my bad english.

0 Likes
Message 11 of 11

Anonymous
Not applicable

I don't understand,

but this is code exactly Post 1: (see attached file number layout)

(defun c:arrangementXY (/ ss vlist rec_1 rec_2 pt1_1 pt1_3 pt1 pt2 lst)
  (command "-layer" "unlock" "*" "")
  (if (setq ss (ssget '((0 . "LWPOLYLINE") (8 . "OUTLINE"))))
    (progn
      (setq ss (sort_x ss))
      (setq
	pt1_1 (append (car (mAssoc 10 (entget (car ss)))) (list 0.0))
      )
      (setq pt1 (polar pt1_1 pi 4500.))

      (setq pt2 (polar pt1 4.71239 3200.))
      (if (= (rem (length ss) 2) 0)	; if NUMBER is even
	(progn
	  (move_obj ss pt1 pt2)
	)				;progn then
	(progn				;NUMBER is odd
	  (setq lst (move_obj ss pt1 pt2))
	  (setq pt1 (car lst))
	  (setq pt2 (cadr lst))
	  (setq vlist (mAssoc 10 (entget (car (reverse ss)))))
	  (setq pt1_1 (append (car vlist) (list 0.0)))
	  (setq pt1_3 (append (car (cdr (cdr vlist))) (list 0.0)))
	  (command "_move" "_C"	pt1_3 pt1_1 "" "_non" pt1_1 "_non" pt1)
	)				;progn else
      )					;if number even or odd

    )					;progn ss
  )					;if ss
  (princ)
)

(defun move_obj	(lst_ent pt1	 pt2	 /	 cnt	 vlist
		 vlist1	 rec_1	 rec_2	 pt1_1	 pt1_3	 pt2_1
		 pt2_3	 pt1	 pt2
		)
  (setq cnt 0)
  (repeat (- (- (length ss) 1) (/ (- (length ss) 1) 2))
    (setq vlist	nil
	  vlist1 nil
    )
    (setq rec_1 (nth cnt lst_ent))
    (setq rec_2 (nth (1+ cnt) lst_ent))

    (setq vlist (mAssoc 10 (entget rec_1)))
    (setq pt1_1 (append (car vlist) (list 0.0)))
    (setq pt1_3 (append (car (cdr (cdr vlist))) (list 0.0)))


    (setq vlist1 (mAssoc 10 (entget rec_2)))
    (setq pt2_1 (append (car vlist1) (list 0.0)))
    (setq pt2_3 (append (car (cdr (cdr vlist1))) (list 0.0)))

    (command "_move" "_C" pt1_3	pt1_1 "" "_non"	pt1_1 "_non" pt1)

    (command "_move" "_C" pt2_3	pt2_1 "" "_non"	pt2_1 "_non" pt2)

    (setq pt1 (polar pt1 0. 4500.))
    (setq pt2 (polar pt1 4.71239 3200.))
    (setq cnt (+ cnt 2))
  )					;repeat
  (list pt1 pt2)
)					;defun
(defun sort_x (ss / n ss1)
  (setq n 0)
  (repeat (sslength ss)
    (setq ss1 (append ss1 (list (ssname ss n))))
    (setq n (1+ n))
  )					;repeat
  (setq	ss1 (vl-sort ss1
		     '(lambda (e1 e2)
			(< (car (cdr (assoc 10 (entget e1))))
			   (car (cdr (assoc 10 (entget e2))))
			)
		      )
	    )
  )					;setq
)					;defun

;;;Found internet
(defun mAssoc (key lst)
  (setq l nil)
  (foreach x lst
    (if	(= key (car x))
      (setq l (cons (cdr x) l))
    )
  )
  (reverse l)
)					;defun

 

0 Likes