TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: danny on May 20, 2005, 06:05:31 PM

Title: detach xref with similar name
Post by: danny 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"
Title: detach xref with similar name
Post by: danny on May 20, 2005, 06:06:14 PM
:lol:
Title: detach xref with similar name
Post by: Jeff_M 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)
  )
:)
Title: detach xref with similar name
Post by: danny 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*
Title: detach xref with similar name
Post by: Jeff_M on May 20, 2005, 07:55:19 PM
Just add them to the filter:
(ssget "x" '((2 . "*SiteandStream*,*MirmarOption*,*CoralReef*")))
Title: detach xref with similar name
Post by: danny on May 20, 2005, 09:31:32 PM
much Mahalo's Jeff, :)