Juergen Posted December 6, 2022 Posted December 6, 2022 Hi, I have closed polylines that are close together. Is there a way with a short lisp to distribute them? Thanks for help. example.dwg Quote
mhupp Posted December 6, 2022 Posted December 6, 2022 This will space things left to right as long as they are all in the positive x and y cords Select one row at a time. ;;----------------------------------------------------------------------------;; ;; Move Poly to line and in order (defun C:MP (/ SS poly obj LL UR L&W lst BP x ) (vl-load-com) (if (setq SS (ssget)) (progn (foreach poly (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-getboundingbox (setq obj (vlax-ename->vla-object poly)) 'minpt 'maxpt) (setq LL (vlax-safearray->list minpt) UR (vlax-safearray->list maxpt) L&W (mapcar '- UR LL) ) (setq lst (cons (list obj LL (car L&W)) lst)) ) (setq lst (vl-sort lst '(lambda (a b) (< (distance '(0 0 0) (cadr a)) (distance '(0 0 0) (cadr b)))))) ;sorts left to right (setq BP (cadr (car lst))) ;(setq BP (getpoint "\nPick Point")) ;use if you want to pick a spot (setq dist (getdist "\nSpacing: ")) (foreach ent lst (vla-move (car ent) (cadr ent) BP) (setq BP (polar BP 0 (+ (caddr ent) dist))) ) ) ) (princ) ) Quote
Juergen Posted December 7, 2022 Author Posted December 7, 2022 Hi mhupp, thanks for the program. I get the following message: error: no conversion of the lisp value to VARIANT with the following type: (0.0 0.0 0.0) I select the objects Pick Point: I click a point in the drawing Spacing: I write e.g. 1000 Quote
mhupp Posted December 7, 2022 Posted December 7, 2022 Every thing is working on this end If your picking a point and spacing sounds like the error is with the vla-move Using (command for move instead ;;----------------------------------------------------------------------------;; ;; Move Poly to line and in order (defun C:MP (/ SS poly obj LL UR L&W lst BP x ) (vl-load-com) (if (setq SS (ssget)) (progn (foreach poly (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-getboundingbox (vlax-ename->vla-object poly) 'minpt 'maxpt) (setq LL (vlax-safearray->list minpt) UR (vlax-safearray->list maxpt) L&W (mapcar '- UR LL) ) (setq lst (cons (list poly LL (car L&W)) lst)) ) (setq lst (vl-sort lst '(lambda (a b) (< (distance '(0 0 0) (cadr a)) (distance '(0 0 0) (cadr b)))))) ;sorts left to right ;(setq BP (cadr (car lst))) (setq BP (getpoint "\nPick Point: ")) ;use if you want to pick a spot (setq dist (getdist "\nSpacing: ")) (foreach ent lst ;(vla-move (car ent) (cadr ent) BP) ;error maybe? (command "_.Move" (car ent) "" "_non" (cadr ent) "_non" BP) (setq BP (polar BP 0 (+ (caddr ent) dist))) ) ) ) (princ) ) Quote
Juergen Posted December 7, 2022 Author Posted December 7, 2022 Hi mhupp, it work´s very fine. Thank for your help. 1 Quote
Juergen Posted February 23, 2023 Author Posted February 23, 2023 Hi, is it possible to distribute the rectangle with contents (e.g. cirles, lines, polyline,..) in them? Thanks. example4.dwg Quote
BIGAL Posted February 23, 2023 Posted February 23, 2023 Yes Needs more code as needs two steps select plines and work out spacing order, as per Mhupp code, then reslect pline and select what is inside it, then move. Like everyone need some time Mhupp may answer sooner. Quote
devitg Posted February 28, 2023 Posted February 28, 2023 On 2/23/2023 at 3:01 AM, Juergen said: Hi, is it possible to distribute the rectangle with contents (e.g. cirles, lines, polyline,..) in them? Thanks. example4.dwg 63.45 kB · 4 downloads Shall I guess this way ? Quote
Juergen Posted February 28, 2023 Author Posted February 28, 2023 Hi devitg, yes, you are in the right assumption. Quote
Juergen Posted March 1, 2023 Author Posted March 1, 2023 The circles etc should be moved with the polylines. It should all be together. Quote
ronjonp Posted March 1, 2023 Posted March 1, 2023 36 minutes ago, Juergen said: The circles etc should be moved with the polylines. It should all be together. Why are you doing this? And .. if you really need to do this why is it not more organized as blocks ? Quote
Juergen Posted March 1, 2023 Author Posted March 1, 2023 I get the drawing sent to me like this, everything is coherent here. It's easier for me to edit when everything is distributed. If I have to select everything individually, I can move the selection right away. Is there a way that I select everything and a block is created for each closed polyline? Quote
devitg Posted March 1, 2023 Posted March 1, 2023 7 hours ago, Juergen said: I get the drawing sent to me like this, everything is coherent here. It's easier for me to edit when everything is distributed. If I have to select everything individually, I can move the selection right away. Is there a way that I select everything and a block is created for each closed polyline? You can do a ZOOM Object, and scale to 0.9X for each poly , then edit as need Quote
BIGAL Posted March 2, 2023 Posted March 2, 2023 (edited) Devitg is on right path, for simplicity I would use a SSGET "F" option so pline order is recorded saves all the sorting of X & y etc. I would also copy rather than move helps if things go wrong. Note not sure why but my Bricscad does the ssget F backwards. ; very simple copy plines and whats inside to right ; By AlanH March 2023 (defun c:wow2 ( / pt1 pt2 ss ss2 x dist oldsnap) (setq dist (getdist "\nEnter distance X ")) (setq dist2 (- (getdist "\nEnter distance y "))) (setq d2 dist y 0.0) (while (setq pt1 (getpoint "\nPick 1st point Enter to exit ")) (setq pt2 (getpoint pt1 "\nPick point 2 ")) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq x 0) (setq ss (ssget "F" (list pt1 pt2) '((0 . "LWPOLYLINE")))) (if (= ss nil) (alert "No objects found") (repeat (sslength ss) (setq plent (ssname ss x)) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq co-ord (cons (last co-ord) co-ord)) ; make a closed list (setq ss2 (ssget "wP" co-ord)) (if (= ss2 nil) (setq ss2 (ssadd))) (setq ss2 (ssadd plent ss2)) (setq x (1+ x) d2 (* x d2)) (command "copy" ss2 "" "0,0" (list d2 Y)) (setq ss2 nil) ) ) (setq d2 dist) (setq y (+ Y dist2)) ) (setvar 'osmode oldsnap) (princ) ) (c:wow2) For repeated use can put the get pt1 inside a while so pick more. I used pick left to right. Probably needs a bit more enhancing. Edited March 10, 2023 by BIGAL 1 Quote
Juergen Posted March 2, 2023 Author Posted March 2, 2023 Hi Bigal, i tried to use your lisp. I mark everything and click the 1st point then the 2nd point but I get the message no objects found. What am I doing wrong? Quote
BIGAL Posted March 2, 2023 Posted March 2, 2023 Checked again code is working the outlines must be individual plines, if they are lines will not work. Your words for each closed polyline Quote
Juergen Posted March 2, 2023 Author Posted March 2, 2023 I get following info from the command line: Pick 1st point Pick point 2 Application ERROR: SSGET W/C requires two points Quote
BIGAL Posted March 2, 2023 Posted March 2, 2023 (edited) Post the dwg so can test and see what is going on. Are they 3d plines ? Edited March 2, 2023 by BIGAL Quote
Juergen Posted March 3, 2023 Author Posted March 3, 2023 Hi Bigal, here my drawing. drawing.dwg Quote
BIGAL Posted March 5, 2023 Posted March 5, 2023 Found the problem I looked for objects inside if none it did not like it so download new version above and let me know. 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.