Show prompt if any xrefs exist

Show prompt if any xrefs exist

Anonymous
Not applicable
1,108 Views
7 Replies
Message 1 of 8

Show prompt if any xrefs exist

Anonymous
Not applicable

Happy New Year to everyone Smiley Happy

 

Im working on a routine that suppose to run without any xrefs in the drawing. Need help on checking if theres any xref exist in the drawing.

if xref exist = show message

if no xref found = continue with routine

 

Thanks in advance! Smiley Happy

0 Likes
Accepted solutions (1)
1,109 Views
7 Replies
Replies (7)
Message 2 of 8

hmsilva
Mentor
Mentor
Accepted solution

One way

 

  (vl-load-com)
  (vlax-For blk
		(vla-Get-Blocks
		  (vla-Get-ActiveDocument (vlax-Get-Acad-Object))
		)
    (if	(= (vla-Get-IsXref blk) :vlax-True)
      (setq xr T)
    )
  )
  (if xr
      (alert "if xref exist = show message")
    (progn
      ;; if no xref found = continue with routine
      )
    )

 

 

Henrique

EESignature

0 Likes
Message 3 of 8

Anonymous
Not applicable

Thanks for the reply Henrique!

the code works as expected but when I open a dwg with xref and detach it then run the routine, it still says theres xref in the drawing.

 

Edit:

I tried to close and reopen and it worked fine. I guess this can work.

 

Thanks Henrique!Smiley Happy

0 Likes
Message 4 of 8

hmsilva
Mentor
Mentor

@Anonymous wrote:

Thanks for the reply Henrique!

the code works as expected but when I open a dwg with xref and detach it then run the routine, it still says theres xref in the drawing.

 

Edit:

I tried to close and reopen and it worked fine. I guess this can work.

 

Thanks Henrique!Smiley Happy


You're welcome, JCprog

 

You'll have to declare 'xr' as a local variable, and the test should work as expected without closing/reopen de dwg...

 

Henrique

 

EESignature

0 Likes
Message 5 of 8

Anonymous
Not applicable
nice! I learn something everyday 🙂 works perfect! Thanks again!
0 Likes
Message 6 of 8

hmsilva
Mentor
Mentor
You're welcome, JCprog
Glad I could help

Henrique

EESignature

0 Likes
Message 7 of 8

Lee_Mac
Advisor
Advisor

Another, returns T if one or more xrefs are defined in the active drawing:

 

(defun xrexists ( / def flg )
    (while
        (and
            (setq def (tblnext "block" (null def)))
            (not (setq flg (= 4 (logand 4 (cdr (assoc 70 def))))))
        )
    )
    flg
)

 

0 Likes
Message 8 of 8

Anonymous
Not applicable
Thanks for the code Lee! you guys are awesome! 🙂
0 Likes