.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why can not I write the xrecord? (C#)

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
855 Views, 2 Replies

Why can not I write the xrecord? (C#)

Hello All!

Please help me!

 

Why the xrecord not save?

 

public static void SaveInscCad(ObjectId idEnt, string InscCad)
        {
            Database db = AcadAppServices.Application.DocumentManager.MdiActiveDocument.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try 
	            {	        
            		Entity ent = (Entity)tr.GetObject(idEnt, OpenMode.ForWrite);
                    if (ent.ExtensionDictionary.IsNull) ent.CreateExtensionDictionary();
                    DBDictionary extDic = (DBDictionary)tr.GetObject(ent.ExtensionDictionary, OpenMode.ForWrite);
                    TypedValue[] valores = new TypedValue[1];
                    valores[0] = new TypedValue((int)DxfCode.Text, InscCad);

                    ResultBuffer resBuf = new ResultBuffer(valores);
                    Xrecord dado = new Xrecord();
                    dado.Data = resBuf;
                    extDic.SetAt(InscCad, dado);
                    tr.AddNewlyCreatedDBObject(dado, true);
                    tr.Commit();
	            }
	            catch (System.Exception)
	            {
		            tr.Abort();
	            }
            }
        }

Thanks...

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Ran your code and it does work. an extension dictionary is added to the entity and holds the string. if you use MgdDbg you can see the record, you can ge MgdDbg from here http://through-the-interface.typepad.com/through_the_interface/2010/02/the-stephen-and-fenton-show-a...

Message 3 of 3
Anonymous
in reply to: Anonymous

Thank you!!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost