Jump to content

Detach Specific Xref


cmchadwick

Recommended Posts

Hi,

 

Try this code:

(defun DetachXref (name / xref)
 ;; Tharwat - Date: 14.Mar.2017 ;;
 (if (and (not (vl-catch-all-error-p (setq xref (vl-catch-all-apply 'vla-item
                                                  (list
                                                    (vla-get-blocks
                                                      (vla-get-activedocument (vlax-get-acad-object))
                                                      )
                                                    name
                                                    )
                                                  )
                                           )
                 )
               )
          (= :vlax-true (vla-get-isxref xref))
          )
   (vla-detach xref)
   )
 (princ)
 ) (vl-load-com)

Link to comment
Share on other sites

  • 2 years later...

Sorry for being so dense. What is text that issues this command DETACHXREF?

I want to detach drawing named ca-dan.dwg, would I update lisp like so?

(defun DetachXref (name / xref)
 ;; Tharwat - Date: 14.Mar.2017 ;;
 (if (and (not (vl-catch-all-error-p (setq xref (vl-catch-all-apply 'vla-item
                                                  (list
                                                    (vla-get-blocks
                                                      (vla-get-activedocument (vlax-get-acad-object))
                                                      )
                                                    (detachxref "ca-dan")
                                                    )
                                                  )
                                           )
                 )
               )
          (= :vlax-true (vla-get-isxref xref))
          )
   (vla-detach xref)
   )
 (princ)
 ) (vl-load-com)
Link to comment
Share on other sites

I gave you the answer (detachxref "ca-dan") or (detachxref "some variable value as a string") its in your code not Tharwat's.

 

(defun DetachXref (name / xref)
………...
)

(setq xname (getstring "Enter name of xref to remove"))
(detachxref xname)

or

(detachxref (getstring "Enter name of xref to remove")) 

or pick xref and get its name.

 

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...