Jump to content

Help please in getting started.


Mark111

Recommended Posts

Hi All

 

Very new to wrighting lisp code.

Help please to get me going.

I'm trying to wright code to, multi copy/paste small block to the ends of vertical lines in single layer, in one go.(small block on different layer) Time saving, from having to paste each. There are alot of lines, not all same dimention between them or length!

eg. image row of fence posts dotted any where, want to fix box at top of posts.

would be nice to have an offset, and be able to pick the lines that would be copy/pasting too.

Can anyone help or have seen code that can do this?

 

cheers

Mark

Link to comment
Share on other sites

This does not take into account any LAYERs stuff. It just uses the current layer and assumes WCS inserts. Also it looks for LINEs only. No PLINEs -David

(defun c:lend2ins (/ bn ss i en ed p10 p11)

;;;FORCE BLOCK TABLE
(defun SetBlkTF (n)
(cond ((not (snvalid n))
       (princ "\nInvalid Block Name - " n)
       (setq n nil))
      ((tblsearch "BLOCK" n))
      ((findfile (strcat n ".DWG"))
       (command "_.INSERT" n)
       (command))
      (T
       (entmake (list (cons 0 "BLOCK")(cons 2 n)(cons 10 (list 0 0 0))(cons 70 0)))
       (entmake (list (cons 0 "TEXT")
                      (cons 1 (strcat "BLOCK PLACECARD - " n))
                      (cons 7 (cdr (assoc 2 (tblnext "STYLE" T))))
                      (cons 8 "0")
                      (cons 10 (list 0 0 0))
                      (cons 11 (list 0 0 0))
                      (cons 40 (max 1 (getvar "TEXTSIZE")))
                      (cons 72 4)))
       (entmake (list (cons 0 "ENDBLK")(cons 8 "0")))))
 n)

 (while (or (not bn)
            (not (SetBlkTF bn)))
         (setq bn (getstring "\nBLOCK To INSERT:   ")))

 (while (not ss)
        (princ "\nSelect Lines To INSERT BLOCK To:   ")
        (setq ss (ssget (list (cons 0 "LINE")
                              (if (getvar "CTAB")
                                  (cons 410 (getvar "CTAB"))
                                  (cons 67 (- 1 (getvar "TILEMODE"))))))))

 (setq i (sslength ss))
 (while (not (minusp (setq i (1- i))))
        (setq en (ssname ss i)
              ed (entget en )
             p10 (cdr (assoc 10 ed))
             p11 (cdr (assoc 11 ed)))
        (entmake (list (cons 0 "INSERT")(cons 2 bn)(cons 10 p10)
                       '(39 . 0)'(6 . "BYLAYER")'(62 . 256)))
        (entmake (list (cons 0 "INSERT")(cons 2 bn)(cons 10 p11)
                       '(39 . 0)'(6 . "BYLAYER")'(62 . 256))))

 (prin1))

Link to comment
Share on other sites

You're welcome. It is a slight modification to a program I already had to setup a camera view. -David.

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