本帖最后由 作者 于 2009-9-28 21:28:36 编辑
/ operBlkRec = (BlockTableRecord)operTrans.GetObject(operBlk[BlockTableRecord.ModelSpace], OpenMode.ForWrite); InsertBlkRef = new BlockReference(Point3d.Origin, InsertBlkID); InsertBlkRef.SetDatabaseDefaults(); operBlkRec.AppendEntity(InsertBlkRef); operTrans.AddNewlyCreatedDBObject(InsertBlkRef, true); 我的块定义是一个圆加一个属性,结果发现圆插入了,但属性没有插入,在cad中打开插入的块参照的特性,发现根本就没有属性那一栏。 还有,调试过程中发现插入后InsertBlkRef的MSITStore:E:\study\CAD\arxref(.net).chm::/2/Autodesk.AutoCAD.DatabaseServices.BlockReference.AttributeCollection.html">AttributeCollection是null。 不知道应该怎么样插入带属性定义的块参照,并且赋给块参照的属性具体的tag? //插入快参照后还需要插入属性 int i = 0; BlockTableRecord blkdef = (BlockTableRecord)operTrans.GetObject(InsertBlkRef.BlockTableRecord, OpenMode.ForRead); foreach (ObjectId id in blkdef) { DBObject ent = operTrans.GetObject(id, OpenMode.ForRead); if (ent is AttributeDefinition) { AttributeDefinition attdef = (AttributeDefinition)ent; AttributeReference attref = new AttributeReference(); attref.SetAttributeFromBlock(attdef, InsertBlkRef.BlockTransform); attref.TextString = loopInfor; i++; InsertBlkRef.AttributeCollection.AppendAttribute(attref); operTrans.AddNewlyCreatedDBObject(attref, true); } }
|