See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Insert Block on Multiple Circles (Circle Center Point)

  1. #1
    Member
    Join Date
    2013-02
    Posts
    49
    Login to Give a bone
    0

    Default Insert Block on Multiple Circles (Circle Center Point)

    Hi All,

    Could anyone help me create a LISP for Inserting Block on Multiple Circles (Circle Center Point).

    Note:

    Insertion of a Block to Circle Center Point

    Thank you in advance.

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

    Default Re: Insert Block on Multiple Circles (Circle Center Point)

    Hi,
    Add your block name in the program below as indicated in the codes and this should work with regular blocks and not with attributed blocks, because attributed blocks require more codes to fill out the values based on the blocks' settings.

    Code:
    (defun c:Test (/ int sel ent bkn)
      ;;----------------------------------------------------;;
      ;;	Author : Tharwat Al Choufi			;;
      ;; website: https://autolispprograms.wordpress.com	;;
      ;;----------------------------------------------------;;
    
      (setq bkn "MyBlock") ;; Replace MyBlock with your correct name.
    
      (and (or (tblsearch "BLOCK" bkn)
               (alert (strcat "Block Name < " bkn " > was not found !"))
           )
           (princ (strcat "\nSelect circles to position < "
                          bkn
                          " > over them : "
                  )
           )
           (setq int -1
                 sel (ssget '((0 . "CIRCLE")))
           )
           (while (setq int (1+ int)
                        ent (ssname sel int)
                  )
             (entmake (list '(0 . "INSERT")
                            (cons 2 bkn)
                            (assoc 10 (entget ent))
                            '(41 . 1.0)
                            '(42 . 1.0)
                            '(43 . 1.0)
                      )
             )
           )
      )
      (princ)
    )

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Insert Block on Multiple Circles (Circle Center Point)

    More structured code using ActiveX and only copying (instead of inserting) selected block without keyboard entry.

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function to Copy a block on centers of selection set of circles
    ;___________________________________________________________________________________________________________|
    
    (defun C:BOC ()(C:BlockOnCircle))
    
    (defun C:BlockOnCircle (/ lstCircleObjects objBlock ssBlock ssCircles)
     (if (and (princ "\nSelect Block: ")
              (setq ssBlock    (ssget ":S:E"  (list (cons 0 "insert"))))
              (setq objBlock          (car (SelectionSetToList ssBlock)))
              (princ "\nSelect Circles: ")
              (setq ssCircles  (ssget  (list (cons 0 "circle"))))
              (setq lstCircleObjects  (SelectionSetToList ssCircles))
     
         )
      (CopyBlockToCircleCenters objBlock lstCircleObjects)
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to Copy a block only centers of a list of circles objects using activeX
    ;___________________________________________________________________________________________________________|
    
    (defun CopyBlockToCircleCenters (objBlock lstCircleObjects / lstCircleObjects lstInsertionPoint objCircle )
     (if (setq lstInsertionPoint (vlax-get objBlock "insertionpoint"))               
      (foreach objCircle lstCircleObjects
       (setq lstCircleCenterPoint (vlax-get objCircle "center"))
       (setq objBlockNew (vlax-invoke objBlock "copy"))
       (vlax-invoke objBlockNew "move" lstInsertionPoint lstCircleCenterPoint)
      )
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to convert a lisp selection set to a list of vla objects
    ;___________________________________________________________________________________________________________|
    
    (defun SelectionSetToList (ssSelections / entSelection intCount lstObjects objSelection )
     (repeat (setq intCount (sslength ssSelections))
      (and
       (setq intCount     (1- intCount))
       (setq entSelection (ssname ssSelections intCount))
       (setq objSelection (vlax-ename->vla-object entSelection))
       (setq lstObjects   (cons objSelection lstObjects))
      )
     )
     (reverse lstObjects)
    )
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2024-03-13 at 03:23 PM.
    AutomateCAD

  4. #4
    Member
    Join Date
    2013-02
    Posts
    49
    Login to Give a bone
    0

    Default Re: Insert Block on Multiple Circles (Circle Center Point)

    Hi Peter

    This is exactly what I needed.

    Thank you for always spending time to help!

    Regards

    - - - Updated - - -

    Hi Tharwat

    I got what I'm needed but I always appreciated the time you spend to help me.

    Regards

  5. #5
    Woo! Hoo! my 1st post
    Join Date
    2024-03
    Posts
    1
    Login to Give a bone
    0

    Default Re: Insert Block on Multiple Circles (Circle Center Point)

    Thank you

  6. #6
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Insert Block on Multiple Circles (Circle Center Point)

    @peter Please check it, from your post.

    ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
    ;;************************************************************************************************************
    ;;----------------------------------------------------------------------;;
    ;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA
    ;;; Copyleft 1995-2024 by Gabriel Calos De Vit ; DEVITG@GMAIL.COM
    ;;

    ; Hecho por Gabo CALOS DE VIT de CORDOBA ARGENTINA
    ;;; Copyleft 1995-2024 por Gabriel Calos De Vit
    ;; DEVITG@GMAIL.COM
    ;;; inicio-defun-12-03-2024

    ;;;;-*******************************************************************************************************************************



    (defun blk-@-circle-center (/ ACAD-OBJ
    ADOC CIRCLE-CENTER
    LSTCIRCLEOBJECTS
    OBJBLOCK OBJBLOCK-CPY
    OBJBLOCK-CPY-CTR
    SSBLOCK SSCIRCLES ;_ end of ACAD-OBJ
    )
    (VL-LOAD-COM)
    (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ el programa ACAD
    (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ el DWG que esta abierto-
    ;; By PETER at Augi forum
    (if (and (princ "\nSelect Block: ")
    (setq ssBlock (ssget ":S:E" (list (cons 0 "insert"))))
    (setq objBlock (vla-item (VLA-GET-ACTIVESELECTIONSET adoc) 0))
    (princ "\nSelect Circles: ")
    (setq ssCircles (ssget (list (cons 0 "circle"))))
    (setq lstCircleObjects (VLA-GET-ACTIVESELECTIONSET adoc))
    ) ;_ end of and
    (princ)
    ) ;_ end of if
    ;;https://forums.augi.com/showthread.p...-Center-Point)
    (vlax-for Circle-Obj lstCircleObjects
    (setq circle-center (VLA-GET-CENTER Circle-Obj))
    (setq objBlock-cpy (VLA-COPY objBlock))
    (setq objBlock-cpy-ctr (VLA-GET-INSERTIONPOINT objBlock-cpy))
    (vla-Move objBlock-cpy objBlock-cpy-ctr circle-center)
    ) ;_ end of vlax-for
    ) ;_ end of defun

    (defun C:blk@circ ()

    (blk-@-circle-center)

    )
    Thanks for your part
    Attached Files Attached Files

Similar Threads

  1. Replies: 6
    Last Post: 2016-11-04, 03:11 PM
  2. CV12-4: One Point, Two Point, Red Point, Blue Point
    By Autodesk University in forum Civil Infrastructure
    Replies: 0
    Last Post: 2013-04-17, 04:50 AM
  3. 2013: Aligning center point of circle and changing its radius
    By engamrsalah in forum Revit Architecture - Families
    Replies: 7
    Last Post: 2013-01-29, 05:10 PM
  4. circles within circles...
    By IamMichaelPacker747327 in forum AutoCAD General
    Replies: 9
    Last Post: 2012-04-30, 08:03 PM
  5. Replies: 10
    Last Post: 2007-03-23, 01:50 AM

Posting Permissions

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