Author Topic: Block Replace  (Read 3967 times)

0 Members and 1 Guest are viewing this topic.

Luke

  • Guest
Block Replace
« 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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16717
  • Superior Stupidity at its best
Re: Block Replace
« Reply #1 on: April 11, 2008, 04:44:16 PM »
in a script, it is likely an errant or space
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Luke

  • Guest
Re: Block Replace
« Reply #2 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)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16717
  • Superior Stupidity at its best
Re: Block Replace
« Reply #3 on: April 11, 2008, 04:54:30 PM »
Note the errant space
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Luke

  • Guest
Re: Block Replace
« Reply #4 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

ronjonp

  • Needs a day job
  • Posts: 7022
Re: Block Replace
« Reply #5 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) "")
    )
  )
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Luke

  • Guest
Re: Block Replace
« Reply #6 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...

Is there a better way to skin this cat?

Luke

  • Guest
Re: Block Replace
« Reply #7 on: April 11, 2008, 05:11:59 PM »
Thanks ronjonp, I need this to also replace my 8x11 border all in one click...

ronjonp

  • Needs a day job
  • Posts: 7022
Re: Block Replace
« Reply #8 on: April 11, 2008, 05:13:16 PM »
See if you can modify it  :wink:  ... if you're having trouble let me know.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Luke

  • Guest
Re: Block Replace
« Reply #9 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?

ronjonp

  • Needs a day job
  • Posts: 7022
Re: Block Replace
« Reply #10 on: April 11, 2008, 05:33:57 PM »
Look into ATTREQ and ATTDIA :)...I'll see if i can throw something together.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

daron

  • Guest
Re: Block Replace
« Reply #11 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.

Luke

  • Guest
Re: Block Replace
« Reply #12 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!

ronjonp

  • Needs a day job
  • Posts: 7022
Re: Block Replace
« Reply #13 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) "")
    )
  )
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC