I have copied a blockReference that was in my first file dwg to an existing file with the method WblockCloneObjects method. I have set the position of this blockReference and it worked fine.
The problem is when I change the attributeReference textString property, My blockReference change the position and the value of the attribute isn't visible in the blockReference.
Here it is my code:
private bool SetIssueNumber(Transaction toTransaction, BlockReference deepClonedIssue, string identifier)
{
//Get the attributeCollection
Autodesk.AutoCAD.DatabaseServices.AttributeCollection attrCollection = deepClonedIssue.AttributeCollection;
//Get the object
foreach (ObjectId idAttrReference in attrCollection)
{
AttributeReference attributeReference =
toTransaction.GetObject(idAttrReference, OpenMode.ForWrite) as AttributeReference;
if (attributeReference == null)
return false;
if (attributeReference.Tag.Equals("ISSUENUMBER"))
{
attributeReference.TextString = identifier;
return true;
}
}
return false;
}
When I remove:
attributeReference.TextString = identifier;
The blockReference shows up in the expecting position but When it's executed, I observe that the position change and the value of attribute doesn't show up.
Not sure how you're deepcloning the block reference, but you may also need to transform (move/rotate/scale) the attribute. Here is the method with notes from the help file.