.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Set AttributeR eference as Constant?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
159 Views, 2 Replies
09-14-2005 10:51 AM
I have a block table record that has a collection of attribute definitions on it, some of which are set up as constants. When I create a block reference based off of this block table record and go to create the attribute references corresponding to the attribute definitions, I cannot figure out how to specify the attribute references as constant. SetPropertiesFrom doesn't seem to do it. Any ideas?
Transaction trans = doc.TransactionManager.StartTransaction();
ObjectId idResult = ObjectId.Null;
try
{
// Get the model space block table
BlockTable bt = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
BlockTableRecord btrInsert = trans.GetObject(idBlock, OpenMode.ForRead) as BlockTableRecord;
// Create the new block reference
BlockReference br = new BlockReference(pt3DPos, idBlock);
btr.AppendEntity(br);
trans.AddNewlyCreatedDBObject(br, true);
// Update the attributes on the block
foreach (ObjectId id in btr)
{
Entity ent = trans.GetObject(id, OpenMode.ForRead, false) as Entity;
if (ent is AttributeDefinition)
{
AttributeReference attRef = new AttributeReference();
AttributeDefinition attDef = ent as AttributeDefinition;
attRef.SetPropertiesFrom(attDef);
attRef.Position = new Point3d(attDef.Position.X + br.Position.X,
attDef.Position.Y + br.Position.Y,
attDef.Position.Z + br.Position.Z);
attRef.Height = attDef.Height;
attRef.Rotation = attDef.Rotation;
attRef.Tag = attDef.Tag;
attRef.Invisible = attDef.Invisible;
br.AttributeCollection.AppendAttribute(attRef);
trans.AddNewlyCreatedDBObject(attRef, true);
}
}
idResult = br.ObjectId;
trans.Commit();
}
finally {trans.Dispose(); }
Transaction trans = doc.TransactionManager.StartTransaction();
ObjectId idResult = ObjectId.Null;
try
{
// Get the model space block table
BlockTable bt = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
BlockTableRecord btrInsert = trans.GetObject(idBlock, OpenMode.ForRead) as BlockTableRecord;
// Create the new block reference
BlockReference br = new BlockReference(pt3DPos, idBlock);
btr.AppendEntity(br);
trans.AddNewlyCreatedDBObject(br, true);
// Update the attributes on the block
foreach (ObjectId id in btr)
{
Entity ent = trans.GetObject(id, OpenMode.ForRead, false) as Entity;
if (ent is AttributeDefinition)
{
AttributeReference attRef = new AttributeReference();
AttributeDefinition attDef = ent as AttributeDefinition;
attRef.SetPropertiesFrom(attDef);
attRef.Position = new Point3d(attDef.Position.X + br.Position.X,
attDef.Position.Y + br.Position.Y,
attDef.Position.Z + br.Position.Z);
attRef.Height = attDef.Height;
attRef.Rotation = attDef.Rotation;
attRef.Tag = attDef.Tag;
attRef.Invisible = attDef.Invisible;
br.AttributeCollection.AppendAttribute(attRef);
trans.AddNewlyCreatedDBObject(attRef, true);
}
}
idResult = br.ObjectId;
trans.Commit();
}
finally {trans.Dispose(); }
*Tony Tanzillo
Re: Set AttributeR eference as Constant?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-14-2005 08:15 PM in reply to:
brianroth
There are no attribute references for constant
attribute definitions. Constant attributes are
essentially like text in the block's definition.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
wrote in message news:4956361@discussion.autodesk.com...
I have a block table record that has a collection of attribute definitions on it, some of which are set up as constants. When I create a block reference based off of this block table record and go to create the attribute references corresponding to the attribute definitions, I cannot figure out how to specify the attribute references as constant. SetPropertiesFrom doesn't seem to do it. Any ideas?
Transaction trans = doc.TransactionManager.StartTransaction();
ObjectId idResult = ObjectId.Null;
try
{
// Get the model space block table
BlockTable bt = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
BlockTableRecord btrInsert = trans.GetObject(idBlock, OpenMode.ForRead) as BlockTableRecord;
// Create the new block reference
BlockReference br = new BlockReference(pt3DPos, idBlock);
btr.AppendEntity(br);
trans.AddNewlyCreatedDBObject(br, true);
// Update the attributes on the block
foreach (ObjectId id in btr)
{
Entity ent = trans.GetObject(id, OpenMode.ForRead, false) as Entity;
if (ent is AttributeDefinition)
{
AttributeReference attRef = new AttributeReference();
AttributeDefinition attDef = ent as AttributeDefinition;
attRef.SetPropertiesFrom(attDef);
attRef.Position = new Point3d(attDef.Position.X + br.Position.X,
attDef.Position.Y + br.Position.Y,
attDef.Position.Z + br.Position.Z);
attRef.Height = attDef.Height;
attRef.Rotation = attDef.Rotation;
attRef.Tag = attDef.Tag;
attRef.Invisible = attDef.Invisible;
br.AttributeCollection.AppendAttribute(attRef);
trans.AddNewlyCreatedDBObject(attRef, true);
}
}
idResult = br.ObjectId;
trans.Commit();
}
finally {trans.Dispose(); }
attribute definitions. Constant attributes are
essentially like text in the block's definition.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
I have a block table record that has a collection of attribute definitions on it, some of which are set up as constants. When I create a block reference based off of this block table record and go to create the attribute references corresponding to the attribute definitions, I cannot figure out how to specify the attribute references as constant. SetPropertiesFrom doesn't seem to do it. Any ideas?
Transaction trans = doc.TransactionManager.StartTransaction();
ObjectId idResult = ObjectId.Null;
try
{
// Get the model space block table
BlockTable bt = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
BlockTableRecord btrInsert = trans.GetObject(idBlock, OpenMode.ForRead) as BlockTableRecord;
// Create the new block reference
BlockReference br = new BlockReference(pt3DPos, idBlock);
btr.AppendEntity(br);
trans.AddNewlyCreatedDBObject(br, true);
// Update the attributes on the block
foreach (ObjectId id in btr)
{
Entity ent = trans.GetObject(id, OpenMode.ForRead, false) as Entity;
if (ent is AttributeDefinition)
{
AttributeReference attRef = new AttributeReference();
AttributeDefinition attDef = ent as AttributeDefinition;
attRef.SetPropertiesFrom(attDef);
attRef.Position = new Point3d(attDef.Position.X + br.Position.X,
attDef.Position.Y + br.Position.Y,
attDef.Position.Z + br.Position.Z);
attRef.Height = attDef.Height;
attRef.Rotation = attDef.Rotation;
attRef.Tag = attDef.Tag;
attRef.Invisible = attDef.Invisible;
br.AttributeCollection.AppendAttribute(attRef);
trans.AddNewlyCreatedDBObject(attRef, true);
}
}
idResult = br.ObjectId;
trans.Commit();
}
finally {trans.Dispose(); }
Re: Set AttributeR eference as Constant?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-22-2006 06:55 AM in reply to:
brianroth
Ok, but It is not possible to set the visible attribute to hide the text.

