Author Topic: Block Replacement lisp (continued)  (Read 7838 times)

0 Members and 1 Guest are viewing this topic.

CECE_CAD

  • Guest
Block Replacement lisp (continued)
« on: February 27, 2007, 10:24:18 AM »
I have been looking for a block replacement lisp and came to the swamp for the info.  I have found the (Block Replacement lisp post http://www.theswamp.org/index.php?topic=8823.0 that was posted last year.  Seeing that I'm a newbie to lisping/coding yes I read the whole post, I have a question about it.  I would like to keep the ability to pick the block that I want to change, then have the ability to insert any other block to replace it with.  The problem is I don't know how to add it to or change any of the "smaller" and simpler codes posted on here. 

I have arch blocks (AL2x4) that I want to change to my company standard blocks (2x4fix)

« Last Edit: February 27, 2007, 10:42:46 AM by CECE_CAD »

CECE_CAD

  • Guest
Re: Block Replacement lisp (continued)
« Reply #1 on: February 27, 2007, 10:48:23 AM »
Sorry I forgot to add the code I was talking about

Code: [Select]

;;; Change Block Version 2.3.1
;;; Copyright (C) 1997-2006 by K.E. Blackie
;;;
;;; You may copy, modify, use or distribute this code provided that
;;; the copyright notice remains in place and that no monetary
;;; consideration be given for the use or transfer of such code.
;;;;
;;;;-------------------------------------------------
;;; The function CB will replace a selected block reference(s)
;;; with another block reference that is already defined in
;;; the drawing. All attributes will be retained until/unless
;;; attsync is used.
;;;
;;
;; Modified for style by kwb@theswamp 20060303
;;

(defun C:CB (/ intCounter lstOldReference ssBlocks strNewBlockName)
  ;;
  ;; prompt the user to select items, filtering for blocks only
  ;;
  (prompt "\nSelect BLOCKS to be replaced.")
  (setq ssBlocks        (ssget '((0 . "INSERT")))
        strNewBlockName (getstring t "\nReplacement Block Name: ")
        intCounter      0
  )

  ;; step through the selection set of blocks
  ;; get the entity list and substitute the new block name for the old block name
  ;; and update the entity with entmod
  ;;
  (repeat (sslength ssBlocks)
    (setq lstOldReference (entget (ssname ssBlocks intCounter)))
    (entmod (subst (cons 2 strNewBlockName)
                   (assoc 2 lstOldReference)
                   lstOldReference
            )
    )
    (setq intCounter (1+ intCounter))
  )

  ;; Remind about Syncronisation .. don't leave anything on the command line
  ;;
  (princ "\nAttsync may be required for Attributed Blocks")
  (princ)
)


This code was posted by Kerry Brown in the above link
« Last Edit: February 27, 2007, 10:54:41 AM by CECE_CAD »

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Block Replacement lisp (continued)
« Reply #2 on: February 27, 2007, 01:37:07 PM »
what version af autocad are you on?  the following is for 2006.

http://www.theswamp.org/index.php?topic=13283.0
James Buzbee
Windows 8

CECE_CAD

  • Guest
Re: Block Replacement lisp (continued)
« Reply #3 on: February 27, 2007, 01:44:59 PM »
what version af autocad are you on?  the following is for 2006.

http://www.theswamp.org/index.php?topic=13283.0

jbuzbee,  I use 2007

CECE_CAD

  • Guest
Re: Block Replacement lisp (continued)
« Reply #4 on: February 27, 2007, 04:02:29 PM »
what version af autocad are you on?  the following is for 2006.

http://www.theswamp.org/index.php?topic=13283.0



jbuzbee,

how do I use the jbswapblock.dvb...?

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Block Replacement lisp (continued)
« Reply #5 on: February 27, 2007, 07:41:23 PM »
Matt W tested it on 2007 and seems to work.  Copy the jbVBASwapBlock.lsp and jbSwapBlock.dvb into autocad's search path.  load jbVBASwapBlock.lsp with appload, acaddoc.lsp or *.mnl and type "jbSwapBlock" at the command line.
James Buzbee
Windows 8

CECE_CAD

  • Guest
Re: Block Replacement lisp (continued)
« Reply #6 on: February 28, 2007, 11:35:51 AM »
Matt W tested it on 2007 and seems to work.  Copy the jbVBASwapBlock.lsp and jbSwapBlock.dvb into autocad's search path.  load jbVBASwapBlock.lsp with appload, acaddoc.lsp or *.mnl and type "jbSwapBlock" at the command line.


jbuzbee, it works..Is there a way to insert blocks that are not listed in the drawing?

Guest

  • Guest
Re: Block Replacement lisp (continued)
« Reply #7 on: February 28, 2007, 04:44:44 PM »
What's wrong with using BLOCKREPLACE from Express Tools??!?

CECE_CAD

  • Guest
Re: Block Replacement lisp (continued)
« Reply #8 on: February 28, 2007, 05:44:52 PM »
What's wrong with using BLOCKREPLACE from Express Tools??!?

Matt,  There is nothing wrong with using the Express Tools Block Replace just the fact the block has to be inside the drawing first.  What I really would like to do is have a lisp that I can use to know the blocks that I need to change and the block to replace it with.  But I was settling for what ever I could find.  I also need it to change the layer to our standard layer.  I have the same arch that does the same naming style with his blocks and he has alot of lights, I don't like having the blocks redefined either.  We do alot of work with this same arch so I was just trying to find a nice quick way of being able to replace of his blocks with ours.  Besides giving him our blocks.....

I'm not as advance with writing lisp, but i'm trying..
« Last Edit: February 28, 2007, 05:46:47 PM by CECE_CAD »