See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Multiple block insertion lisp?

  1. #1
    100 Club
    Join Date
    2015-11
    Location
    Cincinnati, Ohio
    Posts
    173
    Login to Give a bone
    0

    Default Multiple block insertion lisp?

    Does any know of a lisp that will insert one block multiple times at the mid point of every line in a drawing. (for example)

  2. #2
    100 Club
    Join Date
    2012-08
    Posts
    111
    Login to Give a bone
    1

    Default Re: Multiple block insertion lisp?

    Quote Originally Posted by jdcincy View Post
    Does any know of a lisp that will insert one block multiple times at the mid point of every line in a drawing. (for example)
    I have a lisp that insert blocks at the end point of every line in a drawing.
    Maybe it can help you.

    Thank you Lee Mac.

    File Attached
    PtManagerV2-4.lsp

  3. #3
    100 Club
    Join Date
    2015-11
    Location
    Cincinnati, Ohio
    Posts
    173
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    Could it be changed to midpoint? I would like to check it out. Thanks Billy

  4. #4
    100 Club
    Join Date
    2012-08
    Posts
    111
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    Quote Originally Posted by jdcincy View Post
    Could it be changed to midpoint? I would like to check it out. Thanks Billy
    Sorry jdcincy, but I don't know how to do that.
    Perhaps if you ask nicely, some gurus here can help you.

    Regards

  5. #5
    100 Club
    Join Date
    2012-08
    Posts
    111
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    Here an alternative code.

    I tried to to keep it simple and not combine to many commands to make it easy to follow along.

    You can also modify the program to add multiple lines to a selection set and then do the insert instead of one at a time.
    Code:
    ;;; BLI.lsp
    ;;;
    ;;; Purpose: To insert a block on a midpoint of a line.
    (defun C:BLI ()
     (setq ENT NIL)
     (setq PIC_ENT NIL)
     (setq BLOCK_TO_INSERT "C:\Users\Owner\Desktop\CROQUI\ST.dwg"); insert the path where your block is
     (setq BSCALEFACTOR 0.5)
     (while (null ENT)
      (setq PIC_ENT (entsel "\n Select Line To Insert Block To: "))
      (if (= PIC_ENT NIL)
       (progn
        (princ)
        (exit)
       )
      )
      (setq ENT (entget (car PIC_ENT)))
      (if (= "LINE" (cdr (assoc 0 ENT)))
       (progn
        (setq PT1 (cdr (assoc 10 ENT))) ; get start point of line
        (setq PT2 (cdr (assoc 11 ENT))) ; get endpoint of line
        (setq RANGLE (angle PT1 PT2)) ; get angle of line
        (setq DANGLE (RTD RANGLE)) ; convert angle radians to deg
        (setq LLINE (distance PT1 PT2)) ; gets length of line
        (setq HOFLINE (/ LLINE 2)) ; lengh of line divided by 2
        (setq INSERTPT (polar PT1 RANGLE HOFLINE))  ; set block insertion point
        (command "-insert"    "ST"  INSERTPT
             BSCALEFACTOR   BSCALEFACTOR   DANGLE
            ); the name of your block
        (setq ENT NIL)
        (setq PIC_ENT NIL)
       )
       (progn
        (princ "\n *** You need to select a line! ")
        (setq ENT NIL)
       )
      )
     )
    )
    ;;; RTD
    ;;; ---
    ;;; Convert radians to degrees
    (defun RTD (A) (* A (/ 180 pi)))
    (princ "\n BLI.slp loaded!  Type BLI to start!")
    (princ)
    HTH
    Last edited by BILLYJOW; 2012-12-05 at 07:28 PM.

  6. #6
    100 Club
    Join Date
    2015-11
    Location
    Cincinnati, Ohio
    Posts
    173
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    lol,,,,Im still trying to understand how to make the first lisp work correctly.

    Ive got the block inserting to all points in the drawing but still looking for a way to get it to go to end points of lines. Ill check out this other lisp in a min. thanks for all your help billy.

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Multiple block insertion lisp?

    Try this ...

    Code:
    (defun c:Mins (/ name ss i e)
      (if
        (and (or (/= (setq name (getstring t "\n Specify Block name :")) "")
                 (/= name nil)
             )
             (if (not (tblsearch "BLOCK" name))
               (progn
                 (alert " name of Block is not found !!")
                 nil
               )
               t
             )
             (progn (prompt "\n Select lines ...")
                    (setq ss (ssget '((0 . "LINE"))))
             )
        )
         (repeat (setq i (sslength ss))
           (setq e (entget (ssname ss (setq i (1- i)))))
           (entmakex
             (list '(0 . "INSERT")
                   (cons 10
                         (mapcar (function (lambda (q p) (/ (+ q p) 2.)))
                                 (cdr (assoc 10 e))
                                 (cdr (assoc 11 e))
                         )
                   )
                   (cons 2 name)
                   '(41 . 1.0)
                   '(42 . 1.0)
                   '(43 . 1.0)
             )
           )
         )
         (princ)
      )
      (princ)
    )

  8. #8
    100 Club
    Join Date
    2015-11
    Location
    Cincinnati, Ohio
    Posts
    173
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    lol,,,,that is cool tharwat!!! The only thing that could make that lisp better is if the block would align with the line. thank you

  9. #9
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    Quote Originally Posted by jdcincy View Post
    lol,,,,that is cool tharwat!!! The only thing that could make that lisp better is if the block would align with the line. thank you
    Like this .... ?

    Code:
    (defun c:Mins (/ name ss i e p1 p2)
      (if
        (and (or (/= (setq name (getstring t "\n Specify Block name :")) "")
                 (/= name nil)
             )
             (if (not (tblsearch "BLOCK" name))
               (progn
                 (alert " name of Block is not found !!")
                 nil
               )
               t
             )
             (progn (prompt "\n Select lines ...")
                    (setq ss (ssget '((0 . "LINE"))))
             )
        )
         (repeat (setq i (sslength ss))
           (setq e (entget (ssname ss (setq i (1- i)))))
           (entmakex
             (list '(0 . "INSERT")
                   (cons 10
                         (mapcar (function (lambda (q p) (/ (+ q p) 2.)))
                                 (setq p1 (cdr (assoc 10 e)))
                                 (setq p2 (cdr (assoc 11 e)))
                         )
                   )
                   (cons 2 name)
                   (cons 50 (angle p1 p2))
                   '(41 . 1.0)
                   '(42 . 1.0)
                   '(43 . 1.0)
             )
           )
         )
         (princ)
      )
      (princ)
    )

  10. #10
    100 Club
    Join Date
    2015-11
    Location
    Cincinnati, Ohio
    Posts
    173
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    That is bad a**. lol Very cool. I wish I could write lisps like that. I will have to watch how I draw my lines so the block will rotate the correct direction. Again very cool lisp. thank you

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 16
    Last Post: 2013-11-29, 07:11 PM
  2. Dynamic Block Insertion lisp
    By LSElite in forum AutoLISP
    Replies: 2
    Last Post: 2012-11-28, 02:28 AM
  3. Create a dynamic block with multiple insertion points
    By danielk in forum Dynamic Blocks - Technical
    Replies: 18
    Last Post: 2012-09-07, 08:38 AM
  4. Multiple block insertion with a script to redefine existing blocks?
    By drafterjohn in forum AutoCAD Customization
    Replies: 5
    Last Post: 2009-08-10, 01:52 PM
  5. Is it possible for a Dynamic Block to have multiple Insertion Points
    By TerribleTim in forum Dynamic Blocks - Technical
    Replies: 10
    Last Post: 2007-06-16, 10:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •