Jump to content

Quickly remove Objects on Block with swept selected object


Trai

Recommended Posts

I usually do with block in drawings. I see that ''REFEDIT'' command  choosing  can also work but it takes longer time, so can someone help me a lisp to result this problem. Thanks all

 

Link to comment
Share on other sites

36 minutes ago, tombu said:

T.Willey's code at TheSwamp may be what you're looking for https://www.theswamp.org/index.php?topic=12437.msg153343#msg153343

DEAR SIR. i read link you pined and find a lisp, but lisp only permiss click to delete object .  can you help me edit it to i can sweep many objects, ''NOT'' click mouse to delete. Here code lisp.

 

(defun c:EraseObjectFromBlock (/ ActDoc BlkCol Sel Ent)
; Erase object selected from block, in block collection, so all blocks will update.

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-EndUndoMark Actdoc)
(vla-StartUndoMark ActDoc)
(setq BlkCol (vla-get-Blocks ActDoc))
(setvar "errno" 0)
(while (not (equal (getvar "errno") 52))
 (if
  (and
   (setq Sel (nentsel "\n Select nested object to erase from block: "))
   (> (length Sel) 2)
   (not
    (vl-position
     nil
     (mapcar
      '(lambda (x / BlkName BlkObj)
       (setq BlkName (cdr (assoc 2 (entget x))))
       (and
        (not (vl-catch-all-error-p (setq BlkObj (vl-catch-all-apply 'vla-Item (list BlkCol Blkname)))))
        (= (vla-get-IsXref BlkObj) :vlax-false)
        (= (vla-get-IsLayout BlkObj) :vlax-false)
       )
      )
      (last Sel)
     )
    )
   )
   (/= (cdr (assoc 0 (entget (setq Ent (car Sel))))) "ATTRIB")
  )
  (progn
   (vla-Delete (vlax-ename->vla-object Ent))
   (vla-Regen ActDoc acActiveViewport)
  )
  (prompt "\n Object selected can not be erased with this command.")
 )
)
(vla-EndUndoMark ActDoc)
(princ)
)

Link to comment
Share on other sites

9 hours ago, Trai said:

DEAR SIR. i read link you pinned and find a lisp, but lisp only permits click to delete object .  can you help me edit it to i can sweep many objects, ''NOT'' click mouse to delete. Here code lisp.

nentsel (AutoLISP) https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-A7AC0917-66CE-4BAA-BBAF-D49F8ADB26B1

Prompts the user to select an object (entity) by specifying a point, and provides access to the definition data contained within a complex object

 

As nentsel which is used to select the entity inside the block can only select one object at a time you're going to have to use the BEDIT command to do that.

Link to comment
Share on other sites

On 9/2/2021 at 12:29 AM, Jonathan Handojo said:

If you delete an object in the block, wouldn't you delete that object across all other blocks in the drawing?

Yessir .. simple example:

(if (setq e (car (nentsel)))
  (vla-delete (vlax-ename->vla-object e))
)

 

2021-09-03_19-21-41.gif

Link to comment
Share on other sites

  • 2 weeks later...

to edit blocks in place i use this:

(defun c:ED  () (command "-refedit" "O" "" ""))

 

then to exit i use this:

(defun c:EDX  () (command "refCLOSE" "" ""))

 

skips all the additional dialog that pops up. just ensure the block you want to edit is highlighted before running ED command otherwise message about selecting nesting level will pop up. with those keys so close to each other on keyboard once get use to it you can jump in/out of blocks really quickly

Edited by masterfal
Link to comment
Share on other sites

18 hours ago, masterfal said:

to edit blocks in place i use this:

skips all the additional dialog that pops up. just ensure the block you want to edit is highlighted before running ED command otherwise message about selecting nesting level will pop up. with those keys so close to each other on keyboard once get use to it you can jump in/out of blocks really quickly

This refedit toggle command allows you to select the block before or after the command.

When finished just use the same command to exit.

(defun c:REDT  () 
  (if(=(strlen(getvar 'refeditname))0)
    (progn
      (sssetfirst nil(ssget "_:S" '((0 . "INSERT"))))
      (command "-refedit" "O" "" "")
    )
    (command "refCLOSE" "" "")
  )
  (princ)
)

Of course the Ribbon gives you the options to save or discard changes as well as adding or removing from the working set.

Link to comment
Share on other sites

23 hours ago, tombu said:

This refedit toggle command allows you to select the block before or after the command.

When finished just use the same command to exit.


(defun c:REDT  () 
  (if(=(strlen(getvar 'refeditname))0)
    (progn
      (sssetfirst nil(ssget "_:S" '((0 . "INSERT"))))
      (command "-refedit" "O" "" "")
    )
    (command "refCLOSE" "" "")
  )
  (princ)
)

Of course the Ribbon gives you the options to save or discard changes as well as adding or removing from the working set.

 

ohh nice! love finding better ways to do things.

 

i use keyboard shortcuts for everything so i dont use ribbon or icons. i like using as much drawing space on my screen as possible. plus i find it much quicker to use keyboard rather than moving mouse to click icon. used to work with this older guy who only wanted to use icons as he thought he couldn't remember so many shortcuts. be surprised how quickly you learn them when using regularly though

Link to comment
Share on other sites

10 hours ago, masterfal said:

 

ohh nice! love finding better ways to do things.

 

i use keyboard shortcuts for everything so i don't use ribbon or icons. i like using as much drawing space on my screen as possible. plus i find it much quicker to use keyboard rather than moving mouse to click icon. used to work with this older guy who only wanted to use icons as he thought he couldn't remember so many shortcuts. be surprised how quickly you learn them when using regularly though

There's at least 200 AutoCAD commands alone and for those of us using verticals adding Map, Civil, Render, Vehicle Tracking more than triples that amount. I've got access to hundreds of them along with another hundred lisp functions in a well organized heavily customized cuix Ribbon with 33 Shortcut Menus. Old guy here who only uses about 30 keyboard shortcuts on a regular basis. Haven't used Toolbars in years as just one Ribbon Tab displaying 12 Panels with each able to provide access to a hundred commands makes having an old fashion Toolbar a waste of screen space. I do use my QAT a lot since it's visible no matter what Panel is selected for Undo/Redo, Layer List Combo Box, etc… https://xlncad.com/complete-list-of-autocad-commands/

Link to comment
Share on other sites

Those of us old enough remember digitisers and all the commands you could put on them and a 4 button puck. There is a sample dwg somewhere, this is a panel for the digitiser. There are multi panels on the digitiser. Watching experienced users was super fast and they did not look at digitiser just knew where a command was.

 

image.thumb.png.565e8347e8a8309601b7246555078af5.png

image.png.02bdf55a3efef32560f68fc3d1186373.png

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...