Author Topic: AutoCAD script not working  (Read 2353 times)

0 Members and 1 Guest are viewing this topic.

ssbp

  • Guest
AutoCAD script not working
« on: September 06, 2015, 02:41:10 PM »
I have created a command to edit block.

Drawings kept on "D:\Temp\"

I run this command and it works perfect for single drawing. I created a script for all drawings with custom commands. Custom command is "qz" (Script attached). Script works well for first drawing and it stuck. Always need to terminate the script.

How to overcome this problem ?

Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: AutoCAD script not working
« Reply #1 on: September 06, 2015, 03:05:24 PM »
  • Is your custom command 'qz' being loaded on drawing startup?
  • Does your custom command contain any expressions which cancel the active command? (e.g. (command nil) or (command)) as these will terminate a script.

ssbp

  • Guest
Re: AutoCAD script not working
« Reply #2 on: September 06, 2015, 03:13:23 PM »
Hey, Thanks for the quick reply.

I dont think thr will be any problem in in custom command. It is very simple.

(defun c:qz ()
(command "-bedit" "A$C603D4565")
(command "erase" "window" "178.1638,11.7404,0.0000" "211.4153,3.7166,0.0000" "")
(command "_pasteclip" "177.1226,18.5725,0.0000")
(command "_bclose" "Save")
(command "zoom" "extents")
)

Just want to replace few drawing entities.

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: AutoCAD script not working
« Reply #3 on: September 06, 2015, 03:19:02 PM »
Perhaps try:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:qz ( / sel )
  2.     (if (tblsearch "block" "A$C603D4565")
  3.         (progn
  4.             (command "_.-bedit" "A$C603D4565" "_.zoom" "_extents")
  5.             (if (setq sel (ssget "_W" '(178.1638 11.7404) '(211.4153 3.7166)))
  6.                 (command "_.erase" sel "")
  7.             )
  8.             (command "_.pasteclip" "_non" '(177.1226 18.5725 0.0000) "_.bclose" "_save" "_.zoom" "_extents")
  9.         )
  10.     )
  11.     (princ)
  12. )

ssbp

  • Guest
Re: AutoCAD script not working
« Reply #4 on: September 06, 2015, 03:34:50 PM »
 :-) Yes! It works now.

Can you please explain - What was the logical reason ?

Thanks Lee.

ssbp

  • Guest
Re: AutoCAD script not working
« Reply #5 on: September 06, 2015, 03:36:40 PM »
Mine was very simple simple and easy. Where and What went wrong in the command ? It is starange for me.

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: AutoCAD script not working
« Reply #6 on: September 06, 2015, 03:46:23 PM »
:-) Yes! It works now.

Can you please explain - What was the logical reason ?

Thanks Lee.

Excellent to hear  :-)

I just added some basic error trapping: checking that the block was defined in the drawing before attempting to edit it, checking for a valid window selection before trying to erase it - either of these cases could be causing your original code to fail.

ssbp

  • Guest
Re: AutoCAD script not working
« Reply #7 on: September 15, 2015, 03:04:03 AM »
Hey Lee,

Sorry for late reply.

Still not clear with these reasons, because block is surely present in all drawings and window has entities which is going replace with other one. Anyway I will keep digging net to get clear with these issues.

Thanks once again.