Results 1 to 5 of 5

Thread: DELETE BLOCK CODE HELP

  1. #1
    Active Member
    Join Date
    2013-03
    Location
    Permian Basin
    Posts
    76
    Login to Give a bone
    0

    Default DELETE BLOCK CODE HELP

    Can anybody edit this code to allow multiple selections and window selection?

    Code:
    (defun c:db (/ block ll ur objecttojoin)
          (vl-load-com)
          (setq block (car (entsel "\nSelect Block:")))
          (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
          (command "_.erase" block "")
          (setq objecttojoin
                     (ssget "C"
                            (vlax-safearray->list ll)
                            (vlax-safearray->list ur)))
          (command
                "_.join"
                (ssname objecttojoin 0)
                (ssname objecttojoin 1)
                "")
          )
    Last edited by BlackBox; 2013-11-13 at 05:27 PM. Reason: Please use [CODE] Tags

  2. #2
    Member
    Join Date
    2007-04
    Posts
    16
    Login to Give a bone
    0

    Default Re: DELETE BLOCK CODE HELP

    try this:

    Code:
    ;;;; JDiala 09-13-2013 ;;;;
    (defun C:test (/ ss i b)
    (if
      (and
        (setq ss (ssget '((0 . "INSERT,LINE"))))
    	(= 3 (sslength ss))
      )
      (progn
        (setq b t i 0)
        (while b
    	  (if (= "INSERT" (cdr (assoc 0 (entget (ssname ss i)))))
    	      (progn
    		    (entdel (ssname ss i))
    		    (ssdel (ssname ss i) ss)
    			(command "_.join" (ssname ss 0) (ssname ss 1) "")
    			(setq b nil)
    	      )
    		  (setq i (1+ i))
    	  )
    	)
      )
    )
    (princ)	  
    )

  3. #3
    Active Member
    Join Date
    2013-03
    Location
    Permian Basin
    Posts
    76
    Login to Give a bone
    0

    Default Re: DELETE BLOCK CODE HELP

    Thanks. This code allows for window selection but I still cant make it run on multiple blocks at a time. Any ideas?

  4. #4
    Active Member
    Join Date
    2013-07
    Posts
    66
    Login to Give a bone
    0

    Default Re: DELETE BLOCK CODE HELP

    Well jdiala put in a line of code
    Code:
    (= 3 (sslength ss))
    which means that if the selection set is equal to three objects that are either line or inserts, preform the following......
    I'm not sure if this would need to be modified to have the program run on more than 3 items, but i'd start there to find out...

  5. #5
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: DELETE BLOCK CODE HELP

    Quote Originally Posted by jayhay35365091 View Post
    Can anybody edit this code to allow multiple selections and window selection?
    Try this:
    Code:
    (Defun c:db ( / pea ss i ll ur objecttojoin)
      (setq pea (getvar 'Peditaccept))
      (setvar 'Peditaccept 1) 
          (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
              (repeat (setq i (sslength ss))
                  (vla-getboundingbox (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) 'll 'ur)
                  (vla-delete e)
              (if  (Setq objecttojoin (ssget "C"
                          (vlax-safearray->list ll)
                          (vlax-safearray->list ur) '((0 . "LWPOLYLINE,LINE"))
                       ))
                (command "_.pedit" "_M" objecttojoin "" "_J" "" "")
    
                  )
              )
          )
    (setvar 'Peditaccept pea)
      (princ)
      )
    But i would be better if you add the block name in the selection

    Code:
    (setq ss (ssget "_:L" '((0 . "INSERT")(2 . "Blockname"))))
    HTH
    Last edited by pbejse; 2013-11-14 at 01:21 AM.

Similar Threads

  1. delete elements outside a block
    By matthew.221135 in forum AutoCAD General
    Replies: 3
    Last Post: 2012-10-16, 07:09 AM
  2. Delete block
    By krkeec763189 in forum Dot Net API
    Replies: 3
    Last Post: 2011-12-19, 04:44 PM
  3. Delete Block LSP
    By 1966ford in forum AutoCAD Customization
    Replies: 1
    Last Post: 2011-02-03, 01:24 PM
  4. Block vs Xref: How to get the dxf code
    By piper in forum AutoLISP
    Replies: 12
    Last Post: 2007-07-03, 08:11 PM
  5. Can you delete a mask block?
    By bercherdbrc138323 in forum ACA General
    Replies: 2
    Last Post: 2007-05-02, 01:52 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
  •