Author Topic: Wblock to new database with dimensions  (Read 2344 times)

0 Members and 1 Guest are viewing this topic.

bikelink

  • Guest
Wblock to new database with dimensions
« on: March 05, 2009, 05:26:35 PM »
In the destination file i found all entities but i'm not able to "export"  the dimensions created in current drawing.
Why ? What's my mistake =?  :x
Thanks in advance.


Database dbDestination = new Database();
ObjectIdCollection objIdColl  = MycreateDimension();  // some dimension in current drawing
docOriginal.Database.Wblock(dbDestination, objIdColl, ptins, DuplicateRecordCloning.Ignore);
objIdColl.Dispose();
dbDestination.saveas( blabla..)
_________


bikelink

  • Guest
Re: Wblock to new database with dimensions
« Reply #1 on: March 06, 2009, 05:18:26 AM »
ok...solved.

Code: [Select]
foreach (Handle h in lstQuote)
                    {
                        using (Dimension dime = B2UtilCad.B2Entity.b2Entity.GetObjectFromObjectId(d, h, OpenMode.ForRead) as Dimension)
                        {
                             IdMapping myMap = new IdMapping();
                             ObjectIdCollection myObjs = new ObjectIdCollection();
                             using (Transaction t = dbSezioni.TransactionManager.StartTransaction())
                             {
                                 BlockTable myBT = dbSezioni.BlockTableId.GetObject(OpenMode.ForWrite) as BlockTable;
                                 BlockTableRecord myBTR = myBT[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite) as BlockTableRecord;
                                 dbSezioni.WblockCloneObjects(myObjs, myBTR.ObjectId, myMap, DuplicateRecordCloning.Replace, false);
                                 myObjs.Dispose();
                                 t.Commit();
                             }
                        }
                        lstHnDaSezioneComplessiva.Add(h);
                    }




 private void EsportaSezioneInAltroDB(Document docOrigine, IList<Handle> lstHn, Database dbSezioni, Point3d ptins)
        {
            try
            {
                ObjectIdCollection objIdColl = new ObjectIdCollection();
                foreach(Handle hn in lstHn)
                {
                    ObjectId id = B2UtilCad.B2Entity.b2Entity.GetHandleAsObjectID(docOrigine,hn);
                    objIdColl.Add(id);
                 }
                docOrigine.Database.Wblock(dbSezioni, objIdColl, ptins, DuplicateRecordCloning.Ignore);
                objIdColl.Dispose();
            }
            catch(Autodesk.AutoCAD.Runtime.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("errore EsportaSezioneInAltroDB "+ ex.Message);
                throw ex;
            }

        }

Edited by Daniel: added code tags
« Last Edit: March 08, 2009, 05:50:32 AM by Daniel »

TonyT

  • Guest
Re: Wblock to new database with dimensions
« Reply #2 on: March 07, 2009, 11:13:54 PM »
In case you didn't know, you can enclose code in tags
in posts here, to preserve formatting and readability.

ok...solved.

foreach (Handle h in lstQuote)
                    {
                        using (Dimension dime = B2UtilCad.B2Entity.b2Entity.GetObjectFromObjectId(d, h, OpenMode.ForRead) as Dimension)
                        {
                             IdMapping myMap = new IdMapping();
                             ObjectIdCollection myObjs = new ObjectIdCollection();
                             using (Transaction t = dbSezioni.TransactionManager.StartTransaction())
                             {
                                 BlockTable myBT = dbSezioni.BlockTableId.GetObject(OpenMode.ForWrite) as BlockTable;
                                 BlockTableRecord myBTR = myBT[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite) as BlockTableRecord;
                                 dbSezioni.WblockCloneObjects(myObjs, myBTR.ObjectId, myMap, DuplicateRecordCloning.Replace, false);
                                 myObjs.Dispose();
                                 t.Commit();
                             }
                        }
                        lstHnDaSezioneComplessiva.Add(h);
                    }




 private void EsportaSezioneInAltroDB(Document docOrigine, IList<Handle> lstHn, Database dbSezioni, Point3d ptins)
        {
            try
            {
                ObjectIdCollection objIdColl = new ObjectIdCollection();
                foreach(Handle hn in lstHn)
                {
                    ObjectId id = B2UtilCad.B2Entity.b2Entity.GetHandleAsObjectID(docOrigine,hn);
                    objIdColl.Add(id);
                 }
                docOrigine.Database.Wblock(dbSezioni, objIdColl, ptins, DuplicateRecordCloning.Ignore);
                objIdColl.Dispose();
            }
            catch(Autodesk.AutoCAD.Runtime.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("errore EsportaSezioneInAltroDB "+ ex.Message);
                throw ex;
            }

        }