change xref block name

Discussion in 'AutoCAD' started by Joe Burke, Nov 8, 2004.

  1. Joe Burke

    Joe Burke Guest

    All,

    I must be doing something stupid here, but I can't see what it is. Any insights
    appreciated. Using 2004.

    ;; select an xref
    ;; enter new name
    ;; attempt to modify the name of the xref block definition
    (defun c:putXrefName ( / blocks blkref newname blkdef )
    (setq blocks
    (vla-get-blocks
    (vla-get-activedocument
    (vlax-get-acad-object))))
    (setq blkref (vlax-ename->vla-object (car (entsel "Select xref: "))))
    (setq newname (getstring "\nEnter new xref name: "))
    (setq blkdef (vla-item blocks (vlax-get blkref 'Name)))
    ;check property is available and can be modified
    (if (vlax-property-available-p blkdef 'Name T)
    (progn
    (print (vlax-get blkdef 'Name)) ;testing
    (print newname) ;testing
    (print)
    (vlax-put blkdef 'Name newname)
    )
    )
    ) ;end

    Command: putxrefname
    Select xref:
    Enter new xref name: whatever
    "Site Civil OP3B"
    "whatever"
    ; error: AutoCAD.Application: Invalid input << why?

    TIA
    Joe Burke
     
    Joe Burke, Nov 8, 2004
    #1
  2. Joe Burke

    James Allen Guest

    Hi Joe,

    FWIW, it seems to work here; 2005. Not much help, huh? Sorry. I'm sure
    you've already checked this, but might it be a file specific problem?

    James
     
    James Allen, Nov 8, 2004
    #2
  3. Joe Burke

    T.Willey Guest

    Worked here, and I'm on 2004 also.

    Tim
     
    T.Willey, Nov 8, 2004
    #3
  4. Joe Burke

    dblaha Guest

    It's working fine for my in both 2005 and 2002. The only way I could get it to fail was by attempting to run it while refeditting the xref I'm attempting to rename. But that generated a different error message. I agree with James in that it sounds file specific.
     
    dblaha, Nov 8, 2004
    #4
  5. Joe Burke

    Joe Burke Guest

    Hi guys,

    Thanks for checking.

    Whatever the problem is, it must be a strange one. It still doesn't work (error) with
    the two files I was testing with last night. So I tried xrefing the file that was
    xrefed in those, into another file. Run the code... error. Then I changed the xref
    name manually in xref manager. Just to be sure it could be changed. Run the code...
    now it works, name changed, no error. What?

    I'm going to have to play with it some more. No time for that now.

    BTW, if anyone is wondering, why code for such a simple thing. It was part of
    something else. I broke it out just to isolate the problem.

    Joe Burke
     
    Joe Burke, Nov 8, 2004
    #5
  6. Joe Burke

    Joe Burke Guest

    Follow up after some more testing.

    James,

    Looks you nailed it regarding a file specific problem. Many thanks. No, I didn't
    think of that.

    What I did using the problematic xrefs. Made a copy of one of them and ran audit on
    the renamed copy. It found and fixed 548 problems. Then I referenced the audited file
    into one of the files which also references the not audited version. Run the code
    selecting one xref and then the other. It changed the name of the audited xref as
    expected. The not audited xref still tosses the error. I guess that's proof.

    The loose end here is why manually changing a damaged xref file name allows the code
    to work afterwards. I can only guess, that operation performs some check similar to
    audit, which doesn't occur when the name is changed using the code.

    Thanks to Tim and dblaha too.

    Regards
    Joe Burke
     
    Joe Burke, Nov 9, 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.