Author Topic: how to know if there is a xref  (Read 5036 times)

0 Members and 1 Guest are viewing this topic.

DEVITG

  • Bull Frog
  • Posts: 479
how to know if there is a xref
« on: April 11, 2004, 04:52:43 PM »
There is any variable or other fact that can give if a drawinw had xref to it?

Mi intention is to verify if a drawing had a xref.
 :?:  :?:
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

hyposmurf

  • Guest
how to know if there is a xref
« Reply #1 on: April 11, 2004, 06:23:37 PM »
I suppose you mean after the XREF has been binded?Otherwise the XREF Manager will tell you.

DEVITG

  • Bull Frog
  • Posts: 479
how to know if there is a xref
« Reply #2 on: April 11, 2004, 06:53:37 PM »
Quote
Mi intention is to verify if a drawing had a xref.


I just want to know if a drawing has a xref or not , before doing nothing.
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

hyposmurf

  • Guest
how to know if there is a xref
« Reply #3 on: April 11, 2004, 06:58:57 PM »
Well your xref manager will tell you what xrefs you have attached,detached or unloaded.It wont tell you though what xrefs have been bound.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how to know if there is a xref
« Reply #4 on: April 11, 2004, 07:02:38 PM »
Try this.....

Code: [Select]

(defun C:ISXref ( / n name ndx sset strlist xreflist )
  (setq sset (ssget "x" '((0 . "insert"))))
  (setq ndx 0)
  (if sset
    (repeat (sslength sset)
      (setq name (cdr (assoc 2 (entget (ssname sset ndx)))))
      (if (>= (cdr (assoc 70 (tblsearch "block" name))) 4)
        (if (not (member name xreflist))
          (setq xreflist (append (list name) xreflist))
        )
      )
      (setq ndx (1+ ndx))
    )  
  )
  (if xreflist
   (setq strlist "\"This drawing contains these XRefs \" & vbCr & \"")
   (setq strlist "\"This drawing contains no XRefs \"")
  )  
  (foreach n xreflist
   (setq strlist (strcat strlist n "\" & vbCr & \""))
  )
  (command "vbastmt" (strcat "MsgBox " strlist))
)


Have fun....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hyposmurf

  • Guest
how to know if there is a xref
« Reply #5 on: April 11, 2004, 07:04:30 PM »
Cool that works  :).Did you just come up with that on the spot or have it tucked away?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how to know if there is a xref
« Reply #6 on: April 11, 2004, 07:09:07 PM »
On the spot
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hyposmurf

  • Guest
how to know if there is a xref
« Reply #7 on: April 11, 2004, 07:09:54 PM »
You little whiz! :)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how to know if there is a xref
« Reply #8 on: April 11, 2004, 07:10:30 PM »
:oops:
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
how to know if there is a xref
« Reply #9 on: April 11, 2004, 07:15:52 PM »
lol.

Hypo, once you know what each autolisp function does the coding is the pain in the butt part of code development. (Somtimes i hate writing code. ...it takes way to long to type out my thoughts.) kinda like driving. When you were 16 you wanted to drive everywhere and then when you got older you wanted that transporter thingie you saw in the startrek movie cause the drivng part was the crapy part.  
lol
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

DEVITG

  • Bull Frog
  • Posts: 479
vabastmt
« Reply #10 on: April 11, 2004, 07:25:04 PM »
Hi Keith , would you be so kind to explain the following feature??? :oops:


Quote
(setq strlist (strcat strlist n "\" & vbCr & \""))
  )
  (command "vbastmt" (strcat "MsgBox " strlist))


BTW: the ISXREF works great.
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
how to know if there is a xref
« Reply #11 on: April 11, 2004, 07:33:43 PM »
.. or if you just want a count, this will tell you how many are recorded in the database, not how many are displayed
Code: [Select]

(defun c:test (/ count)
  (setq count 0)
  (vlax-for each (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if (= (vla-get-isxref each) :vlax-true)
      (setq count (1+ count))
    )
  )
  count
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how to know if there is a xref
« Reply #12 on: April 11, 2004, 07:33:51 PM »
Well, I wanted to make the user aware of any xrefs located in the drawing....In LISP the alert window ... i.e.

Code: [Select]

(alert "blah blah blah")


is limited to the amount of information you can "effectively" put into it. So, rather than fight with calling the base acad.dcl file and loading the dialog for it etc.... I simply parsed the entire list of the xrefs in the drawing and added them to a string..that string would be formatted with the name of the xref n a quote " the VBA command for connecting strings & the VBA constant for a carriage return vbCr for the formatting in the message box, followed by another open quote " that would preceed the next xref name stored in the variable n.

Now, there is a command line call that you can use to call VBA commands simply by entering the VBA code directly on the command line. That command is vbastmt which is essentially "VBA Statement"
The bit of code following is the statement string that is passed to the command line.. opening a message box MsgBox and passing the string list of names and carriage returns strlist to the message box command.

and I am glad it works like it should....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hyposmurf

  • Guest
how to know if there is a xref
« Reply #13 on: April 12, 2004, 05:48:18 AM »
Quote from: Se7en
lol.

Hypo, once you know what each autolisp function does the coding is the pain in the butt part of code development. (Somtimes i hate writing code. ...it takes way to long to type out my thoughts.) kinda like driving. When you were 16 you wanted to drive everywhere and then when you got older you wanted that transporter thingie you saw in the startrek movie cause the drivng part was the crapy part.  
lol

I was just amazed that Keith was only online for a short while and he'd knocked together his own custom code for solution,tested it and posted it.Trully an art in itself,would be smart to be able to do that at work. :)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how to know if there is a xref
« Reply #14 on: April 12, 2004, 08:17:01 AM »
lol...
Well, I have done very similar things in the past, so I had a pretty good understanding how it should work...

Actually I changed the code significantly before I even posted it...I could be considered having written 2 versions and posting only the best one...

Here is what I initially put together (psudocode only)
Code: [Select]

select inserted blocks in drawing
extract block names and put them in a list
step through the block table extracting block names and putting them in a list if they are xrefs.
Step through the xref block list and see if any of them are in the inserted blocks list if they are put it in a new list
Display the new list (referenced xrefed blocks) on the command line


but I elected to make it like this
Code: [Select]

select inserted blocks in drawing
step through each block
extract block name
find block table reference of block name
if it is an xref put it in a list
format a text string
display text string in message box


It is somewhat smaller and I think easier to understand...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie