Jump to content

Distribute closed polylines


Juergen

Recommended Posts

@Juergen

If you have a non-English version of Autocad, try internationalizing the commands in the code:
(setq ss (ssget "F" (list pt1 pt2)  '((0 . "LWPOLYLINE")))) -> (setq ss (ssget "_F" (list pt1 pt2)  '((0 . "LWPOLYLINE"))))

(setq ss2 (ssget "wP" co-ord)) -> (setq ss2 (ssget "_wP" co-ord))

(command "copy" ss2 "" "0,0" (list dist 0.0)) -> (command "_.copy" ss2 "" "0,0" (list dist 0.0))

Edited by Tsuky
Link to comment
Share on other sites

Hi Tsuky,

 

thanks for your help, it works! 😀

What is to add when I want a customer entry? "(setq x 0 dist 50.0) ; maybe add a enter dist"

 

And also a big thanks to Bigal.

Link to comment
Share on other sites

Replace

(setq x 0 dist 50.0) ; maybe add a enter dist

by

(setq x 0)
(initget 7)
(setq dist (getdist pt1 "\nDistance for copy?: "))

and

(setq x (1+ x) dist (+ 50 dist))

by

(setq x (1+ x) dist (+ dist dist))

 

Link to comment
Share on other sites

Not sure what happened I updated code but just had a look and it was wrong so updated again it has a while so can run multiple times. I know needs a Y offset if ran multi times. Not sure if needed.

 

(setq dist (getdist "\nEnter distance "))
(setq d2 dist)
(while (setq pt1 (getpoint "\nPick 1st point Enter to exit "))

 

Link to comment
Share on other sites

  • 2 months later...

Hi,

I use the code from AlanH.

Please see my image.

Is it possible to bring the objects in one line?

Thanks for help.

 

; very simple copy plines and whats inside to right
; By AlanH March 2023
(defun c:wow2 ( / pt1 pt2 ss ss2 x dist oldsnap)
(setq pt1 (getpoint "\Pick 1st point ") pt2 (getpoint pt1 "\nPick point 2 "))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq x 0)
(initget 7)
(setq dist (getdist pt1 "\nDistance for copy?: "))
(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))
  (setq ss2 (ssadd plent ss2))
   (command "_.move" ss2 "" "0,-20000" (list dist 0.0))
  (setq x (1+ x) dist (+ 2000 dist))
)
)
(setvar 'osmode oldsnap)
(princ)
)
(c:wow2)

 

image.jpg

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...