TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Luke on April 11, 2008, 04:42:31 PM

Title: Block Replace
Post by: Luke on April 11, 2008, 04:42:31 PM
I want to run a script to replace BlockA with BlockA and BlockB with BlockB.

I have the following code:
Code: [Select]
(command "-INSERT" "LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17")
(command)
(command "-INSERT" "LCC_BRD_LANDSCAPE_8x11=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_8x11")
(command)

So the first (command) after the first insert stops the inserting of the block, that is what I want it to do. Unfortunately it also stops the remainder of the script from running. 

Can anybody tell me what to change.
Title: Re: Block Replace
Post by: Keith™ on April 11, 2008, 04:44:16 PM
in a script, it is likely an errant or space
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 04:50:33 PM
When I try to run each section individually they both work.  But when I put them together it stops after the first (11x17)
Title: Re: Block Replace
Post by: Keith™ on April 11, 2008, 04:54:30 PM
Note the errant space
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 05:00:50 PM
Yes I see now.

I have adjusted
Code: [Select]
(command "-INSERT" "LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17")
(command)
(command "-INSERT" "LCC_BRD_LANDSCAPE_8x11=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_8x11")
(command)

but still seems to stop at same point...

From Command line:

Command: _script

Enter script file name <C:\Documents and Settings\user\Desktop\Block
Replace.scr>: LCC_BORDER_UPDATE.scr
Command: (command "-INSERT"
"LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17")
-INSERT Enter block name or [?]:
LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17 Block
"LCC_BRD_LANDSCAPE_11x17" redefined

Units: Inches   Conversion:    1.0000
Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: nil
Specify insertion point or
[Basepoint/Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: (command)

Command: nil
Title: Re: Block Replace
Post by: ronjonp on April 11, 2008, 05:04:39 PM
Try loading this into your startup suite then call in your script using RB.

Code: [Select]
(defun c:rb (/)
  (if (tblobjname "block" "LCC_BRD_LANDSCAPE_11x17")
    (progn
      (command
".-INSERT"
"LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17"
'(0 0 0)
"1"
"1"
"0"
       )
      (command "._erase" (entlast) "")
    )
  )
)
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 05:05:54 PM
I notice when I highlight my inserted code it shows the same as you saw Keith, but when I highlight it in the actual notepad editor it shows up like this...(http://CODE.jpg)

Is there a better way to skin this cat?
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 05:11:59 PM
Thanks ronjonp, I need this to also replace my 8x11 border all in one click...
Title: Re: Block Replace
Post by: ronjonp on April 11, 2008, 05:13:16 PM
See if you can modify it  :wink:  ... if you're having trouble let me know.
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 05:28:54 PM
I appreciate the help, but I'm not sure if I like this route... (no disrespect just sort of outloud thinking on "paper")

I do not want the block to actually insert, this makes me cycle through the attributes of my title block and it inserts it.

I just need to overwrite my old block with my new one.  Is lisp the better way to do it or can my script be tweaked to get it to keep on running after the first command stops the insert?
Title: Re: Block Replace
Post by: ronjonp on April 11, 2008, 05:33:57 PM
Look into ATTREQ and ATTDIA :)...I'll see if i can throw something together.
Title: Re: Block Replace
Post by: daron on April 11, 2008, 05:35:04 PM
Also look into designcenter. It allows you to insert and updated block definition without inserting the block.
Title: Re: Block Replace
Post by: Luke on April 11, 2008, 05:36:00 PM
Not necessary to try anything else.  I got my script to work...

Code: [Select]
(command "-INSERT" "LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17")
(command)(command "-INSERT" "LCC_BRD_LANDSCAPE_8x11=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_8x11")(command)

Thanks all for your help!
Title: Re: Block Replace
Post by: ronjonp on April 11, 2008, 05:38:46 PM
good to hear...

This works as well:

Code: [Select]
(defun c:rb (/ atr)
  (setq atr (getvar 'attreq))
  (if (tblobjname "block" "LCC_BRD_LANDSCAPE_11x17")
    (progn
      (setvar 'attreq 0)
      (command
".-INSERT"
"LCC_BRD_LANDSCAPE_11x17=S:/Engineer/Borders/LCC_BRD_LANDSCAPE_11x17"
'(0 0 0)
"1"
"1"
"0"
       )
      (setvar 'attreq atr)
      (command "._erase" (entlast) "")
    )
  )
)