Results 1 to 6 of 6

Thread: Routine to delele all blocks outside closed polyline

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

    Default Routine to delele all blocks outside closed polyline

    Good day everyone!

    Could anyone help me find or create a routine to delete all blocks outside closed polyline.

    PS.
    Delete not trim.

    Thank you in advance

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

    Default Re: Routine to delele all blocks outside closed polyline

    Good day,

    Create a selection set of all closed polylines to select all blocks insides each closed polyline then create a selection set of all existed blocks in current space.

    The iterate through each block and check if it is already included within any of the selection set of the closed polylines, so if it is not there then delete it otherwise ignore it and continue.

  3. #3
    Member
    Join Date
    2013-02
    Posts
    44
    Login to Give a bone
    0

    Default Re: Routine to delele all blocks outside closed polyline

    Hi Tharwat

    Thanks for always accommodating my queries. Is there a LISP to select a closed polyline & it will automatically delete all blocks outside of it. I already have one for trimming but it doesn't works with blocks. Hope you could help on this. This will help me save a lot of time in my work. Thank you in advance.

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

    Default Re: Routine to delele all blocks outside closed polyline

    Hi,

    Give this a shot.
    Code:
    (defun c:Test (/ sel ent lst inc dis bks )
      ;;------------------------------------------------------------;;
      ;;	Author: Tharwat Al Choufi - Date: 31.Mar.2022		;;
      ;;	website: https://autolispprograms.wordpress.com		;;
      ;;------------------------------------------------------------;;
      (and (princ "\nSelect closed 2Dpolyline :")
           (or (setq sel (ssget "_+.:S:E" '((0 . "*POLYLINE") (-4 . "&=") (70 . 1))))
               (alert "Nothing selected or invalid object or polyline is not closed <!>")
               )
           (setq lst (vlax-curve-getdistatparam (setq ent (ssname sel 0)) (fix (vlax-curve-getendparam ent)))
                 inc (/ lst 1000.)
                 lst nil dis inc 
                 )
           (repeat 1000
             (setq lst (cons (vlax-curve-getpointatdist ent inc) lst)
                   inc (+ inc dis)
                   )
             )
           (or (setq sel (ssget "_WP" lst '((0 . "INSERT"))))
               (alert "Nothing selected or invalid object or polyline is not closed <!>")
               )
           (setq bks (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'CTAB)))))
           (repeat (setq inc (sslength bks))
             (setq inc (1- inc)
                   ent (ssname bks inc)
                   )
             (or (ssmemb ent sel) (entdel ent))
             )
           )         
      (princ)
    ) (vl-load-com)

  5. #5
    Member
    Join Date
    2013-02
    Posts
    44
    Login to Give a bone
    0

    Default Re: Routine to delele all blocks outside closed polyline

    Hi Tharwat,

    As always, thank you so much.

    This helps me a lot.

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

    Default Re: Routine to delele all blocks outside closed polyline

    You're welcome anytime,

Similar Threads

  1. Replies: 8
    Last Post: 2016-04-14, 11:18 AM
  2. Looking for routine...Polyline box around a polyline
    By iacevedo270202 in forum AutoLISP
    Replies: 4
    Last Post: 2011-04-06, 06:20 PM
  3. Quick adding of multiple closed polyline areas
    By CBLENDERMANN in forum AutoLISP
    Replies: 6
    Last Post: 2008-05-29, 04:21 PM
  4. Getting the centroid of closed polyline
    By csgohjmj in forum AutoLISP
    Replies: 24
    Last Post: 2004-10-15, 06:01 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
  •