Jump to content

LISP to copy Polylines with certain points fixed (kind of strech-copy)


heschr

Recommended Posts

Hello,

 

after reading along for quite some time (and profiting alot), here comes my first post:

I needed a routine to create a lot of polylines with all the same starting point. I got tired of always have to move the first point back to the right starting point.

 

Here is my solution, kind of an copy-strech mix. Could this be achieved in a more elegant way?

 

 


(defun c:cfp ( / i ss plist_o ss_n elist_t plist_t pcount bpoint) 

(vl-load-com)

 ;get points of original polyline

(setq 
   ss (car(entsel "\nSelect Polyline to copy.")) 
   plist_o (vl-remove-if-not
     (function (lambda (pt) (= (car pt) 10)))
     (entget ss)
             )
)

 ;get userinput on how many points should be fixed and basepoint for multiple copies
 
(initget 4)
(setq 
 pcount (getint "\nHow many points should be fixed? <1>"))
 (if (= pcount nil) (setq pcount 1)) 
 (setq bpoint (getpoint "\nSelect basepoint"))
 (while (not nil)

 ;perform copy and get the points of the temporal polyline
 
(command "_copy" ss "" bpoint pause)

 (setq 
   ss_n (entlast)
   elist_t (entget ss_n)
   plist_t (vl-remove-if-not
               (function (lambda (pt) (= (car pt) 10)))
               (entget ss_n)
            )
  )

 ;change the fixed points of the temporal polyline back to the 
 ;original points and draw the final polyline
 
(setq i 0)
(repeat pcount
   (setq elist_t
     (subst
       (nth i plist_o)
       (nth i plist_t)
       elist_t
     )
  )
  (setq i (1+ i))
)
 
(entmod elist_t)
 )
)

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...