Author Topic: Find XREF Block Reference from Object...  (Read 2795 times)

0 Members and 1 Guest are viewing this topic.

jhsct

  • Mosquito
  • Posts: 5
Find XREF Block Reference from Object...
« on: February 27, 2015, 04:02:26 PM »
Hello

I am automatically selecting objects for the user and I have a reference to an object in a Model - basically the ObjectID.  I want to find out which xRef (blockreference) it comes from.  The users will take a single xREF and insert it multiple times at different location and i want to find the XREF blockreference position.

If the user selects the object then we could use the getcontainers procedure but in this case I just have the object.  Is there a way?

Needing some direction... 

Thank you
« Last Edit: February 27, 2015, 06:16:02 PM by jhsct »

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Find XREF Block Reference from Object...
« Reply #1 on: February 27, 2015, 09:03:39 PM »
If the object is displayed in multiple xref instances, then you need some way of resolving which of those possible instances you're interested in.

jhsct

  • Mosquito
  • Posts: 5
Re: Find XREF Block Reference from Object...
« Reply #2 on: February 27, 2015, 10:53:55 PM »
My thought is there must be something in the object itself that i could look at and track back up to the xref (block reference) owner...but I don't see it at this point.

My only other thought is as follows...

I know the ObjectID...so search find all XREF blocks and then search each XREF Block Reference for the objectID of the object...

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Find XREF Block Reference from Object...
« Reply #3 on: February 28, 2015, 08:19:41 AM »
Every reference the object's owning xref will include the same reference to the same object. There are not different objects in each instance. Only the block reference entity itself is different from instance to instance.

jhsct

  • Mosquito
  • Posts: 5
Re: Find XREF Block Reference from Object...
« Reply #4 on: March 01, 2015, 12:00:07 PM »
Hello,

I guess I'm missing something fundamental.  If a block reference is inserted into a drawing twice then it is in two locations and the objects inside the xref are shown in two locations - I believe with their own object IDs.  If you have an objects of a component inside one of the block references I would think I could find the specific block reference it is located inside of...not just the block table record or the database reference (which is the same for both objects)

I guess I should back up my thought process...

I have an xref inserted in a drawing and the reference is shown in a position other than 0,0,0. 

If you are in a viewport and cycle through each object in the model and then use the Autodesk.AutoCAD.Internal.Utils.SelectObjects on each individual object, the selection grips AutoCAD shows are not on the object in the XREF.  They are offset from the actual object displayed by AutoCAD by the exact distance where the XREF Block Reference is offset.  I assume this is a bug in AutoCAD because if you put a solid around the xREF and do a clash with the object...AutoCAD (in terms of the clash location) believes the object is where the grips are shown above...not the true location of where its drawn or in fact where the xREF Block Reference refers to.

Does that make any sense???

Anyhow, i need the XREF Block Reference so I can perform a transform on the object to get the correct location...

I must be missing something.  I need a way to get to the specific XREF Block reference from the object reference...



owenwengerd

  • Bull Frog
  • Posts: 451
Re: Find XREF Block Reference from Object...
« Reply #5 on: March 01, 2015, 02:04:53 PM »
Sorry, I'm not sure how I can state it any more clearly.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Find XREF Block Reference from Object...
« Reply #6 on: March 01, 2015, 02:25:18 PM »
There are not different objects in each instance.
That is about as clear as it be stated.

Think of a BlockReference as a way to display the objects inside a BlockTable with a Transformations applied.

When you have 2 BlockReferences the are displaying the same objects but transforming the objects from origin of the BlockTableRecord to the insertion point, and rotating, etc.......

Its just a transformation of the same group of objects and it does not contain the objects(BlockReferences can contain Attributes)