private static Xrecord GetValueRecord(this AcTransaction trans, string valName) { valName = Ac.GetValidName(valName); var valDict = trans.GetGeo7Dict("Values"); if (valDict.Contains(valName)) { var valId = valDict.GetAt(valName); return(trans.GetObject <Xrecord>(valId)); } else { var typedVal = new TypedValue((int)DxfCode.Text, ""); using (var resBuff = new ResultBuffer(typedVal)) { var xRec = new Xrecord(); xRec.Data = resBuff; valDict.SetAt(valName, xRec); trans.AddNewlyCreatedDBObject(xRec, true); return(xRec); } } //ResultBuffer resbuf = new ResultBuffer( new TypedValue((int)DxfCode.Text, "HELLO"), // new TypedValue((int)DxfCode.Int16, 256), // new TypedValue((int)DxfCode.Real, 25.4)); }
public AcBlockRef AddBlockRef(Point3d pos, AcTransaction trans) { //Create the block reference... var blockRef = new BlockReference(pos, this.ObjectId); blockRef.SetDatabaseDefaults(); // Default/Active layer, color, ... trans.AddEntity(blockRef); // Do it before blockRef.AttributeCollection.AppendAttribute(attRef); var attrRefs = new List <AttributeReference>(); foreach (var attrDef in this.Attributes) { // this BlockDef could be initialized throught other (closed) Transaction, the same with this.Attributes var attDefObj = attrDef.GetAcObject(trans); // trans.GetObject<AttributeDefinition>(attrDef.ObjectId); // attrDef.AcObject; var attRef = new AttributeReference(); attRef.SetAttributeFromBlock(attDefObj, blockRef.BlockTransform); attRef.SetDatabaseDefaults(); if (!attDefObj.Constant) { attRef.TextString = attDefObj.TextString; } blockRef.AttributeCollection.AppendAttribute(attRef); trans.AddNewlyCreatedDBObject(attRef, true); attrRefs.Add(attRef); } return(new AcBlockRef(blockRef, trans, attrRefs)); }
public static ObjectId AddEntity(this AcTransaction trans, Entity ent) { var entId = trans.ModelSpace.AppendEntity(ent); // Add the reference to ModelSpace trans.AddNewlyCreatedDBObject(ent, true); // Let the transaction know about it return(entId); }
public static DBDictionary GetSubDictionary(this AcTransaction trans, DBDictionary parentDict, string subDictKey) { if (parentDict.Contains(subDictKey)) { var subDictId = parentDict.GetAt(subDictKey); return(trans.GetObject <DBDictionary>(subDictId)); } else { var newDict = new DBDictionary(); var res = parentDict.SetAt(subDictKey, newDict); trans.AddNewlyCreatedDBObject(newDict, true); return(newDict); } }
public static ObjectId CreateLayer(this AcTransaction trans, string name) { if (trans.LayerTable.Has(name)) { return(trans.LayerTable[name]); } using (var ltr = new LayerTableRecord()) { ltr.Name = name; //ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, 2); var res = trans.LayerTable.Add(ltr); trans.AddNewlyCreatedDBObject(ltr, true); return(res); } }