Isaac26a Posted January 24, 2021 Posted January 24, 2021 Hello everyone, I was trying to find out a way to solve this task, that for many of you may be boring or simple, but I happen to deal with this from time to time, I have this texts or other objects that are in a rectangle and I have to copy this items in so many rectangles in order to continue with other tasks, as you may see in the pictures it can't be solved using an array because they're not all in the same size. I was thinking that a way to approach this matter is to create a selection set of the objects and a list of the polylines (rectangles) where I should copy the objects and do a loop with while, but how do I get to paste them in the lower right corner of every object if that is my reference point. I hope you can help me solve this matter or at least give me some hints or directions, thanks in advance to you all. example.dwg Quote
BIGAL Posted January 24, 2021 Posted January 24, 2021 (edited) Try this ; copy an object to multi rectangs ; based on Lower Right cnr of rectang ; By AlanH Jan 2021 (defun c:test ( / ss lst co-ord ent pt x ) (setq ss (ssget (list (cons 0 "LWpolyline")))) ; select all the rectangs 1st (setq lst '()) (repeat (setq x (sslength ss)) (setq ent (ssname ss (setq x (- x 1)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) (setq co-ord (vl-sort co-ord '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) )) (setq pt (list (car (nth 2 co-ord))(cadr (nth 2 co-ord)) 0.0)) (setq lst (cons pt lst)) ) (princ "\n") (princ "\nSelect objects to copy ") (setq ss (ssget)) ; select all the objects to copy (setq pt (getpoint "\nPick base point LR ? ")) (repeat (setq x (length lst)) (setq pt2 (nth (setq x (- x 1)) lst)) (command "copy" ss "" pt pt2) ) (princ) ) Edited January 25, 2021 by BIGAL 2 Quote
Isaac26a Posted January 25, 2021 Author Posted January 25, 2021 36 minutes ago, BIGAL said: Try this ; copy an object to multi rectangs ; based on Lower Right cnr of rectang ; By AlanH Jan 2021 (defun c:test ( / ss lst co-ord ent pt x ) (setq ss (ssget (list (cons 0 "LWpolyline")))) (setq lst '()) (repeat (setq x (sslength ss)) (setq ent (ssname ss (setq x (- x 1)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) (setq co-ord (vl-sort co-ord '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) )) (setq pt (list (car (nth 2 co-ord))(cadr (nth 2 co-ord)) 0.0)) (setq lst (cons pt lst)) ) (princ "\n") (princ "\nSelect objects to copy ") (setq ss (ssget)) (setq pt (getpoint "\nPick base point LR ? ")) (repeat (setq x (length lst)) (setq pt2 (nth (setq x (- x 1)) lst)) (command "copy" ss "" pt pt2) ) (princ) ) Hey man, I really appreciate your help, Thank you very much, It works perfectly. At the beginning I was expecting to select the objects to copy, but then I read the code and found out that you first ask for the objects where it's going to be copied. It does what was expected. Thanks again Alan Quote
BIGAL Posted January 25, 2021 Posted January 25, 2021 I am hoping to fix up problem of posting a movie to show how to use code. You can change the order if you want just make one of the selection sets say ss2 move the ssget to above the other asking in the order you want. Quote
Isaac26a Posted January 26, 2021 Author Posted January 26, 2021 2 hours ago, BIGAL said: I am hoping to fix up problem of posting a movie to show how to use code. You can change the order if you want just make one of the selection sets say ss2 move the ssget to above the other asking in the order you want. Really there's no need for that, I just didn't know how to indicate the bottom right corner of the list of objects, but you did all the solution. A really good one. Thanks, and you're right, just have to swap the order. Quote
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.