Selecting XREF in SSGET

Selecting XREF in SSGET

My_Civil_3D
Advocate Advocate
701 Views
2 Replies
Message 1 of 3

Selecting XREF in SSGET

My_Civil_3D
Advocate
Advocate

Hi guys i am trying to find a way to select all xref's in a drawing;

 

this is an example of the dxf data in my drawing but not sure which assoc number to look for. i have read that assoc 1 is an xref but in my data i do not have that 

 

(330 . <Entity name: 19f745a39f0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . ".RAILWAY") (100 . "AcDbBlockReference") (2 . "bbbbbbbbbbbbbbb") (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

Civil 3D Certified Professional
0 Likes
702 Views
2 Replies
Replies (2)
Message 2 of 3

Automohan
Advocate
Advocate
0 Likes
Message 3 of 3

paullimapa
Mentor
Mentor

assoc 1 is in the block table not in the original ssget so after ssget you'll have to get the block name and then search for this name in the block table to get that data and then check to see if there's assoc 1:

 

 

 

; ssxrf function to select all xrefs and returns selection set if any
; Example
; (ssxrf)
; returns selection set if xrefs
; returns nil if none
; Response to OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selecting-xref-in-ssget/m-p/11865848#M446035
(defun ssxrf (/ blknam blktbl ss sx)
  (if ; select all blocks not dynamic & no attributes
   (setq ss 
    (ssget"_X" 
     (list '(0 . "INSERT") 
            '(-4 . "<NOT") 
             '(-4 . "<OR") 
              '(66 . 1) 
               (cons 2 "`**") 
             '(-4 . "OR>") 
            '(-4 . "NOT>")
     ) ; list
    ) ; ssget
   ) ; setq
   (progn
    (setq sx (ssadd)) ; initialize xref selection set
    (foreach itm (mapcar 'cadr (ssnamex ss))  ; create list of all entities from selection set & cycle through
      (setq blknam (cdr (assoc 2 (entget itm)))) ; get block name
       (setq blktbl (tblsearch "BLOCK" blknam))  ; get block table
       (if 
         (or
           (member (cdr (assoc 70 blktbl)) '(4 12 36 44)) ; only valid if is xref
           (assoc 1 blktbl) ; only xrefs have paths
         )            
        (ssadd itm sx) ; add to xref selection set
       ) ; if
    ) ; foreach
    (if(zerop(sslength sx))(setq sx nil)) ; nullify when there are no selections
   ) ; progn
  ) ; if inserts
 sx ; return xref selection set
) ; defun

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos