Page 1 of 4 1234 LastLast
Results 1 to 10 of 31

Thread: Lisp to set Xref path

  1. #1
    Member
    Join Date
    2010-04
    Posts
    14
    Login to Give a bone
    0

    Default Lisp to set Xref path

    I have been looking at lisp codes or two days and I can't find the clue that I am looking for.

    I want to run a lisp that will look for the xref file names in the current directory. The open drawing and all of the xref's will be in the same folder, so I want it to reload the xref if it is found in the current directory.

    I swear that doesn't sound complicated, but I'm not very good with lisp and don't know all of the possible commands.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    That particular xref or all xrefs found in the current directory? Are you wanting to change the path of the found xrefs, too?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    Here's an adaptation of a routine I already had... probably not the most efficient example, but I believe it will do what the OP wants:
    (i.e., reload all xrefs that reside in the active drawing's directory)

    Code:
    (defun c:TEST (/ blockTable xrefName curPath)
      (vl-load-com)
      (vlax-for x (setq blockTable
                         (vla-get-blocks
                           (cond
                             (*activeDoc*)
                             ((setq *activeDoc*
                                (vla-get-activedocument
                                  (vlax-get-acad-object)))))))
        (if (and (vlax-property-available-p x 'isxref)
                 (= :vlax-true (vla-get-isxref x))
                 (= (vl-string-right-trim
                      (strcat (setq xrefName (vla-get-name x)) ".dwg")
                        (vla-get-path x))
                        (cond
                          (curPath)
                          ((setq curPath (getvar 'dwgprefix))))))
          (progn
            (vla-reload (vla-item blockTable xrefName))
            (terpri)
            (prompt
              (strcat "\n  >>  Reloaded XREF  >>  \"" xrefName "\"")))))
      (terpri)
      (princ))
    Note - this does not account for visretain sysvar.

    Hope this helps!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Member
    Join Date
    2010-04
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    I want to reload all of the xrefs in the drawing, if they are found in the current directory.

    I tried that test lisp file and it asks me to select items in xref or current layer and when I try to select the entire drawing everything disapears.

    I can open the drawing, got to xref manager, select all of the xrefs in the group and reload them, but I cannot do it with a lisp file, yet. I downloaded and tested lots of lisp files today but so far none of them have reloaded the xrefs.

  5. #5
    Member
    Join Date
    2010-04
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    I guess I didn't finish telling you what I want to do.

    I want to Reload all of the xref's that it can find in the current directory, and then I am going to detach the xref's that are not loaded.

    I have a lisp that will detach the xref's that are not loaded, but it will not reload them first.

    Then I am going to bind the loaded xref's to the drawing and continue with a clean up routine that I already have working.

    Thanks for helping me, I have been pulling my hair out over this step all day.

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    Quote Originally Posted by tbeaman View Post
    I want to reload all of the xrefs in the drawing, if they are found in the current directory.
    That is exactly what my routine does (posted above).

    Quote Originally Posted by tbeaman View Post
    I tried that test lisp file and it asks me to select items in xref or current layer and when I try to select the entire drawing everything disapears.
    You haven't tested my routine at all... have you?

    My routine has zero prompts for user input.

    A simple enhancement to the final if statement using the vla-unload method would lend to your stated goal(s) as well. Of course, we could just jumpt to the vla-delete method and get rid of the whole reference, but what do I know!? lol
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Member
    Join Date
    2010-04
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    I did use your lisp file, I even copied it again this morning and tried it again.

    As soon as I type in test it says "SELECT OBJECTS IN CURRENT DRAWING OR XREF" and if I hit enter or try to select everything disapears off of the screen.

    I'm sorry, I didn't mean to upset you.

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    Quote Originally Posted by tbeaman View Post
    I did use your lisp file, I even copied it again this morning and tried it again.

    As soon as I type in test it says "SELECT OBJECTS IN CURRENT DRAWING OR XREF" and if I hit enter or try to select everything disapears off of the screen.

    I'm sorry, I didn't mean to upset you.
    The routine posted by Renderman above does not contain any prompts for user input. It does have some prompts stating "Reloading XREF" with the reference name of the xref.

    Do you have another routine that may be defined with the c:test name? Though, loading this routine into the drawing should overwrite any previously defined routines with the same name.

    Could you post your routine? Maybe someone can assist you in adding the two tasks together.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    Quote Originally Posted by tbeaman View Post
    I'm sorry, I didn't mean to upset you.
    No worries, you have not upset me. ... confused a bit, yes. But nothing more. lol

    Opie has an excellent point, I sometimes forget that we frequently use temporary command names (like c:TEST, or c:FOO, etc.) and this could have easily created a conflict.

    If you follow Opies suggestion(s) and post your current code, we'll help get it worked out, my friend.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  10. #10
    Certified AUGI Addict cadtag's Avatar
    Join Date
    2000-12
    Location
    Cairo - no, not Illinois
    Posts
    5,069
    Login to Give a bone
    0

    Default Re: Lisp to set Xref path

    maybe I'm missing something, but would not

    (command "-xref" "r" "*")

    give you the piece you need?

Page 1 of 4 1234 LastLast

Similar Threads

  1. Xref path - Saved path vs. Found at
    By jsowinski in forum AutoLISP
    Replies: 21
    Last Post: 2010-08-27, 06:11 AM
  2. Xref Path
    By Ehsan in forum AutoLISP
    Replies: 15
    Last Post: 2010-05-02, 04:44 AM
  3. Change Xref from Full Path to Relative Path
    By ccowgill in forum AutoLISP
    Replies: 6
    Last Post: 2009-05-27, 11:54 AM
  4. Xref path to no path
    By hostetterkl in forum AutoLISP
    Replies: 2
    Last Post: 2005-08-10, 09:48 PM
  5. Relevative Path vs Full Path Xref Swap *
    By tomdillenbeck in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2005-05-26, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •