See the top rated post in this thread. Click here

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Multiple block insertion lisp?

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

    Default Re: Multiple block insertion lisp?

    You're very welcome John .

  2. #12
    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
    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
    Me too, john

    Tharwat you are awesome!!!

  3. #13
    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 BILLYJOW View Post
    Me too, john

    Tharwat you are awesome!!!
    It is very kind of you to say that .

    Thank you BILLYJOW

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

    Default Re: Multiple block insertion lisp?

    Tharwat,,,Could I bother you one more time?

    I have been trying to change your first lisp to insert blocks at points (or nodes). no rotation needed. I have failed over and over.

    If you have time could you try it out?

  5. #15
    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

    I have been trying to change your first lisp to insert blocks at points (or nodes). no rotation needed. I have failed over and over.
    UPDATED TO THE FOLLOWING POST
    Last edited by Tharwat; 2012-12-07 at 07:39 PM.

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

    Default Re: Multiple block insertion lisp?

    Alright thank you... I was making it to complicated.

  7. #17
    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
    Alright thank you... I was making it to complicated.
    I am sorry , I forgot to change a few lines of code because I forgot that the first routine insert a block on the center of the selected lines and with points the first insertion point is enough like this ...


    Code:
    (defun c:Test (/ 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 . "POINT"))))
             )
        )
         (repeat (setq i (sslength ss))
           (setq e (entget (ssname ss (setq i (1- i)))))
           (entmakex
             (list '(0 . "INSERT")
                   (assoc 10 e)
                   (cons 2 name)
                   '(41 . 1.0)
                   '(42 . 1.0)
                   '(43 . 1.0)
             )
           )
         )
         (princ)
      )
      (princ)
    )

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

    Default Re: Multiple block insertion lisp?

    I was so excited to start my new project yesterday because I knew I was going to get the chance to use this cool code you gave me. All I had to do was make sure I drew my lines correctly to get the block to insert and be rotated in the correct direction.

    I drew my grid and had all my framing drawn and now its time to insert my block and........What a messssss. Some of my lines where drawn from right to left and that caused my block to be upside down. Some of my vertical lines were drawn from top to bottom and my block inserted to right side of the line. See, I always want my block to either insert ABOVE the mid point of a horizontal line or to the LEFT side of a vertical line.

    So I think what I need to do is write some "if-then" into your code. (Sorry, I have no ideal what Im doing, I have this pamphlet called "AutoLisp Quick Start" a guide for lisp rookies)

    If the line is 180 degrees then rotate block 180 degrees

    if the line is 270 degrees then rotate block 180 degrees

    I dont know. I couldnt find my lisp a** with two hands. Tharwat if you have time could you help me right 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)
    )
    [/QUOTE]

  9. #19
    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
    If the line is 180 degrees then rotate block 180 degrees

    if the line is 270 degrees then rotate block 180 degrees
    Just replace the DXF 50 in the code as the following to match if the angle is equal either 180. or 270. put the angle 180. otherwise leave the angle value as it is .

    Code:
    (cons 50
          (if (or (eq (angle p1 p2) pi)
                  (eq (angle p1 p2) (* pi 1.5))
              )
            pi
            (angle p1 p2)
          )
    )
    Hope this helps with your request .

  10. #20
    Member
    Join Date
    2010-11
    Posts
    7
    Login to Give a bone
    0

    Default Re: Multiple block insertion lisp?

    Quote Originally Posted by Tharwat View Post
    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)
    )
    Hi tharwat,
    can I request you modify the code to add the blocks at start, end and mid of the lines.
    Also If you can get an option to ask the block for start, mid and end. As I have to insert 3 different blocks at each line.
    hope you understand my request..

Page 2 of 3 FirstFirst 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
  •