ENTMOD and repathing XREF's

Discussion in 'AutoCAD' started by Bruce Sheldon, Apr 15, 2004.

  1. Hi all,

    The help file for VisualLISP states: "The entity name returned by
    tblobjname can be used in entget and entmod operations." Yet, if I try to
    set a new path to the tblobjname XREF definition, the ENTMOD command returns
    "nil" and is not able to complete the task. Any suggestions? Here's my
    code:


    (defun C:REPATHXREF ()
    (setq theblock (tblnext "BLOCK" T))
    (while theblock
    (if (assoc 1 theblock)
    (progn
    (setq theblockname (cdr (assoc 2 theblock)))
    (setq xrefent (entget (tblobjname "BLOCK" theblockname)))
    (princ "\nOldpath: ")
    (princ (setq oldpath (cdr (assoc 1 xrefent))))
    (if (= (substr oldpath 1 3) "S:\\") ;Network Drive is S:\
    (progn
    (princ "\nNewpath: ")
    (princ
    (setq newpath (strcat "\\\\Main2" (substr oldpath 3)));Wish to
    repath to named server
    )
    )
    )
    (setq
    xrefent
    (subst (cons 1 newpath) (assoc 1 xrefent) xrefent)
    )
    (entmod xrefent)
    )
    )
    (setq theblock (tblnext "BLOCK"));Continue for all XREF's in the drawing
    )
    (princ)
    )
     
    Bruce Sheldon, Apr 15, 2004
    #1
  2. Bruce Sheldon

    Jamie Duncan Guest

    The following entries may not be renamed but are otherwise modifiable,
    subject to restriction:

    Symbol table entries that cannot be renamed

    Table Entry name
    STYLE STANDARD
    DIMSTYLE STANDARD
    BLOCKS *MODEL_SPACE
    BLOCKS *PAPER_SPACE
    APPID No entries may be renamed

    might this be the problem?


    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)
     
    Jamie Duncan, Apr 16, 2004
    #2
  3. I'm not sure, but blocks in general may be modified. The help file uses the
    blocks table as an example of this command. Obviously, xref's may be
    treated differently from regular blocks.
     
    Bruce Sheldon, Apr 16, 2004
    #3
  4. Bruce Sheldon

    Jamie Duncan Guest

    I tried to entmod an xref block - got nil everytime


    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)
     
    Jamie Duncan, Apr 16, 2004
    #4
  5. Yeah, I know. I wish some knowlegable person who knows how to tweek this
    path will see this post. There must be a way to do it. I suppose I can do
    the ol' "command" line method and choke through the repathing that way.
    I'll give that a try and see what happens.
     
    Bruce Sheldon, Apr 16, 2004
    #5
  6. Bruce Sheldon

    Jamie Duncan Guest

    Me2 - I have some repathing issues as well. But we never have that many
    xrefs - so it shouldn't be too hard.

    There may be an activex method as well.



    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)
     
    Jamie Duncan, Apr 17, 2004
    #6
  7. Bruce Sheldon

    John Uhden Guest

    Use ActiveX on an Xref reference (Path property) and follow with the Reload
    method.
     
    John Uhden, Apr 17, 2004
    #7
  8. Bruce Sheldon

    Jamie Duncan Guest

    It's as I suspected. Thanks John.



    --
    Jamie Duncan

    "How wrong it is for a woman to expect the man to build the world she wants,
    rather than to create it herself."
    - Anais Nin (1903-1977)
     
    Jamie Duncan, Apr 17, 2004
    #8
  9. Bruce Sheldon

    John Uhden Guest

    You can do this with VLisp, you know. Here's an example designed to strip the
    path if the xref is found without the path...

    (defun c:XPATH ( / *error* cmdecho SS i n Object Name Path File Blocks Block)
    ;; v1.0 (01-26-04), John Uhden
    (gc)
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
    (defun *error* (error)
    (if (vl-position cmdecho '(0 1))(setvar "cmdecho" cmdecho))
    (vla-endundomark *doc*)
    (cond
    ((not error))
    ((wcmatch (strcase error) "*QUIT*,*CANCEL*"))
    (1 (princ (strcat "\nERROR: " error)))
    )
    (princ)
    )
    (vla-endundomark *doc*)
    (vla-startundomark *doc*)
    (setq cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (command "_.expert" (getvar "expert"))

    (and
    (setq Blocks (vlax-get *doc* 'Blocks))
    (setq SS (ssget "X" '((0 . "INSERT"))))
    (setq i 0 n 0)
    (repeat (sslength SS)
    (and
    (setq Object (vlax-ename->vla-object (ssname SS i)))
    (setq i (1+ i))
    (setq Name (vlax-get Object 'Name))
    (setq Block (vla-item Blocks Name))
    (= (vlax-get Block 'IsXref) -1)
    (setq Path (vlax-get Object 'Path))
    (wcmatch Path "*\\*,*/*")
    (setq File (strcat (vl-filename-base Path)(vl-filename-extension Path)))
    (findfile File)
    (princ (strcat "\nChanging path from '" Path "'\n to '" File "' ..."))
    (or (vlax-put Object 'Path File) 1)
    (princ "\n Reloading...")
    (or (vlax-invoke Block 'Reload) 1)
    (princ " Done.")
    (setq n (1+ n))
    )
    1
    )
    (princ (strcat "\n" (itoa n) " xrefs repathed"))
    )
    (*error* nil)
    )
     
    John Uhden, Apr 17, 2004
    #9
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.