Is An Xref Nested

Is An Xref Nested

Jason.Piercey
Advisor Advisor
2,185 Views
34 Replies
Message 1 of 35

Is An Xref Nested

Jason.Piercey
Advisor
Advisor

I currently have a need for simply knowing if an xref is nested. Looking through my toolbox functions I have code for determining that based on user selection of a nested object (nentsel) but that doesn't fit my current requirements.  Hard to believe those functions were written some 23 years ago! Wow.

 

Anyway, it's been a long time since I've written much code so I'm a wee bit rusty.  Is testing for and/or using DXF code 102 enough for a nested determination?  Seems to work in my limited testing.

 

; determine if the specified block name is a nested xref
; Arguments:
; [document] vla-object, document object
; [name] string, xref name
; Return: T or nil
(defun nestedXref-p (document name / object)
  (and
    (setq object (vla-item (vla-get-blocks document) name))
    (= :vlax-true (vla-get-isxref object))
    (not (assoc 102 (entget (vlax-vla-object->ename object))))
    )
  )

 

0 Likes
Accepted solutions (1)
2,186 Views
34 Replies
Replies (34)
Message 21 of 35

komondormrex
Mentor
Mentor

well, it is NOT a my method) just sort of observation😁

0 Likes
Message 22 of 35

komondormrex
Mentor
Mentor

wow, i am trying to walk in your shoes)))

0 Likes
Message 23 of 35

Kent1Cooper
Consultant
Consultant

I think part of the difficulty, if you're talking about determining whether an Xref'd drawing of a certain name is nested or not, is that the same drawing can be both within the same host drawing.  DrawingA can be Xref'd into DrawingB, and in DrawingC, DrawingB can be Xref'd in containing the nested DrawingA, and DrawingA itself can also be Xref'd directly in DrawingC.  So if you try to investigate DrawingA as an Xref in DrawingC, is it nested or not?  It's both.

Kent Cooper, AIA
0 Likes
Message 24 of 35

ronjonp
Mentor
Mentor

@Kent1Cooper I think what you're referring to is a circular reference. Which can be done but is not common.

ronjonp_0-1682524454705.png

Even though 'A' is contained within 'B' and 'C', in the circular reference of 'B' and 'C' back to 'A' the link is broken.

ronjonp_1-1682524752044.png

That is if I followed your post correctly 🙂 .

 

This is exactly why I preach OVERLAY.

 

0 Likes
Message 25 of 35

Kent1Cooper
Consultant
Consultant

@ronjonp wrote:

.... I think what you're referring to is a circular reference. ....


I wasn't describing a circular reference -- A would not host anything in what I was talking about, which is this situation:
Kent1Cooper_0-1682528012143.png

in which A is Xref'd into C both nested and not-nested.

Kent Cooper, AIA
0 Likes
Message 26 of 35

ronjonp
Mentor
Mentor

@Kent1Cooper Gotcha. So nested and not nested :). As you can see I'm a visual learner. 😁

ronjonp_0-1682531278109.png

 

(nestedxref-p "B")
;; T

0 Likes
Message 27 of 35

john.uhden
Mentor
Mentor

Hi, @Jason.Piercey ,

Haven't heard from you in years.  Then again, I was gone for about 10 of them.

1st - be careful with the use of vla-item.  If the item exists it gets returned, but if it doesn't, it errors out.

         Better to use tblsearch.

2nd - nentsel can do it all by returning the list of objects in parental order.

John F. Uhden

0 Likes
Message 28 of 35

Jason.Piercey
Advisor
Advisor

I considered using a selection set as a test but would rather avoid it if possible.

0 Likes
Message 29 of 35

Jason.Piercey
Advisor
Advisor

Hi @john.uhden, it's always nice to see some old timers still around here.  When searching this forum I ran across another discussion of ours (from some 20 years ago!) about changing paths of xrefs and we brought up the child/parent relationships during that time. 

 

Regarding vla-item, thanks. I would likely end up wrapping that to trap any errors. I mentioned (nentsel) in my initial post but this specific task really needs to be free of user selection.

 

Nice to hear from you.

0 Likes
Message 30 of 35

john.uhden
Mentor
Mentor

@Jason.Piercey ,

Thanks for responding.

My aged brain is not seeing how you would search for a nested block insertion, especially if it's an attachment, not an overlay, though that may not make any difference, whereas grabbing any piece of it from the screen will divulge a family tree.  But beware, you may find that your sister is also your aunt. 😧

John F. Uhden

0 Likes
Message 31 of 35

Jason.Piercey
Advisor
Advisor

@john.uhden 

This little bit of automation I'm attempting is to speed up the process of making sheet set templates project specific. Copy a group of DWG files (and associated DST file) to a project folder then modify their internal and external names accordingly.

 

I prefix project specific files with the project number (the template uses 00-0000) so I'm looking for a quicker way to rename those files internally (and ensure relative paths while I'm at it.) Externally is a bit easier, for everything except plot sheets, with "bulk rename" software. Per our 20 year old conversation mentioned above about repathing xrefs, we touched on the nested topic and how those nested paths would be restored to their previous state upon reopening/reloading.  I'm sure your can see why user selection isn't all that desirable in this case.

 

As far as I can tell Autodesk's Reference Manager allows repathing but not renaming so that is of no use, unfortunately. The link that paullimapa provided above appears to work but makes my head hurt looking at it. Perhaps I can use it "to get the job done" but ultimately I was hoping to streamline/simplify the process.

 

Thanks for chiming in.

0 Likes
Message 32 of 35

john.uhden
Mentor
Mentor

@Jason.Piercey ,

I'll betcha any number of prime contributors here could figure it out.

I'm thinking just sift through every block in the drawing and check the OwnerIDs.

John F. Uhden

0 Likes
Message 33 of 35

Jason.Piercey
Advisor
Advisor

@john.uhden 

 

I was looking at OwnerID properties but couldn't quite wrap my head around the relationships between objects. Maybe I'll explore that further as time permits. Where is the old dbview.arx when you need it?

0 Likes
Message 34 of 35

john.uhden
Mentor
Mentor

Jason,

I took a few minutes chasing down vla-objectidtoobject, but I messed up.  Gotta find some time to get it right; maybe in some old code.  This weekend is probably shot with opening the pool and power washing the deck.

John F. Uhden

0 Likes
Message 35 of 35

ronjonp
Mentor
Mentor

@john.uhden 

Lee's nestedxref-p works well. I linked to it HERE.

0 Likes