Author Topic: Select only xrefs in model space  (Read 1663 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Select only xrefs in model space
« on: January 30, 2008, 07:33:21 AM »
I'm looking for a way to select xrefs which are only in model space, anyone know of a way to do this?

Cheers in advance for your help.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

gile

  • Gator
  • Posts: 2510
  • Marseille, France
Re: Select only xrefs in model space
« Reply #1 on: January 30, 2008, 08:25:49 AM »
Hi,

To select all xrefs in model space, you can first create a string with all xref names separated with commas to be used in the selection set filter.

Code: [Select]
(setq str "")
(while (setq blk (tblnext "BLOCK" (not blk)))
  (if (cdr (assoc 1 blk))
    (setq str (strcat str (cdr (assoc 2 blk)) ","))
    )
  )

(setq ss (ssget "_X" (list '(0 . "INSERT") '(410 . "Model") (cons 2 str))))
Speaking English as a French Frog

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Select only xrefs in model space
« Reply #2 on: January 30, 2008, 09:17:06 AM »
Sorry, not trying to purposely make this appear obfuscated but it's what I had time to pen ...

Code: [Select]
(   (lambda ( xrefnames )   
        (if xrefnames
            (ssget "x"
                (append
                   '((0 . "insert")(67 . 1)(-4 . "<or"))
                    (mapcar
                       '(lambda ( name ) (cons 2 name))
                        xrefnames
                    )
                   '((-4 . "or>"))
                )
            )       
        )
    )
   
    (   (lambda ( / data result )
            (while (setq data (tblnext "block" (null data)))
                (if (eq 4 (logand 4 (cdr (assoc 70 data))))
                    (setq result (cons (cdr (assoc 2 data)) result))
                )
            )
            result
        )
    )   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst