Results 1 to 2 of 2

Thread: How to update Xdata on existing entities in ACAD with objectARX?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2007-06
    Posts
    15
    Login to Give a bone
    0

    Question How to update Xdata on existing entities in ACAD with objectARX?

    Hi,

    I am writing a C# application for ACAD using objectARX. I need to update the Xdata in a DBDictionary. I can get to the correct Xdata and iterate through it fine. My problem is when I try to modify it and I commit my transaction and save the database none of the changes get registered. I am posting some code bellow. Any help will be greatly appreciated.


    TypedValue[] Xdata;
    Database db = new Database();
    Transaction trans=null;
    ResultBuffer newXdata=null;
    DBDictionary datadic=getDictionary(file.FullName);
    //getDictionary just return a copy of the DBDictionary that I am looking for in a file
    //that I open through the ReadDwgFile() command
    //I used the switch command to create a modified copy of the existing Xdata
    //because the TypedValue.Value and TypedValue.TypeCode are read only

    if (datadic != null)
    {
    Xdata = datadic.XData.AsArray();
    TypedValue[] tempXdata=new TypedValue[Xdata.Length];
    for (int i = 0; i < Xdata.Length; i++)
    {
    switch(i)
    {
    case 6: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, file.FullName);//'location
    break;
    case 7: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, System.DateTime.Today.ToString("MMMM d, yyyy"));//'last mod date "MMM dd, yyyy"
    break;
    case 8: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, HEISU_Forms.HEISUforms.HEISUfrm.UserName);//'last mod by
    break;
    case 9: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, projInfo.projectDescription);//'Project Name
    break;
    case 10: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, projInfo.projectNumber);//'Project Number
    break;
    case 12: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, HEISU_Forms.HEISUforms.HEISUfrm.UserName);//'Creator
    break;
    case 16: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, projInfo.fullStateName);//'full state name
    break;
    case 20: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, projInfo.logoState);//'1 if logo is legal, 0 for eor
    break;
    default: tempXdata[i] = new TypedValue(Xdata[i].TypeCode, Xdata[i].Value);//transfer all other Xdata
    break;
    }
    }
    newXdata = new ResultBuffer(tempXdata);
    }
    try
    {
    DBObject obj;
    db.ReadDwgFile(file.FullName, FileShare.ReadWrite, false, "");
    trans = db.TransactionManager.StartTransaction();
    obj=trans.GetObject(datadic.ObjectId, OpenMode.ForWrite);

    obj.UpgradeOpen();
    obj.XData = newXdata;
    newXdata.Dispose();
    obj.Close();
    trans.Commit();
    trans.Dispose();
    db.SaveAs(@"U:test.dwg", null);
    }
    finally
    {
    try
    {
    db.CloseInput(true);

    }
    catch { }
    }
    Last edited by ivan.markov; 2007-06-06 at 03:55 PM.

Similar Threads

  1. Lisp file to delete All Xdata from selected entities regardless app name
    By diaa.caliph423218 in forum Bridging the Gap: LISP -> .NET -> LISP
    Replies: 1
    Last Post: 2015-09-29, 08:33 PM
  2. Replies: 6
    Last Post: 2015-08-31, 04:05 PM
  3. can't update existing dwg file
    By romy8111 in forum AutoCAD Electrical - General
    Replies: 1
    Last Post: 2010-01-18, 10:10 PM
  4. can't update existing dwg file
    By romy8111 in forum AutoCAD General
    Replies: 1
    Last Post: 2010-01-12, 10:25 AM
  5. Converting ABS entities to ACAD solids?
    By jnewell in forum AMEP General
    Replies: 1
    Last Post: 2005-01-07, 12:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •