erasing sub-entitites

Discussion in 'AutoCAD' started by mikedsjr, Apr 12, 2004.

  1. mikedsjr

    mikedsjr Guest

    I have some titleblock blocks within many drawings that needs to have a portion of text erased. The text to be erase are not attribute text. Is using nentsel or nentselp the right direction to go?
     
    mikedsjr, Apr 12, 2004
    #1
  2. Redefine the block.

    ; Change blockname to the name of the block
    ; blockname.dwg is the corrected block
    (command "insert" "blockname=c:\\blockname.dwg")
    (command)
    ; if you have attributes in the block. Requires Express Tools
    (arxload "battman")
    (acet-attsync "blockname")

    --
    Best Regards, Jimmy Bergmark
    CAD and Database Developer Manager at www.pharmadule-emtunga.com
    Take a look at
    JTB FlexReport (FLEXlm report tool) - www.jtbworld.com/jtbflexreport
    SmartPurger (Purges automatically) - www.jtbworld.com/?/smartpurger.htm
    or download some freeware at www.jtbworld.com
    More on AutoCAD 2005;
    www.jtbworld.com/autocad2005.htm


    portion of text erased. The text to be erase are not attribute text. Is
    using nentsel or nentselp the right direction to go?
     
    Jimmy Bergmark, Apr 12, 2004
    #2
  3. mikedsjr

    OLD-CADaver Guest

    It may be easier to wblock the titleblock (if you don't already have the titleblock drawing). Then make the changes to that drawing and use INSERT= to replcae the old with the new. The INSERTion can be batch scripted to do 'em all or add something to your acad.lsp to do thm as they are opened.

    (command "-insert" " <block_name=Drawing_name_incl_directory> " "y" (command))
     
    OLD-CADaver, Apr 12, 2004
    #3
  4. mikedsjr

    mikedsjr Guest

    Interesting.

    Ok. Thanks for the tip guys.
     
    mikedsjr, Apr 12, 2004
    #4
  5. mikedsjr

    Jeff Mishler Guest

    You could run this lisp in a script:

    (rmv-txt "blockname" "string to find" "string to replace with")

    For example, you have a block named "TitleBlock1", with a string of text
    being "ENGINEERS-ARCHITECTS-PLANNERS" and you no longer want the
    "ENGINEERS-" in the string. This would be your script entry:
    (rmv-txt "TitleBlock1" "ENGINEERS-" "")

    or say you wanted to add "LAND" to the "PLANNERS" Portion:

    (rmv-txt "TitleBlock1" "PLA" "LAND PLA")

    HTH,
    Jeff

    (defun rmv-txt (block string substring /
    doc blk idx oldstr newstr len)
    (vl-load-com)
    (setq doc (vla-get-activedocument
    (vlax-get-acad-object)
    ))
    (vla-startundomark doc)
    (setq blk (vla-item (vla-get-blocks doc) block))
    (vlax-for ent blk
    (if (and (wcmatch (strcase (vla-get-objectname ent)) "*TEXT*")
    (setq idx (vl-string-search string
    (setq oldstr (vla-get-textstring ent))))
    )
    (progn
    (setq len (strlen oldstr))
    (setq newstr (strcat
    (substr oldstr 1 idx)
    substring
    (substr oldstr (+ 1 (strlen string) idx) len)
    )
    )
    (vla-put-textstring ent newstr)
    )
    )
    )
    (vla-regen doc acAllViewports)
    (vla-endundomark doc)
    )

    a portion of text erased. The text to be erase are not attribute text.
    Is using nentsel or nentselp the right direction to go?
     
    Jeff Mishler, Apr 12, 2004
    #5
  6. mikedsjr

    mikedsjr Guest

    Thanks. That is what I was looking for.

    I'm not very up on the Visual Lisp, but in the next few months I am certainly going to dig in and learn quick. I didn't realize that the best way to do that was through Visual Lisp.
     
    mikedsjr, Apr 13, 2004
    #6
  7. mikedsjr

    Jeff Mishler Guest

    You're Welcome.

    With only a few exceptions, the VisualLisp/ActiveX is easier (and
    definitely lots easier to see what you are doing) than traditional
    lisp/DXF codes. It takes some getting used to, but now I don't know why
    I took so long to "convert".
    By easier to read, I mean like these two examples:

    (vla-get-layer ent) vs (cdr (assoc 8 (entget ent)))
    (vla-get-textstring ent) vs (cdr (assoc 1 (entget ent)))

    Without knowing each and every DXF code and what it holds, it is very
    archaic to try to read the code on the right.

    Jeff

    certainly going to dig in and learn quick. I didn't realize that the
    best way to do that was through Visual Lisp.
     
    Jeff Mishler, Apr 13, 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.