Author Topic: Select everything in modelspace EXCEPT xrefs  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Select everything in modelspace EXCEPT xrefs
« on: September 20, 2007, 11:43:49 AM »
How?

I assume I'm going to need some type of selection set, right?  But I'm not sure how to filter out just xrefs.

deegeecees

  • Guest
Re: Select everything in modelspace EXCEPT xrefs
« Reply #1 on: September 20, 2007, 11:49:58 AM »
In "Developer Help", do a search on "Relational Tests", this should getcha goin'.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Select everything in modelspace EXCEPT xrefs
« Reply #2 on: September 20, 2007, 11:51:05 AM »
Give this a try:

Code: [Select]
(defun getallbutxrefs (/ ss lst)
  (if (setq ss (ssget "x"))
    (progn
      (setq ss (mapcar 'cadr (ssnamex ss)))
      (mapcar '(lambda (x)
(if (and (not (vlax-property-available-p
(vlax-ename->vla-object x)
'Path
       )
  )
  (equal (cdr (assoc 410 (entget x))) "Model")
     )
   (setq lst (cons x lst))
)
       )
      ss
      )
      lst
    )
  )
)

*updated to only select modelspace objects
« Last Edit: September 20, 2007, 11:57:22 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Select everything in modelspace EXCEPT xrefs
« Reply #3 on: September 20, 2007, 11:51:40 AM »
Cycle through the blocks collection looking for Xrefs. When found, add the names to a string variable such that the final string looks like: "Block1,Block2,Block3" This will be the Name portion of your filter to exclude.

ASMI

  • Guest
Re: Select everything in modelspace EXCEPT xrefs
« Reply #4 on: September 20, 2007, 02:16:30 PM »
Or

Code: [Select]
(defun notXRefsList(/ objLst)
  (vl-load-com)
  (vlax-for itm(vla-get-ModelSpace
(vla-get-ActiveDocument
   (vlax-get-acad-object)))
    (if(not(vlax-property-available-p itm 'Path))
      (setq objLst(cons itm objLst))
      ); and if
    ); end vlax -for
  ); end of notXRefsList

Maybe need selection set not list?

ASMI

  • Guest
Re: Select everything in modelspace EXCEPT xrefs
« Reply #5 on: September 20, 2007, 02:47:38 PM »
With SelectionSet:

Code: [Select]
(defun notXrefsSet(/ sSet cObj fStr)
  (setq cObj(tblnext "BLOCK" T)
fStr ""); end setq
  (while cObj
    (if(=(logand(cdr(assoc 70 cObj))4)4)
      (setq fStr(strcat fStr(cdr(assoc 2 cObj))","))
      ); end if
      (setq cObj(tblnext "BLOCK"))
    ); end while
  (if(/= fStr "")
    (ssget "_X" (list '(410 . "Model")
  '(-4 . "<NOT")(cons 2 fStr)'(-4 . "NOT>")))
    ); end if
  ); end of notXrefsSet

Does anyone know, is restriction for filter strings length or not? (cons 2 fStr) can be very long if many Xrefs...