<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: wblockclone dbtext into side database and then turn it into a blocktablereco in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813465#M27088</link>
    <description>&lt;P&gt;thanks for the reply - I'll give that a shot and let you know&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2018 19:17:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-02-27T19:17:10Z</dc:date>
    <item>
      <title>wblockclone dbtext into side database and then turn it into a blocktablerecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813160#M27085</link>
      <description>&lt;P&gt;I'm trying to wblockclone a DBText object into a side database (into model space).&amp;nbsp; Once the DBText object is in the side database I want to create a new blocktablerecord and add that DBText to the blocktablerecord - essentially creating a new block composed of just the text object in the side database.&amp;nbsp; I've tried a few different approaches and no matter what I do I get to a point with I get a ePermanetlyErase error.&amp;nbsp; Any help would be greatly appreciated - I've wasted too many hours on just this tid bit of code within my project.&amp;nbsp; Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(sorry I don't have any code to paste in here - since out of frustration I've erased what ever I had lol)&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 17:28:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813160#M27085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-27T17:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813200#M27086</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have you simply try to first add the BlockTableRecord to the BlockTable of the side Database and then directly WblockClone the DBText in this BlockTableRecord?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 17:41:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813200#M27086</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-02-27T17:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813373#M27087</link>
      <description>&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("TEST")]
        public void Test()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var sourceDb = doc.Database;
            var ed = doc.Editor;
            var opts = new PromptEntityOptions("\nSelect text: ");
            opts.SetRejectMessage("\nSelected object is not a text.");
            opts.AddAllowedClass(typeof(DBText), true);
            var result = ed.GetEntity(opts);
            if (result.Status != PromptStatus.OK) return;
            var ids = new ObjectIdCollection();
            ids.Add(result.ObjectId);
            using (var targetDb = new Database(true, true))
            {
                ObjectId btrId;
                using (var tr = targetDb.TransactionManager.StartTransaction())
                {
                    var bt = (BlockTable)tr.GetObject(targetDb.BlockTableId, OpenMode.ForWrite);
                    var btr = new BlockTableRecord();
                    btr.Name = "test";
                    btrId = bt.Add(btr);
                    tr.AddNewlyCreatedDBObject(btr, true);
                    tr.Commit();
                }
                var mapping = new IdMapping();
                sourceDb.WblockCloneObjects(ids, btrId, mapping, DuplicateRecordCloning.Ignore, false);
                targetDb.SaveAs(@"C:\Temp\Foo.dwg", DwgVersion.Current);
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Feb 2018 18:39:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813373#M27087</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-02-27T18:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813465#M27088</link>
      <description>&lt;P&gt;thanks for the reply - I'll give that a shot and let you know&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 19:17:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813465#M27088</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-27T19:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813512#M27089</link>
      <description>&lt;P&gt;still have the same issue...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code&amp;nbsp; (note the source database is also a side database)&amp;nbsp; I get the error on the wblockcloneobjects line within section that handles "Text" objects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim acSelectedDwgFileDatabase As Autodesk.AutoCAD.DatabaseServices.Database = New Autodesk.AutoCAD.DatabaseServices.Database
            acSelectedDwgFileDatabase.ReadDwgFile(SelectedDwgFile, Autodesk.AutoCAD.DatabaseServices.FileOpenMode.OpenForReadAndAllShare, False, vbNull.ToString)
            Using acSelectedDwgFileTransaction As Autodesk.AutoCAD.DatabaseServices.Transaction = acSelectedDwgFileDatabase.TransactionManager.StartTransaction
                'Dim acObjectId As Autodesk.AutoCAD.DatabaseServices.ObjectId = acSelectedDwgFileTransaction.GetObject(SelectedacObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead).ObjectId
                Dim acObjectIdCollect As Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection = New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection
                If SelectedObjecType = "Block" Then
                    Dim acObjectId As Autodesk.AutoCAD.DatabaseServices.ObjectId = acSelectedDwgFileDatabase.GetObjectId(False, New Autodesk.AutoCAD.DatabaseServices.Handle(SelectedacHandle), 0)
                    Dim acBlockReference As Autodesk.AutoCAD.DatabaseServices.BlockReference = acSelectedDwgFileTransaction.GetObject(acObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) 'TryCast(acSelectedDwgFileTransaction.GetObject(acObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead), Autodesk.AutoCAD.DatabaseServices.BlockReference)
                    If acBlockReference IsNot Nothing Then
                        Dim acBlockTableRecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = acSelectedDwgFileTransaction.GetObject(acBlockReference.BlockTableRecord, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                        SampleUltraPictureBox.Image = ImageSourceToGDI(Autodesk.AutoCAD.Windows.Data.CMLContentSearchPreviews.GetBlockTRThumbnail(acBlockTableRecord))
                    End If
                End If
                If SelectedObjecType = "Text" Then
                    Dim acObjectId As Autodesk.AutoCAD.DatabaseServices.ObjectId = acSelectedDwgFileDatabase.GetObjectId(False, New Autodesk.AutoCAD.DatabaseServices.Handle(SelectedacHandle), 0)
                    acObjectIdCollect.Add(acObjectId)
                    Using targetDb = New Autodesk.AutoCAD.DatabaseServices.Database(True, True)
                        Dim btrid As Autodesk.AutoCAD.DatabaseServices.ObjectId
                        Dim btr = New Autodesk.AutoCAD.DatabaseServices.BlockTableRecord
                        Using tr = targetDb.TransactionManager.StartTransaction
                            Dim bt = CType(tr.GetObject(targetDb.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite), Autodesk.AutoCAD.DatabaseServices.BlockTable)
                            btr.Name = "sample"
                            btrid = bt.Add(btr)
                            tr.AddNewlyCreatedDBObject(btr, True)
                            tr.Commit()
                        End Using
                        Dim acmapping = New Autodesk.AutoCAD.DatabaseServices.IdMapping
                        acSelectedDwgFileDatabase.WblockCloneObjects(acObjectIdCollect, btrid, acmapping, Autodesk.AutoCAD.DatabaseServices.DuplicateRecordCloning.Ignore, False)
                        SampleUltraPictureBox.Image = ImageSourceToGDI(Autodesk.AutoCAD.Windows.Data.CMLContentSearchPreviews.GetBlockTRThumbnail(btr))
                    End Using
                End If
                acSelectedDwgFileDatabase.CloseInput(True)
            End Using&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Feb 2018 19:32:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813512#M27089</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-27T19:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813575#M27090</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Sorry I have a hard time reading your code.&lt;/SPAN&gt; In addition to being written in VB, it contains too many instructions that are not directly related to the subject and data that we do not know where they come from.&lt;BR /&gt;&lt;BR /&gt;Just try to use the Database Constructor overload which takes two arguments:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;Dim acSelectedDwgFileDatabase As Database = New Database (False, True)&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class=""&gt;You should also save the newly created database:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;targetDb.SaveAs (...)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;Could please tell which line of your code raise a ePermanetlyErase exception.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 19:59:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813575#M27090</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-02-27T19:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813618#M27091</link>
      <description>&lt;P&gt;Using Dim acSelectedDwgFileDatabase As Database = New Database (False, True) in my code solve the issue.&amp;nbsp; I bet all along the previous ways I was trying to wblock into the side database were fine and it was always simply because of this line.&amp;nbsp; However I'm going to keep your suggested code of writing directly into a newly create btr - it seems cleaner than what I had before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(btw sorry the code is messy - it's just prototype code at this point as I'm testing some ideas for our project)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help!!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 20:11:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813618#M27091</guid>
      <dc:creator>william.klawitter4MJ74</dc:creator>
      <dc:date>2018-02-27T20:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: wblockclone dbtext into side database and then turn it into a blocktablereco</title>
      <link>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813837#M27092</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5640988"&gt;@william.klawitter4MJ74&lt;/a&gt; wrote:&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(btw sorry the code is messy - it's just prototype code at this point as I'm testing some ideas for our project)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you want to encourage others to read your code, try to avoid using fully-qualified identifiers with namespace prefixes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, many people will not bother looking at code like that, because of how difficult is is to read.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 21:20:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wblockclone-dbtext-into-side-database-and-then-turn-it-into-a/m-p/7813837#M27092</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-02-27T21:20:05Z</dc:date>
    </item>
  </channel>
</rss>

