Author Topic: Need a script to delete a specific block in PaperSpace  (Read 6399 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need a script to delete a specific block in PaperSpace
« Reply #15 on: October 09, 2014, 03:32:51 PM »
You have to supply the block names .. like so:
Quote
(remstamp "REMBLOCK,FORCONSTRUCTION")
Hummm, I don't think so.
Something else causing the error.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need a script to delete a specific block in PaperSpace
« Reply #16 on: October 09, 2014, 03:36:57 PM »
:(
I get that, but I can't use it at the command prompt that way if I load the lsp... 

Awesome for running with SCRIPT PRO.  but what could we do to get it to work at the command prompt.. ultimatly multiple options are very cool, but being aple to type the comand.. hit enter then type the block name would be ideal.  like mentioned before, one could always script it to run twice

remstamp
forconstruction
remstamp
forapproval
qsave

It would be handy to have at the command prompt while in the file as much as just for scripting use.

Does that make sence?
most of the crew i work with don't even know how to make .scr files.. so I got to get it simpler.

Look at this subroutine:
http://www.theswamp.org/index.php?topic=2688.msg34342#msg34342
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Need a script to delete a specific block in PaperSpace
« Reply #17 on: October 09, 2014, 03:54:33 PM »
OK..
I have two blocks in the drawing,
one named DEMOLITON and one named FORCONSTRUCTION

I paisted

(remstamp "REMBLOCK,FORCONSTRUCTION")
and
(remstamp "DEMOLITION,FORCONSTRUCTION")
both times the purge seems to run but then I get this at the command prompt

I even typed it in instad of paisting .. i attached the lsp and the DWG.


Command: ; error: bad argument type: consp "REMBLOCK,FORCONSTRUCTION"
Command: ; error: bad argument type: consp "DEMOLITION,FORCONSTRUCTION"

I even re-copied your code, resaved the .lsp file, and reloaded the lsp. and ran it a second time...
something.. aint right.
I am very  trainable....   (forgive my spelling)

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Need a script to delete a specific block in PaperSpace
« Reply #18 on: October 09, 2014, 03:59:00 PM »
I don't know how to implement the subroutine.. I'm not good at writing the code.. I had a rough time following the script above.. the subroutine is way over my head. .
I am very  trainable....   (forgive my spelling)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need a script to delete a specific block in PaperSpace
« Reply #19 on: October 09, 2014, 06:37:46 PM »
This is how I'd do it.

Use the enclosed lisp File.
Use a script file for each combination of blocks ; each file with a unique name.

If used manually, type SCRIPT at the command line and select the appropriate script.
If used with ScriptPro, call the appropriate script.

Code - Auto/Visual Lisp: [Select]
  1. ;; RemStamps.lsp
  2. ;; MODIFIED CODE 2014/10/10
  3. ;; Codehimbelonga kdub@theSwamp 2014/10/08
  4.  
  5. (defun remstamp (blknames / blkname)
  6.   (setq exprt (getvar "expert"))
  7.   (setvar "EXPERT" 5)
  8.   (command "-layer" "set" "0" "")
  9.   (command "Zoom" "All")
  10.   ;;
  11.   (if
  12.     (setq ss (ssget "X" (list '(0 . "INSERT") (cons 2  blknames))))
  13.      (while (setq block (ssname ss 0))
  14.        (vla-delete (vlax-ename->vla-object block))
  15.        (ssdel block ss)
  16.      )
  17.   )
  18.  
  19.   (vl-cmdf "_.Audit" "Y")
  20.   (repeat 3 (command "-PURGE" "ALL" "*" "N"))
  21.   (setvar "EXPERT" exprt)
  22.   (command "QSAVE")
  23.   (princ)
  24. )
  25.  
  26.  


Code - Auto/Visual Lisp: [Select]
  1. ;;;;; RemStamp-01.scr
  2. (LOAD "P:\\DWells\\LSP\\REMOVE_Block\\REMSTAMP.lsp")
  3. (RemStamp "FORCONSTRUCTION,DEMOLITION")
  4.  

Code - Auto/Visual Lisp: [Select]
  1. ;;;;; RemStamp-02.scr
  2. (LOAD "P:\\DWells\\LSP\\REMOVE_Block\\REMSTAMP.lsp")
  3. (RemStamp "CONSTRUCTION,DEMOLITION")
  4.  

Code - Auto/Visual Lisp: [Select]
  1. ;;;;; RemStamp-03.scr
  2. (LOAD "P:\\DWells\\LSP\\REMOVE_Block\\REMSTAMP.lsp")
  3. (RemStamp "FORCONSTRUCTION,SPECIALNOTES")
  4.  

Code - Auto/Visual Lisp: [Select]
  1. ;;;;; RemStamp-04.scr
  2. (LOAD "P:\\DWells\\LSP\\REMOVE_Block\\REMSTAMP.lsp")
  3. (RemStamp "HOLDFORINFORMATION,SPECIALNOTES,REVIEWSTAMP")
  4.  

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need a script to delete a specific block in PaperSpace
« Reply #20 on: October 09, 2014, 07:10:46 PM »
Just for info, I've used this to update/revise a block in multiple drawings, via ScriptPro.
Particularly handy when 'someone' misspells something in a block that is inserted into hundreds of drawings.

Code - Auto/Visual Lisp: [Select]
  1. ;;(updateReviewStamp "FORREVIEW" "FORCONSTRUCTION")
  2. ;; Rev 2011.08.07
  3.  
  4. (defun updateReviewStamp (oldBlock newBlock)
  5.   (setq exprt (getvar "expert"))
  6.   (setvar "EXPERT" 5)
  7.   (command "-layer" "set" "0" "")
  8.   (command "Zoom" "All")
  9.   (repeat 3 (command "-PURGE" "ALL" "*" "N"))
  10.   ;;
  11.   (if (setq ss (ssget "X" (list '(0 . "INSERT") (cons 2  oldBlock))))
  12.         (progn
  13.           (vl-cmdf "_.rename"
  14.                            "block"
  15.                            oldBlock
  16.                            newBlock
  17.           )
  18.           (vl-cmdf
  19.                   "_.Insert"
  20.             (strcat newBlock "=P:\\ProjBlocks\\" newBlock ".dwg")
  21.                 (list 0. 0. 0.)
  22.                 1
  23.                 1
  24.                 0
  25.           )
  26.           (vl-cmdf "_erase" (entlast) "")        
  27.         )
  28.   )
  29.   (vl-cmdf "_.Audit" "Y")
  30.   (repeat 3 (command "-PURGE" "ALL" "*" "N"))
  31.   (setvar "EXPERT" exprt)
  32.   (command "QSAVE")
  33.   (princ)
  34. )
  35.  
  36.  
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Need a script to delete a specific block in PaperSpace
« Reply #21 on: October 09, 2014, 08:34:04 PM »
This seems to be work'n.   Thanks Everyone..


 :wink:
I am very  trainable....   (forgive my spelling)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need a script to delete a specific block in PaperSpace
« Reply #22 on: October 09, 2014, 10:46:28 PM »
You have to supply the block names .. like so:
Quote
(remstamp "REMBLOCK,FORCONSTRUCTION")

Sorry Ron I thought you were talking about my code.
I'm slipping, need more sleep. :(
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Need a script to delete a specific block in PaperSpace
« Reply #23 on: October 10, 2014, 08:48:34 AM »
You have to supply the block names .. like so:
Quote
(remstamp "REMBLOCK,FORCONSTRUCTION")

Sorry Ron I thought you were talking about my code.
I'm slipping, need more sleep. :(
No worries Charles  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC