Sorry about that I had someone come in the office and need some things and then had to run out to get my son.
I am staying at relatives house tonight to help get son to sleep and get him up because he is going to ride with them....... that does not matter but have no info, VS, AutoCAD, etc.... in front of me. So this is coming from where ever I can pull it out.
-The first obvious thing is to break up the function because it is just too much to
try to focus on at once. There are 4, 10 or however many databases,
transactions to keep up with.
-You are Wblocking the BlockReference. So you are creating a file that contains a
'insert' inserted at the same position.
If it has a different attribute (partnumber) it is fine, the problem comes in when there are multiples of the same part(block). In this case each block will be a part in the drawing
-You are using the PartNumber as the unique identifier. The only thing that
differentiates a xref from one another is the part number
-When a BlockReference with the same BlockDefinition have different values for
the part numbers a new file to xref is created. You are creating files to xref based
on the part number.
-Maybe you want a different 'xref' for each 'Part Number' but you are naming your
files and xref blockTableRecord with the textstring value of the AttributeReference.
If they have the same part number than they will come from last created file to xref, same block or not.
Give them all the same part number and see what happens.
It just keeps overwriting itself. Still not clear but would make more sense to me to
use block name
If I use this code it will bring all the blocks in as xref's each referencing the correct drawing but their positions are way off.
Dim bref As New BlockReference(Point3d.Origin, xrefObjId)
Dim scale As Scale3d = blkRef.ScaleFactors
bref.Position = blkRef.Position
First you set postion at the orgin then you change to the BlockReference's Position.
Again the reason it is off is because you create a file with a 'insert' at say (10,10) where it belongs. Then you xref it that and insert it a (10,10) so now it is at (20,20)
When you use Point3d.Origin the reason they are on top of each other is the same reason as explained above. If they have the same PartNumber they are Defined from the same definition which is the last file added with that part number.
So when you have multiple blockreferences and do NOT want a different xref for each insert I think it creates too much complexity creating the files to be xrefed with a BlockReference.
Which one do you choose?
Have to transform all the others.
etc....
There is probably better methods or to avoid it all together but if needed the first thing that comes to mind is wblock the definition so each entity is the same distance from the xref file orgin as it was in the definition. That way the Blcokreference insertion point could be used.
Use the BlockName as identifier so that way you could do something like
XrefID
If bt.Has("BlockName") then
XrefID = bt("BlockName")
Else
XrefID = db.AttachXref.......
End If
Blockref = new Blockreference(pnt, XrefID )
Sorry I am in hurry and hope that helps but tommorrow will be able to post something that maybe makes more sense.