Jump to content

Insert a block at multiple points or lines and scale


grouch19

Recommended Posts

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • grouch19

    10

  • BIGAL

    7

  • Lee Mac

    2

  • eldon

    1

Top Posters In This Topic

Posted Images

  • 4 years later...

Dear Lee

when i run the code its showing

; error: extra cdrs in dotted pair on input

(defun c:insblk ( / blk cmd dwg ent enx idx lst scl sel )

   (setq blk "Manhole") ;; Block Name

   (cond
       (   (not
               (or (tblsearch "block" blk)
                   (and (setq dwg (findfile (strcat blk ".dwg")))
                       (progn
                           (setq cmd (getvar 'cmdecho))
                           (setvar 'cmdecho 0)
                           (command "_.-insert" dwg nil)
                           (setvar 'cmdecho cmd)
                           (tblsearch "block" blk)
                       )
                   )
               )
           )
           (princ (strcat "\nBlock \"" blk "\" not found or could not be defined."))
       )
       (   (setq sel (ssget "_:L" '((0 . "POLYLINE") (-4. "&=")(70 . (-4 . "<NOT")(-4 . "&=")(70 . 1)(-4 . "NOT>"))))
           (repeat (setq idx (sslength sel))
               (setq ent (entnext (ssname sel (setq idx (1- idx))))
                     enx (entget ent)
                     lst nil
               )
               (while (= "VERTEX" (cdr (assoc 0 enx)))
                   (setq lst (cons (cdr (assoc 10 enx)) lst)
                         ent (entnext ent)
                         enx (entget  ent)
                   )
               )
               (if (= 3 (length lst))
                   (progn
                       (if (apply '< (setq scl (mapcar 'distance lst (cdr lst))))
                           (setq lst (reverse lst)
                                 scl (reverse scl)
                           )
                       )
                       (if (minusp (sin (- (angle (car lst) (caddr lst)) (angle (car lst) (cadr lst)))))
                           (setq lst (vl-list* (cadr lst) (car lst) (cddr lst)))
                       )
                       (if (entmake
                               (list
                                  '(000 . "INSERT")
                                   (cons 002 blk)
                                   (cons 010 (car  lst))
                                   (cons 041 (car  scl))
                                   (cons 042 (cadr scl))
                                   (cons 050 (angle (car lst) (cadr lst)))
                               )
                           )
                           (entdel (ssname sel idx))
                       )
                   )
               )
           )
       )
   )
   (princ)
))

 

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