+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30
  1. #1
    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 Modify Xref list

    Registered forum members do not see this ad.

    Hi,


    I have a list of Xrefs


    Xref_1 Xref_2 Xref_3_ELC Xref_4_ELC Xref_........


    I want to modify the list to only include items that have_ELC at the end.


    even better would be if i could only add Xrefs to my list that have _ELC at the end.


    both attempts below do not succeed.


    any ideas?




    Code:
    
    (defun c:findxref (/ td xrf)
      (setq XrfM nil)
     (while (setq td (tblnext "BLOCK" (not td)))
     (and (= (logand (cdr (assoc 70 td)) 4) 4)
     (setq xrf (cons (strcase (cdr (assoc 2 td))) xrf))
          )
       )
    (print xrf)
    
    
    ;attempt with Vl-remove
     (foreach n xrf
       (if (/= (wcmatch n "*_ELC")T) (vlremove n xrf)))
    
    
    
    
    ;Create new list
     (foreach n xrf
       (if (= (wcmatch n "*_ELC")T) (append n xrfm)))
    
    
      (print Xrf)
      (print Xrfm)
      (princ)
    )



    Thanks

  2. #2
    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,053

    Default

    Just a hint here .

    Code:
    (if (wcmatch n "*_ELC")
       (setq lst (append lst (list n)))
    )
    Last edited by Tharwat; 22nd Jun 2015 at 04:12 pm. Reason: missing function added

  3. #3
    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

    Thanks for the hint but
    it's just not happening for me, what am I missing from your hint?




    keeps returning Nil for Xrfm






    Code:
    (defun c:findxref (/ td xrf XrfM)
      (setq XrfM '())
     (while (setq td (tblnext "BLOCK" (not td)))
     (and (= (logand (cdr (assoc 70 td)) 4) 4)
     (setq xrf (cons (strcase (cdr (assoc 2 td))) xrf))
          )
       )
    (print xrf)
      
     (foreach n xrf
       (if (wcmatch n "*_ELC")    
           (setq XrfM (append  n Xrfm))
         
           )
    )
      
      (print Xrfm)
      (princ)
    )

  4. #4
    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,053

    Default

    I am sorry , I forgot to add the list function for the append function to work with lists .

    So just add the list function for the n variable to be able to append it to the list .

    eg.

    Code:
    (foreach n xrf
        (if (wcmatch n "*_ELC")
          (setq XrfM (append Xrfm (list n)))
        )
      )

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    Rather than removing the unwanted items from the resulting list, I would instead suggest omitting them within the initial loop, e.g.:
    Code:
    (defun c:findxref ( / 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 (cons xrn xrf))
            )
        )
        (print xrf)
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    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

    Thanks to you both, both Options are working for me.
    regards from Austria

  7. #7
    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,053

    Default

    Good for you feargt and you are welcome.

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    You're most welcome feargt
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #9
    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

    Hi again, related to same why am I getting an error message here


    I am trying to retrieve the X value of the Insertion Point of the xrefs in my list,
    but it returns an error. If i try Option 2 and enter the Xref Name at Position "n" and only enter that on the command line, then it works. any ideas what I am missing here


    Code:
    (foreach n xrf
        
    OPTION 1
       (setq ss (ssget "X" '((0 . "INSERT")(67 . 0)(2 . n)))) 
    (setq x (car (cdr (assoc 10 (entget ss)))))  
           
    OPTION 2
       (setq x (car (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . n))) 0))))))
      
    (print x)

  10. #10
    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,053

    Default

    Registered forum members do not see this ad.

    Try this .

    Code:
    (setq ss (ssget "_X" (list '(0 . "INSERT")'(67 . 0)(cons 2 (apply 'strcat (mapcar '(lambda (x) (strcat x ",")) xrf))))))

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