Author Topic: Finding xrefs amongst the blocks  (Read 2670 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Finding xrefs amongst the blocks
« on: April 13, 2006, 12:47:41 PM »
So, I was a wonder'n, is there any way of finding unwanted miscellaneous xrefs among needed xrefs and blocks inserted in a drawing?
I know the tblsearch puts xrefs and blocks into the same category, and I'm looking for a way to distinguish between xrefs and blocks so I can detach any unwanted xrefs and keep those I need.  Unfortunately, the names of the unwanted xrefs are random so I can't be specific when searching those out.

I'm also trying to find a way to detach any undefined or unreferenced images, again, the names are random with the dwg.

Any ideas ???
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Finding xrefs amongst the blocks
« Reply #1 on: April 13, 2006, 12:55:48 PM »
I don't the benefit of free time right now to yack, but here's a couple of posts to get the gearrs turning --

Post 1

Post 2

Search around the swamp, there's tons here.

Good luck.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: Finding xrefs amongst the blocks
« Reply #2 on: April 13, 2006, 04:20:38 PM »
So, I was a wonder'n, is there any way of finding unwanted miscellaneous xrefs among needed xrefs and blocks inserted in a drawing?
I know the tblsearch puts xrefs and blocks into the same category, and I'm looking for a way to distinguish between xrefs and blocks so I can detach any unwanted xrefs and keep those I need.  Unfortunately, the names of the unwanted xrefs are random so I can't be specific when searching those out.

I'm also trying to find a way to detach any undefined or unreferenced images, again, the names are random with the dwg.

Any ideas ???

This is not a standalone dialog routine, but if you want to go on a fishing trip, you can fish out what you need.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Binky

  • Guest
Re: Finding xrefs amongst the blocks
« Reply #3 on: April 14, 2006, 09:02:51 AM »
I needed to sift the xref's out awhile back.  I used TBLNEXT to cycle through all of theblock entities.  I then tested for the presence of ASSOC code 1.  If it was there then it's an xref, if not it's a block.  Not sure how to tell between wanted and unwanted xref's but this will put them in front of you one at a time so you can evaluate them to your criteria.

(defun c:siftxref (/ entry xname xpath )
  (while
    (setq entry (tblnext "block" (not entry)))
    (if (cdr (assoc 1 entry))
      (progn
        ;;;whatever it was you wanted to do;;;
      );_end progn
    );_end if
  );_end while
(princ));_end function

I can not speak to images.  I have not messed with them at all.

Hope this helps some.



Hangman

  • Swamp Rat
  • Posts: 566
Re: Finding xrefs amongst the blocks
« Reply #4 on: April 14, 2006, 02:23:40 PM »
Binky, Thanks for the info.  That's more or less what I was looking for, ASSOC code 1.
There are times we get architects dwgs with orphaned xrefs and other miscellaneous items that we have to manually search for.  It's a nightmare.  So I'm trying to find a way I can have a lisp search and detach any orphaned and/or nested xrefs within xrefs that they have attached to the dwgs.

I've still got to go search MP's referenced posts.  Too busy to breathe at the moment.

Thanks again.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Finding xrefs amongst the blocks
« Reply #5 on: April 14, 2006, 02:35:32 PM »
If you're trying to determine xrefs via dxf codes I must tell you it's better to test on the basis of the block-flags value (dxf group 70) as specified in the AutoCAD DXF Reference (DXF Reference -> Blocks Section -> Blocks). The value you need to test for (bit wise) is 4.

For example --

Code: [Select]
(defun GetXrefs ( / data result )
    (while (setq data (tblnext "block" (null data)))
        (if (eq 4 (logand 4 (cdr (assoc 70 data))))
            (setq result
                (cons
                    (cdr (assoc 2 data))
                    result
                )
            )
        )
    )
    result
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Binky

  • Guest
Re: Finding xrefs amongst the blocks
« Reply #6 on: April 14, 2006, 03:02:03 PM »
I stopped looking for an answer when I found something that would work, I confess to being impatient.  But I would have to agree that MP's test of code 70 is better then my code 1.  It would certianly make more sense if you came back to the code later and tried to figure out what you were doing.

always a better mouse trap out there somewhere.