reoccuring block redefine irritation

Discussion in 'AutoCAD' started by Big 'D', Oct 14, 2004.

  1. Big 'D'

    Big 'D' Guest

    I had some great help this week on redefining a couple of blocks (cap and res1) in a way I could incorporate into a batch routine. It should not matter if the block already exists or not in the drawing. The following is what I was attempting to use. It seems to run successfully and ends with the prompt 'CCT Element blocks redefined'. But it is not redefining the blocks. Can anyone see anything wrong?

    (defun C:REP ()
    (progn
    (command "._insert" "cap=c:/NEWPATH/cap" "y")
    (command)
    (command "._insert" "res1=c:/NEWPATH/res1" "y")
    (command)
    (prompt "\nCCT Element blocks redefined.")
    (princ)
    )
    )

    Thanks
    D
     
    Big 'D', Oct 14, 2004
    #1
  2. regen?

    --
    Autodesk Discussion Group Facilitator



    res1) in a way I could incorporate into a batch routine. It should not
    matter if the block already exists or not in the drawing. The following is
    what I was attempting to use. It seems to run successfully and ends with the
    prompt 'CCT Element blocks redefined'. But it is not redefining the blocks.
    Can anyone see anything wrong?
     
    Jason Piercey, Oct 14, 2004
    #2
  3. Big 'D'

    Dave Drahn Guest

    I took the "y" out and it seemed to work fine:

    (defun C:REP ()
    (progn
    (command "._insert" "cap=c:/TEMP/cap")
    (command)
    (command "._insert" "res1=c:/TEMP/res1")
    (command)
    (prompt "\nCCT Element blocks redefined.")
    (princ)
    )
    )

    res1) in a way I could incorporate into a batch routine. It should not
    matter if the block already exists or not in the drawing. The following is
    what I was attempting to use. It seems to run successfully and ends with the
    prompt 'CCT Element blocks redefined'. But it is not redefining the blocks.
    Can anyone see anything wrong?
     
    Dave Drahn, Oct 15, 2004
    #3
  4. Big 'D'

    Dave Drahn Guest

    .... probably no need for that (progn
    )
    either (I think)

    res1) in a way I could incorporate into a batch routine. It should not
    matter if the block already exists or not in the drawing. The following is
    what I was attempting to use. It seems to run successfully and ends with the
    prompt 'CCT Element blocks redefined'. But it is not redefining the blocks.
    Can anyone see anything wrong?
     
    Dave Drahn, Oct 15, 2004
    #4
  5. Big 'D'

    OLD-CADaver Guest

    << I took the "y" out and it seemed to work fine: >>

    If he wishes to redefine an existing block with a new definition the Y will be needed.

    If he wishes to run this in a script, the Y will cause it to fail if the block does NOT exist in the drawing. So he needs to check if the block exists first.

    (defun C:REP ()
    (if (/= (tblsearch "block" "cap") nil)
    (progn
    (command "._insert" "cap=c:/NEWPATH/cap" "y") (command)
    );;end progn
    (progn
    (command "._insert" "cap=c:/NEWPATH/cap") (command)
    );;end progn
    );;end if
    )
     
    OLD-CADaver, Oct 15, 2004
    #5
  6. ...
    .....
    .....

    I don't think so, but correct me if I'm wrong. I haven't tried it in actual
    script-based application, but in keyboard equivalent input, as I suggested
    earlier, the Y is one of the options in the command line prompt at that
    point, for giving a Y scale factor, so it calls up the prompt for that.
    Then you cancel it without answering that prompt. The block definition is
    already loaded in by then.

    Would that not be the case somehow, just because the implementation is by
    way of a script?
     
    Kent Cooper, AIA, Oct 15, 2004
    #6
  7. Big 'D'

    Dave Drahn Guest

    Maybe there's a setting somewhere or something that I don't know about, but
    removing the "y" seemed to make it operate:
    1. redefine if block exists
    2. add block to dwg with 0 insertions if it does not exist



    block does NOT exist in the drawing. So he needs to check if the block
    exists first.
     
    Dave Drahn, Oct 15, 2004
    #7
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.