Author Topic: ObjectDBX and Attributes  (Read 27215 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #30 on: August 31, 2006, 03:55:55 PM »
The problem is that those talk about closing/saving the current drawing, which is different that closing a drawing opened with ObjectDBX in .Net.  The attached images show the different methods and what is need per the two.  Thanks for trying.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #31 on: August 31, 2006, 03:58:36 PM »
Sorry for the confusion: ac2004_dwg is the activex constant.  I havn't tried this in .net but as long as your referencing the AxDb1#.dll I would think it should work? 

My only other thought would be the first argument is the name only: "MyDrawing" and the second argument as a string ".dwg" ??? Just purely guessing here . . ..
I'm willing to try anything almost, but this didn't work either.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: ObjectDBX and Attributes
« Reply #32 on: August 31, 2006, 04:11:02 PM »
[I'm willing to try anything almost, but this didn't work either.  :-)
I think problem not in second parameter of dbxDoc.SaveAs() function. Problem is that this drawing is now  current (e.g. WorkingDatabase).
Try to dbxDoc.SaveAs()  after using (WorkingDatabase ...) block.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #33 on: August 31, 2006, 04:57:07 PM »
[I'm willing to try anything almost, but this didn't work either.  :-)
I think problem not in second parameter of dbxDoc.SaveAs() function. Problem is that this drawing is now  current (e.g. WorkingDatabase).
Try to dbxDoc.SaveAs()  after using (WorkingDatabase ...) block.

AND THE WINNER IS ALEXANDER RIVILIS!!!!
Doing this, and using what Tony told me on the adesk ng site worked.  Thank you so much!
Code: [Select]
public void UpdateRevStuff() {
      Document Doc = AcadApp.DocumentManager.MdiActiveDocument;
      Editor DocEd = Doc.Editor;
      //using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()) {
      Autodesk.AutoCAD.Windows.OpenFileDialog Dia = new Autodesk.AutoCAD.Windows.OpenFileDialog("Select drawings to update Cloud layer", "", "dwg", "", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
      Dia.ShowDialog();
      string[] DwgList = Dia.GetFilenames();
      AxDbDocument dbxDoc = new AxDbDocument();
      foreach (string Str in DwgList) {
        dbxDoc.Open (Str, null);
        Database db = Database.FromAcadDatabase (dbxDoc.Database);
        using (CaddZone.DatabaseServices.WorkingDatabase wdb = new CaddZone.DatabaseServices.WorkingDatabase (db)) {
      if (HasLayer (db, "Cloud-UNKNOWN")) {
string Rev = (GetHighestRev(db));
if (Rev != "") {
UpdateRevBlock (db, Rev);
UpdateCloudLayer (db, "Cloud-UNKNOWN", "Cloud-" + Rev);
MessageBox.Show ("Right before save.");
//dbxDoc.SaveAs (dbxDoc.Name);
//Marshal.ReleaseComObject (dbxDoc);

}
      }
      }
dbxDoc.SaveAs (dbxDoc.Name, Type.Missing);
Marshal.ReleaseComObject (dbxDoc);
}
 //}
}
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #34 on: August 31, 2006, 05:01:42 PM »
Side note:  The attribute updated correclty also, so you can use ObjectDBX with .Net and attributes.  Good news!
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ObjectDBX and Attributes
« Reply #35 on: August 31, 2006, 05:05:20 PM »
aside from the technical issues Tim, that looks like an interesting project.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #36 on: August 31, 2006, 05:10:44 PM »
aside from the technical issues Tim, that looks like an interesting project.
If you think it is of intrest I can post the whole code.

I posted the finished code to soon.  I release the dbxDoc to soon in the first code I posted.  Here is the correct on, which also writes to the current documents command line saying which ones got updated and which ones didn't

Code: [Select]
public void UpdateRevStuff() {
      Document Doc = AcadApp.DocumentManager.MdiActiveDocument;
      Editor DocEd = Doc.Editor;
      Autodesk.AutoCAD.Windows.OpenFileDialog Dia = new Autodesk.AutoCAD.Windows.OpenFileDialog("Select drawings to update Cloud layer", "", "dwg", "", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
      Dia.ShowDialog();
      string[] DwgList = Dia.GetFilenames();
      AxDbDocument dbxDoc = new AxDbDocument();
    foreach (string Str in DwgList) {
  bool ShouldSave = false;
        dbxDoc.Open (Str, null);
      Database db = Database.FromAcadDatabase (dbxDoc.Database);
      using (CaddZone.DatabaseServices.WorkingDatabase wdb = new CaddZone.DatabaseServices.WorkingDatabase (db)) {
      if (HasLayer (db, "Cloud-UNKNOWN")) {
string Rev = (GetHighestRev(db));
if (Rev != "") {
UpdateRevBlock (db, Rev);
UpdateCloudLayer (db, "Cloud-UNKNOWN", "Cloud-" + Rev);
ShouldSave = true;
//MessageBox.Show ("Right before save.");

}
      }
      }
      if (ShouldSave == true) {
      DocEd.WriteMessage ("\n Saving file {0}", dbxDoc.Name);
dbxDoc.SaveAs (dbxDoc.Name, Type.Missing);
      }
else {
DocEd.WriteMessage ("\n ++ Not saving file {0}", dbxDoc.Name);
}
}
Marshal.ReleaseComObject (dbxDoc);
}
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #37 on: August 31, 2006, 05:59:50 PM »
Even better.  Now you can save the origianl thumbnail preview of the drawing.  Here is the code portion I changed to do so.
Code: [Select]
if (ShouldSave == true) {
db.RetainOriginalThumbnailBitmap = true;  // Added line.
DocEd.WriteMessage ("\n Saving file {0}", dbxDoc.Name);
dbxDoc.SaveAs (dbxDoc.Name, Type.Missing);
}

THANKS AGAIN TO ALL WHO HELPED ME COMPLETE THIS!!
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ObjectDBX and Attributes
« Reply #38 on: August 31, 2006, 06:19:51 PM »
Even better.  Now you can save the original thumbnail preview of the drawing.  Here is the code portion I changed to do so.
Code: [Select]
///

That alone is worth the price of admission
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: ObjectDBX and Attributes
« Reply #39 on: September 01, 2006, 02:59:50 AM »
AND THE WINNER IS ALEXANDER RIVILIS!!!!
:) And what about not using AxDbDocument? AFAIK You can do the same with Database.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX and Attributes
« Reply #40 on: September 01, 2006, 11:02:51 AM »
AND THE WINNER IS ALEXANDER RIVILIS!!!!
:) And what about not using AxDbDocument? AFAIK You can do the same with Database.
I thought I had to when using ObjectDBX.  If not then I can change it if it works.  Is there a draw back to using one over the other?

Thanks again Alexander.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.