Author Topic: detach xref with similar name  (Read 2660 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
detach xref with similar name
« on: May 20, 2005, 06:05:31 PM »
I was trying to detach a bunch of xrefs with similar names.  here's my try
Code: [Select]
(defun c:xrdetach ()
  (setq sset
(ssget
  "x"
  '((2 . "*SiteandStream*"))
)
  )
  (if sset
    (repeat (sslength sset)
      (command "_.xref" "detach" sset)
    )
  )
)

I was hoping that the asteric would dork similar with xrefs as it does with layers.
Here is a few examples of xrefs I'm trying to detach
Quote
IMP-DrawingSheet-AS-108-PARKINGPLANS-IMPSiteandStream.rvt-1.dwg
IMP-DrawingSheet-AS-104-OVERALLLEVEL2FLOOR-GRIDPLAN-IMPSiteandStream.rvt-1.dwg
IMP-DrawingSheet-AH-104-BUILDINGHLEVEL1REFLCEILINGPLAN-IMPSiteandStream.rvt-1.dwg

You can see that they all have different names, but are similar by having "SiteandStream"

danny

  • Guest
detach xref with similar name
« Reply #1 on: May 20, 2005, 06:06:14 PM »
:lol:

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
detach xref with similar name
« Reply #2 on: May 20, 2005, 07:24:32 PM »
Well since the Xref-delete command asks for the name of the xref, you should pass that to it. You were close:
Code: [Select]

(defun c:xrdetach (/ sset idx xrname)
  (setq   sset
    (ssget
      "x"
      '((2 . "*SiteandStream*"))
    )
  )
  (if sset
    (progn
      (setq idx 0)
      (repeat (sslength sset)
(setq xrname (cdr (assoc 2 (entget (ssname sset idx)))))
(command "_.xref" "detach" xrname)
(setq idx (1+ idx))
)
      )
    )
  (princ)
  )
:)

danny

  • Guest
detach xref with similar name
« Reply #3 on: May 20, 2005, 07:31:13 PM »
hmm...intresting.
what if I had a list of xrefs to delete say
Quote
*SiteandStream*
*MirmarOption*
*CoralReef*

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
detach xref with similar name
« Reply #4 on: May 20, 2005, 07:55:19 PM »
Just add them to the filter:
(ssget "x" '((2 . "*SiteandStream*,*MirmarOption*,*CoralReef*")))

danny

  • Guest
detach xref with similar name
« Reply #5 on: May 20, 2005, 09:31:32 PM »
much Mahalo's Jeff, :)