+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 30 of 30
  1. #21
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    Registered forum members do not see this ad.

    my line of thining was the following


    Get list of Xref names with "*_ELC" at the end


    For each Xref in list
    get Insertion Point
    insert first new xref at Insertion Point
    insert second new xref at Insertion Point

  2. #22
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    Quote Originally Posted by Tharwat View Post
    With the function vla-put-path would take care of all and using codes much better than using commands as you are planning to.


    but wont that only work with an Xref that already exists in my drawing?

  3. #23
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    Quote Originally Posted by feargt View Post
    insert first new xref at Insertion Point
    insert second new xref at Insertion Point
    Can you explain these two phrases a little bit more ?

  4. #24
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    for example


    XREF_1_ELC and XREF_2_ELC exist in my drawing .


    they will be replaced with 2 Xrefs each


    XREF_1_ELC_Sub_1 & Xref_1_ELC_Sub_2


    XREF_2_ELC_Sub_1 & Xref_2_ELC_Sub_2


    These must be inserted at the same Insertion Point as the original XREF

  5. #25
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    Quote Originally Posted by feargt View Post
    for example

    XREF_1_ELC and XREF_2_ELC exist in my drawing .

    they will be replaced with 2 Xrefs each

    XREF_1_ELC_Sub_1 & Xref_1_ELC_Sub_2

    XREF_2_ELC_Sub_1 & Xref_2_ELC_Sub_2

    These must be inserted at the same Insertion Point as the original XREF
    So did you or were you able to test the program that I posted in post No# 14 ?

  6. #26
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    no, I didn't test it because that will only replace the existing Xref, and will not insert the second xref

  7. #27
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    Quote Originally Posted by feargt View Post
    no, I didn't test it because that will only replace the existing Xref, and will not insert the second xref
    You are wrong , as I said before after running the program you need to save and close and open the drawing again to see the changes .

  8. #28
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    Quote Originally Posted by Tharwat View Post
    Code:
    (defun c:test (/ lst fnd pth)
      ;; Tharwat 23.06.2015 ;;
      (setq lst '(("Xref_1_ELC" "Xref_1_ELC_Sub1") ("Old" "New")))
      (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
        (if (and (= :vlax-true (vla-get-isxref blk))
                 (setq fnd (assoc (vla-get-name blk) lst))
                 (setq pth (findfile (strcat (cadr fnd) ".dwg")))
            )
          (vla-put-path blk pth)
        )
      )
      (princ)
    )(vl-load-com)

    "Xref_1_ELC" needs to be replaced by 2 Xrefs"Xref_1_ELC_Sub1" and "Xref_1_ELC_Sub_2"






    on a side note:
    adding (vla-reload blk) to the end of the code would probably avoid having to save and reopen the drawing to see the Change


    http://forums.autodesk.com/t5/visual...h/td-p/3312595

  9. #29
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    by the way I do really appreciate your assistance on this!

  10. #30
    Senior Member
    Computer Details
    feargt's Computer Details
    Operating System:
    win 7
    Using
    Civil 3D 2012
    Join Date
    Sep 2008
    Location
    Austria
    Posts
    428

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Lee Mac View Post
    Code:
    (defun c:findxref ( / idx ins sel td xrf xrn )
        (while (setq td (tblnext "block" (not td)))
            (and (= (logand (cdr (assoc 70 td)) 4) 4)
                 (wcmatch (setq xrn (strcase (cdr (assoc 2 td)))) "*_ELC") ;; Must pass this criteria before being added to the list
                 (setq xrf (vl-list* "," xrn xrf))
            )
        )
        (if (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (cdr xrf))))))
            (progn
                (repeat (setq idx (sslength sel))
                    (setq ins (cons (cadr (assoc 10 (entget (ssname sel (setq idx (1- idx)))))) ins))
                )
                (print ins)
            )
            (princ "\nNo xrefs found.")
        )
        (princ)
    )



    was able to solve my problem using the code from Lee Mac by making the following modifications which gave the Name and the Insertion Point. Then while in the Repat funtion I was able to add my xrefs using the Insertion Point and delete the original.


    Code:
    
    (defun c:findxref ( / idx ins sel td xrf xrn Xrn2 xrefN Path)
      (setq pfad "C:/XXXX/Xrefs/")
         (while (setq td (tblnext "block" (not td)))
            (and (= (logand (cdr (assoc 70 td)) 4) 4)
                  (wcmatch (setq xrn (strcase (cdr (assoc 2 td)))) "*_ELC") ;; Must pass this criteria before being added to the list
                  (setq xrf (vl-list* "," xrn xrf))
             )
         )
         (if (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (cdr xrf))))))
             (progn
                 (repeat (setq idx (sslength sel))
                     (setq ins (cadr (assoc 10 (entget (ssname sel (setq idx (1- idx)))))))
                    (setq xrn2 (cdr (assoc 2 (entget (ssname sel idx)))))
                    (print (strcat xrn2 " at " (rtos x)))
            (setq xrefn (vl-string-subst "_ELC_Sub1.dwg" "_ELC" (strcase xrn2)))
           (if (findfile (strcat pfad xrefn)) (command "_.-XREF" "_overlay" (strcat pfad xrefn) (strcat (rtos x) ",0,0") "1" "1" "0"))
    (setq xrefn (vl-string-subst "_ELC_Sub2.dwg" "_ELC" (strcase xrn2)))
           (if (findfile (strcat pfad xrefn)) (command "_.-XREF" "_overlay" (strcat pfad xrefn) (strcat (rtos x) ",0,0") "1" "1" "0"))
    
                 )
                 
             )
             (princ "\nNo xrefs found.")
         )
         (princ)
    )
    Probably not the most eloquent method but it achieves the purpose!!


    Thanks again for all your help Tharwat and Lee!

Similar Threads

  1. Modify xref path in Acad LT 2012
    By deano33 in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 20th Jun 2012, 05:46 pm
  2. Replies: 0
    Last Post: 23rd Nov 2011, 03:16 am
  3. Xref Drawing List
    By TomC in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 23rd Dec 2009, 06:24 am
  4. Modify, bind, Explode XREF?
    By mikew0ng in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 14th Aug 2006, 10:08 pm
  5. Modify > In place xref and block edit
    By edortizr6 in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 26th Jul 2006, 02:00 pm

Tags for this Thread

Bookmarks

Posting Permissions

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