Redefine Block using scripts

Discussion in 'AutoCAD' started by dhorton, May 27, 2004.

  1. dhorton

    dhorton Guest

    Hello,

    I've trawled through past postings but i'm still having difficulty in solving my problem...

    I'm trying to write a script that will redefine all insertions of a particular block with a new block of the same name.

    I've tried using...

    (command "-insert" "Blockname.dwg=J:\\CAD blocks\\Blockname.dwg")

    this then prompts me for insertion points, scale, angle etc.....
    All I need to do is update the existing block contained within the drawing with a block of the same name held on my system without getting to the stage of inserting an additional block. (the block contains a number of attributes of which I need to preserve).

    Do I need to reset some of my system variables??

    Thanks in advance

    Dom
     
    dhorton, May 27, 2004
    #1
  2. dhorton

    bob.at Guest

    Dom

    try this one:

    (command "-insert" "Blockname=J:\\CAD blocks\\Blockname.dwg" ^C)

    And if you have set regenauto to off you must do a manual "regen"

    bob.at
     
    bob.at, May 27, 2004
    #2
  3. dhorton

    ECCAD Guest

    You could also:

    ; fixblock.lsp - saveas fixblock.lsp, store in J:\CAD blocks\
    (defun fixblock ( blockname )
    (setvar "attreq" 0)
    (command "-insert" (strcat blockname "=" "J:/CAD blocks/" blockname ".dwg") "0,0" "" "" "")
    (entdel (entlast))
    (command "attsync" "Name" blockname)
    (setvar "attreq" 1)
    (princ)
    ); end function
    ;
    ;

    In script:

    Open drawing.
    (load "J:/CAD blocks/fixblock.lsp")
    (fixblock "block1")
    (fixblock "block2")
    ..etc
    Qsave
    open next drawing.
    (load "J:/CAD blocks/fixblock.lsp")
    (fixblock "block1")
    (fixblock "block2")
    ..etc
    Qsave
    ..............

    Bob
     
    ECCAD, May 28, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.