You just skip the constant attributes.
They aren't attached to the insertion, they're stored in the block's definition.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message
news:6339139@discussion.autodesk.com...
I am creating a new blockreference object based on the block definition already
present in the BlockTable.
BlockReference br = new BlockReference(pt, bdId); //where bdId is the
objectId of the block
I am then cycling through the ObjectIds in the BlockTableRecord and if they are
AttributeDefinitions then I attach them to the new blockreference:
BlockTableRecord bd = (BlockTableRecord)tr.GetObject(bdId, OpenMode.ForRead);
foreach (ObjectId attId in bd)
{
//Open the Object for reading
Entity ent = (Entity)tr.GetObject(attId, OpenMode.ForRead);
//Check whether it is an Attribute or not
if (ent is AttributeDefinition)
{
//Get the Definition
AttributeDefinition ad = (AttributeDefinition)ent;
//Set up a new attribute reference
AttributeReference ar = new AttributeReference();
//Add the attribute definition to the attribute reference
ar.SetAttributeFromBlock(ad, br.BlockTransform);
//Add the Attribute reference to the new block
br.AttributeCollection.AppendAttribute(ar);
//Use the transaction to commit the changes
tr.AddNewlyCreatedDBObject(ar, true);
} //End If ent
} //End For Loop
Question is: Each of the blocks has 2 attributes that are defined as Constants
on the original BlockTableRecord, but when I use the code above to copy them
over to the new blockreference they are no longer Constants. How do I copy them
over and retain the original status?