Author Topic: Sync (refresh) a Sheet Set  (Read 349 times)

0 Members and 1 Guest are viewing this topic.

pBe

  • Bull Frog
  • Posts: 370
Sync (refresh) a Sheet Set
« on: March 27, 2017, 12:09:35 pm »
I found this on Autocad 2016 online help

Updates the sheet view components in the sheet set of the provided AcadDatabase object.

Syntax
   Sync(   pXDb As IAcadDatabase) As Object


I'm attempting to "refresh" the sheet view programmatically

Code - C#: [Select]
  1. Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
  2. Database acadDatabase = acDoc.Database;
  3.  
  4.            AcSmSheetSetMgr mgr = new AcSmSheetSetMgr();
  5.  
  6.            AcSmDatabase db = new AcSmDatabase();
  7.            db.LockDb(db);
  8.            AcSmSheetSet ss = db.GetSheetSet();
  9.  
  10. .....
  11. .....
  12.  
  13.            db.UnlockDb(db, true);
  14.            ss.Sync(acadDatabase);
  15.            mgr.Close(db);
  16.  

The above doesn't seem to work
The error shows

CS1503   Argument 1: cannot convert from 'Autodesk.AutoCAD.DatabaseServices.Database' to 'AXDBLib.AcadDatabase'

Question: How do i get to AXDBLib.AcadDatabase or convert the variable acadDatabase to its proper form?

Thank you in advance

pBe


Jeff_M

  • King Gator
  • Posts: 3891
  • C3D user & customizer
Re: Sync (refresh) a Sheet Set
« Reply #1 on: March 27, 2017, 12:58:22 pm »
object acadDatabase = acDoc.Database.AcadDatabase;

pBe

  • Bull Frog
  • Posts: 370
Re: Sync (refresh) a Sheet Set
« Reply #2 on: March 27, 2017, 01:27:41 pm »
I'll give it a try Jeff

Thanks

EDIT:

Code - C#: [Select]
  1.        [CommandMethod("SheetViewWrite")]
  2.  
  3. using AXDBLib; //<----- this
  4.  
  5.        public void SheetViewWrite()
  6.        {
  7.            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
  8.  
  9.            // object acadDatabase = acDoc.Database.AcadDatabase;
  10.  
  11.            AcadDatabase acadDatabase = new AcadDatabase(); //<----- lets see if this works
  12.  
  13.            string ssFilePath = userInput("\nEnter Sheet Set Name: ");
  14.  
  15.            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  16.  
  17.            AcSmSheetSetMgr mgr = new AcSmSheetSetMgr();
  18.            AcSmDatabase db = new AcSmDatabase();
  19.  
  20.            try
  21.            {
  22.                db = mgr.OpenDatabase(ssFilePath, true);
  23.  
  24.            }
  25.            catch (System.Exception ex)
  26.            {
  27.                ed.WriteMessage(ex.ToString());
  28.                return;
  29.            }
  30.  
  31.            AcSmSheetSet ss = db.GetSheetSet();
  32.  
  33.            ss.Sync(acadDatabase); /// <--- Here
  34.            mgr.Close(db);
  35.  
  36.        }

Cant seem to recognize the object...  Wonder what i'm missing? a reference file perhaps?

EDIT 2: Lets see if the above works..... updating

Sheet set NOT "refreshing" and now gives an error Error HRESULT E_FAIL has been returned from a call to a COM component.
   at ACSMCOMPONENTS20Lib.IAcSmSheetSet.Sync(AcadDatabase pXDb)

« Last Edit: March 28, 2017, 03:58:55 am by pBe »

pBe

  • Bull Frog
  • Posts: 370
Re: Sync (refresh) a Sheet Set
« Reply #3 on: March 28, 2017, 04:55:58 am »
Hang on...

Syntax
   Sync(   pXDb As IAcadDatabase) As Object

IAcadDatabase <---- But its looking for 'AXDBLib.AcadDatabase' ?

I don't get it, the I means Interface or instance ?

« Last Edit: March 28, 2017, 05:02:31 am by pBe »

Jeff_M

  • King Gator
  • Posts: 3891
  • C3D user & customizer
Re: Sync (refresh) a Sheet Set
« Reply #4 on: March 28, 2017, 09:30:01 am »
Did you try this?:

AcadDatabase acadDatabase = acDoc.Database.AcadDatabase;

pBe

  • Bull Frog
  • Posts: 370
Re: Sync (refresh) a Sheet Set
« Reply #5 on: March 28, 2017, 10:02:29 am »
Thank you for your patience Jeff_M..

I'm getting a squiggly lines under acDoc.Database.AcadDatabase;

Cannot implicitly convert type 'object' to 'AXDBLib.AcadDatabase'. An explicit conversion exists (are you missing a cast?


Jeff_M

  • King Gator
  • Posts: 3891
  • C3D user & customizer
Re: Sync (refresh) a Sheet Set
« Reply #6 on: March 28, 2017, 11:06:04 am »
Sorry, this should do it:           
 AcadDatabase acadDatabase = (AcadDatabase)acDoc.Database.AcadDatabase;

pBe

  • Bull Frog
  • Posts: 370
Re: Sync (refresh) a Sheet Set
« Reply #7 on: March 29, 2017, 05:40:07 am »
I'll give it a go. keep you posted

Thank you Jeff_M

Its not generating any error but it does not refresh the Sheet views . I'll keep digging..
« Last Edit: April 02, 2017, 12:20:14 am by pBe »

pBe

  • Bull Frog
  • Posts: 370
Re: Sync (refresh) a Sheet Set
« Reply #8 on: April 05, 2017, 12:06:40 pm »
Haven't had any luck with this yet, 

I used the codes from the CP318-4 by  Lee Ambrosius
http://forums.augi.com/showthread.php?159467-CP318-4-Taking-a-Look-at-the-Sheet-Set-Object-With-VB-NET

and

Populating a tree view inside AutoCAD with sheet set data using .NET - Part 2 by Kean Walmsley
http://through-the-interface.typepad.com/through_the_interface/2010/05/populating-a-tree-view-inside-autocad-with-sheet-set-data-using-net-part-2.html

Modify the codes to write values to Custom Property and Sheet View. All is well after limited testing, only problem is , right after the code sets a value to "AcSmSheetView" the user needs to pick the refresh button on the Model Views tab under sheet set manager, there are times  Autocad crashes if they don't, but only when you try to "Rename & Renumber" the sheet view item, its all good when refresh is clicked.

This only happens with Vanilla cad, Never had that problem in Civil 3D.

That is the reason why i need a "refresh" function.