Lisp Routine Wanted

Discussion in 'AutoCAD' started by denverae, Aug 2, 2004.

  1. denverae

    denverae Guest

    I am a new user to Lisp. Can someone provide or point me to a routine where
    I can search my 400+ folders to find which dwgs contain the block name pid
    and replace it with PID?

    Thanks in advance,

    Ray
     
    denverae, Aug 2, 2004
    #1
  2. denverae

    R.K. McSwain Guest

    I haven't tried it, but it looks like [ToolPac | Drawing | Replace] will do what you want.
    http://www.dotsoft.com/toolpac.htm
     
    R.K. McSwain, Aug 2, 2004
    #2
  3. denverae

    Paul Turvill Guest

    That would be difficult. Last time I checked block names weren't (aren't)
    case sensitive.
    ___
     
    Paul Turvill, Aug 2, 2004
    #3
  4. denverae

    Anthony Guest

    Sure no problem, just a little more information are you wanting to redefine
    the blocks or just rename the current block?

    Anthony
     
    Anthony, Aug 2, 2004
    #4
  5. denverae

    ECCAD Guest

    Ray,
    Sure. I can help you out. I have a 'batch' process written in
    VB, which I will give you...and if I can get a 'sample' drawing,
    I can check out what needs to be done with a Lisp.
    I need to know the 'location' of your replacement PID block,
    and I can generate a Lisp to be called for 'each' drawing..
    in multiple folders, no problem.
    My E-Mail is:
    Remove the 'nospam' + the .

    Bob Shaw
    www.bobscadshop.com

    No Charge:
    :)
     
    ECCAD, Aug 2, 2004
    #5
  6. Try this, the only thing is to change the block list, and the new block
    definition
    should be in the Autocad Search Path...

    Hope it helps.

    By the way, I did this in a hurry and didn't put the variables as locals

    Saludos

    Marco Jacinto

    (defun c:RefreshingBlocks ()
    (or lb
    (SETQ LB '(("Old_Block_Name" "New Block Name")
    )
    )
    )
    (setq *blocks*
    (vla-get-blocks(vla-get-activedocument(vlax-get-acad-object)))
    bklst nil)
    (vlax-for block *blocks*
    (setq bklst (cons (vla-get-name block) bklst))
    )
    (setq cnt 0)
    (foreach bk bklst
    (foreach bkl lb
    (if (member (strcase bk) bkl)
    (progn
    (setq bkname (vla-item *blocks* bk))
    (if
    (vl-catch-all-apply 'vla-put-name (list bkname (cadr bkl)))
    (progn
    (setq ssbk (ssget "X" (list '(0 . "INSERT") (cons 2 bk))))
    (if ssbk
    (repeat (progn (setq ct 0) (sslength ssbk))
    (vl-catch-all-apply
    'vla-put-name
    (list (vlax-ename->vla-object (ssname ssbk ct))
    (CADR bkl)
    )
    )
    (setq ct (1+ ct))
    )
    )
    )
    )
    (setq
    blkPath
    (findfile (strcat (cadr bkl) ".dwg")
    )
    )
    (if (/= blkPath nil)
    (progn
    ;(mapcar 'princ (list "\nChanging Block: " bk))
    (command "-insert" (strcat bk "=" blkPath))
    (command)
    (setq cnt (1+ cnt))
    )
    )
    )
    )
    )
    )
    (prompt (strcat "\nNumber of blocks updated: " (itoa cnt)))
    (princ)
    (vla-purgeall (vla-get-activedocument(vlax-get-acad-object)))
    )
    (prompt "\nType RefreshingBlocks to run program.")
    (princ)
     
    Marco Jacinto, Aug 3, 2004
    #6
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.