<?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 : Copy  Problems in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898522#M44928</link>
    <description>&lt;P&gt;I think the code is still a little complicated for me,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can you help me achieve the following process?&amp;nbsp; It will be a better way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, there is a source drawing which contains a BlockReference called tstrm in the D drive,&lt;BR /&gt;Then execute custom command in the new drawing, this target block above will be copied to the new drawings.&lt;/P&gt;&lt;P&gt;Attachment has the source drawings&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Extremely grateful&lt;/P&gt;&lt;P&gt;&lt;IMG alt="demo.PNG" border="0" title="demo.PNG" src="https://forums.autodesk.com/t5/image/serverpage/image-id/88164iA2314FD66129D846/image-size/original?v=mpbl-1&amp;amp;px=-1" align="center" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Mar 2014 14:53:58 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-03-20T14:53:58Z</dc:date>
    <item>
      <title>Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4896188#M44925</link>
      <description>&lt;P&gt;I want to create a command, it could copy the contents of another drawing to the current drawing directly, not XERF, Is there anyone can give me a simple example?&lt;BR /&gt;Thanks very much&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 16:04:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4896188#M44925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-19T16:04:50Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4896294#M44926</link>
      <description>&lt;P&gt;Have a look at the Database.WblockCloneObjects() method.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 16:35:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4896294#M44926</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-19T16:35:59Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4897492#M44927</link>
      <description>&lt;P&gt;Here's a little sample&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public static ObjectIdCollection ImportModelSpace(string filename)
        {
            if (!File.Exists(filename))
                throw new FileNotFoundException("File not found", filename);

            Database targetDb = HostApplicationServices.WorkingDatabase;
            ObjectId owner = SymbolUtilityServices.GetBlockModelSpaceId(targetDb);
            IdMapping idMap = new IdMapping();

            using (Database sourceDb = new Database())
            {
                sourceDb.ReadDwgFile(filename, FileShare.Read, false, "");
                using (Transaction tr = sourceDb.TransactionManager.StartTransaction())
                {
                    BlockTableRecord mSpace = (BlockTableRecord)tr.GetObject(
                        SymbolUtilityServices.GetBlockModelSpaceId(sourceDb), OpenMode.ForRead);
                    ObjectIdCollection ids = new ObjectIdCollection(mSpace.Cast&amp;lt;ObjectId&amp;gt;().ToArray());
                    sourceDb.WblockCloneObjects(ids, owner, idMap, DuplicateRecordCloning.Ignore, false);
                    tr.Commit();
                }
            }
            return new ObjectIdCollection(
                idMap
                .Cast&amp;lt;IdPair&amp;gt;()
                .Where(p =&amp;gt; p.IsCloned)
                .Select(p =&amp;gt; p.Value)
                .ToArray());
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 07:06:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4897492#M44927</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-20T07:06:11Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898522#M44928</link>
      <description>&lt;P&gt;I think the code is still a little complicated for me,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can you help me achieve the following process?&amp;nbsp; It will be a better way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, there is a source drawing which contains a BlockReference called tstrm in the D drive,&lt;BR /&gt;Then execute custom command in the new drawing, this target block above will be copied to the new drawings.&lt;/P&gt;&lt;P&gt;Attachment has the source drawings&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Extremely grateful&lt;/P&gt;&lt;P&gt;&lt;IMG alt="demo.PNG" border="0" title="demo.PNG" src="https://forums.autodesk.com/t5/image/serverpage/image-id/88164iA2314FD66129D846/image-size/original?v=mpbl-1&amp;amp;px=-1" align="center" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 14:53:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898522#M44928</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-20T14:53:58Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898814#M44929</link>
      <description>&lt;P&gt;Do you want to add the block reference to the target model space or only import the block definition in the target block table ?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 16:05:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898814#M44929</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-20T16:05:14Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898886#M44930</link>
      <description>&lt;P&gt;I do not quite understand the difference between these two&lt;BR /&gt;But the result I want is equivalent to using Autocad COPY command , just like copy the graphics to a new drawing, the graphics is same with the old one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new command that I want to get will work as below:&lt;/P&gt;&lt;P&gt;1,Exceute the command,&lt;/P&gt;&lt;P&gt;2,Automatic drawing that graphics at my specified position, in fact this step the program will access the source drawing and then copy that graphics&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This small command will save some time during copy, just like select target object and so on&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 16:23:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4898886#M44930</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-20T16:23:27Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4899048#M44931</link>
      <description>&lt;P&gt;First, IMO, if you want to make autoCAD customization, especially with a as sophisticated technology as .NET, you must, above all, master the autoCAD basics as the difference between a block definition (BlockTableRecord) and an insertion of this definition (BlockReference).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The AutoCAD COPY command do not allow to copy a graphic object between different drawing (either between two spaces). This can be done with the Windows clipboard technology (Copy/Paste commands) which is tolerate by AutoCAD.&lt;/P&gt;
&lt;P&gt;The "AutoCAD way" to do what you describe is using the DesignCenter to import the block definition from another drawing and insert a reference of this block in the model space or elsewhere. This can be done programmatically using the WblockCloneObjects() method as shown upper.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find a method to import a block definition from an external drawing in this recent thread (reply #7):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://forums.autodesk.com/t5/NET/How-to-include-extension-dictionary-in-block-inserted-using/td-p/4895790" target="_blank"&gt;http://forums.autodesk.com/t5/NET/How-to-include-extension-dictionary-in-block-inserted-using/td-p/4895790&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2014 17:23:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4899048#M44931</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-20T17:23:03Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904126#M44932</link>
      <description>&lt;P&gt;Thank you very much, I have a learn about WBlockCloneObjects() method in the AutoCAD Developer Guide, it works well.&lt;/P&gt;&lt;P&gt;but I am not very unstudand about your ImportBlock() method, this one has some problem.&lt;BR /&gt;Can you fix my code? Just let it work,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;BR /&gt;filePath=@"D:\SourceDwg\sourceDrawing.dwg"&lt;BR /&gt;BlockName="tstrm"&lt;BR /&gt;The Block will be import at origin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above attachment has the drawing.&lt;/P&gt;&lt;P&gt;Blow is code,&lt;/P&gt;&lt;PRE&gt;using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(AutocadCommandCollection.test6))]


namespace AutocadCommandCollection
{

    class test6
    {

        [CommandMethod("test6")]


        public static void CopyFrom()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                ObjectId Id = ImportBlock(@"D:\SourceDwg\sourceDrawing.dwg", "tstrm");
                BlockTableRecord btr = (BlockTableRecord)acTrans.GetObject(Id, OpenMode.ForRead);
                acBlkTbl.Add(btr);
                acTrans.AddNewlyCreatedDBObject(btr, true);

                acTrans.Commit();
            }
        }




        private static ObjectId ImportBlock(string fileName, string blockName)
        {
            if (!File.Exists(fileName))
                throw new FileNotFoundException("File not found", fileName);

            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database targetDb = acDoc.Database;
            ObjectId owner = targetDb.BlockTableId;

            using (Database sourceDb = new Database())
            {
                sourceDb.ReadDwgFile(fileName, System.IO.FileShare.Read, false, "");
                using (Transaction tr = sourceDb.TransactionManager.StartOpenCloseTransaction())
                {
                    BlockTable bt = (BlockTable)tr.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
                    if (!bt.Has(blockName))
                        return ObjectId.Null;

                    ObjectId id = bt[blockName];
                    ObjectIdCollection ids = new ObjectIdCollection();
                    ids.Add(id);
                    IdMapping idMap = new IdMapping();
                    sourceDb.WblockCloneObjects(ids, owner, idMap, DuplicateRecordCloning.Ignore, false);
                    return idMap[id].IsCloned ? idMap[id].Value : ObjectId.Null;
                }
            }
        }

    }

}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Mar 2014 13:21:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904126#M44932</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-23T13:21:29Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904146#M44933</link>
      <description>&lt;P&gt;I think I finally find the new block after run the code above, the block is existing int the BlockTable or maybe, I can find it throuht the Insert Block drop down list of the Insert Menu.&lt;/P&gt;&lt;P&gt;But It doesn't show as same as the old one after insert manully, I just want Insert the Block in the new drawing, It will be same with the old one.&lt;/P&gt;&lt;P&gt;Can you help me? Very thanks&lt;/P&gt;&lt;P&gt;&lt;IMG align="center" border="0" src="https://forums.autodesk.com/t5/image/serverpage/image-id/88628iF04237D6ED86311F/image-size/original?v=mpbl-1&amp;amp;px=-1" title="Picture.PNG" alt="Picture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Mar 2014 13:47:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904146#M44933</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-23T13:47:03Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904414#M44934</link>
      <description>&lt;PRE&gt;        private void ImportBlockReference(string blockName, string filenName)
        {
            if (!File.Exists(filenName))
                throw new FileNotFoundException("File not found", filenName);

            Database targetDb = HostApplicationServices.WorkingDatabase;
            ObjectId owner = SymbolUtilityServices.GetBlockModelSpaceId(targetDb);

            using (Database sourceDb = new Database(false, true))
            {
                sourceDb.ReadDwgFile(filenName, FileShare.ReadWrite, false, "");
                using (Transaction tr = sourceDb.TransactionManager.StartTransaction())
                {
                    BlockTable bt = (BlockTable)tr.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
                    if (!bt.Has(blockName))
                        throw new ArgumentException("Block definition not found", blockName);

                    ObjectIdCollection ids = new ObjectIdCollection();

                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[blockName], OpenMode.ForRead);
                    ObjectId mSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(sourceDb);
                    foreach (ObjectId id in btr.GetBlockReferenceIds(true, false))
                    {
                        BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);
                        if (br.OwnerId == mSpaceId)
                        {
                            ids.Add(id);
                            break;
                        }
                    }

                    if (ids.Count == 0)
                        throw new ArgumentException("Block reference not found", blockName);

                    IdMapping idMap = new IdMapping();
                    sourceDb.WblockCloneObjects(ids, owner, idMap, DuplicateRecordCloning.Ignore, false);
                }
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Mar 2014 19:21:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4904414#M44934</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-23T19:21:48Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905352#M44935</link>
      <description>&lt;P&gt;Thank you very much for your help, the above code have finished the above function I seted, a celebration~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At before, I thought if I can achieve the above code, then I can make changes, and then complete the final function, but I can’t -_-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code is still need&amp;nbsp;one step, in fact,&amp;nbsp;I want to&lt;STRONG&gt; control the position copied into the new graphics&lt;/STRONG&gt; ,&lt;BR /&gt;For example, I want the block which in the original drawing coordinates is ( 0,0,0 )&amp;nbsp; will be copied to a new position specfied by cursor in the new drawing, I think this needs to move an object , the method may be used is similar with:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acCirc.TransformBy (Matrix3d.Displacement (acVec3d));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;But I can not find something equivalent to the acCirc object form your code.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Can you finish it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is I am not familiar with WblockCloneObjects () method, and IdMapping class, I do not know how to use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me think about my mastery of AtuoCAD, now I'm not too familiar with AutoCAD 's API, The basic API I know all learn from AutoCAD Developer Guide, I just basically modify the sample code.&lt;BR /&gt;I very much hope to further study, but there is no sample code in ObjectARX_2010_Win_64_and_32Bit, it seems not easy to understand, do you have any good way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincere wishes!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2014 11:11:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905352#M44935</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-24T11:11:33Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905504#M44936</link>
      <description>&lt;P&gt;&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://forums.autodesk.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;Yes, I think I need the new ObjectId of this block in the new drawing, then I can get the new&amp;nbsp;BlockReference in the new drawing, then move and so on.&lt;BR /&gt;How can I get it, maybe I can get it though the idMap?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2014 12:25:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905504#M44936</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-24T12:25:21Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905656#M44937</link>
      <description>&lt;P&gt;I have solve this move problem, thank you very much and a celebration : )&lt;/P&gt;&lt;P&gt;May be you can tell me how to learn AutoCAD's API~~~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is code&lt;/P&gt;&lt;PRE&gt;using System;
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(AutocadCommandCollection.test9))]


namespace AutocadCommandCollection
{

    class test9
    {

        [CommandMethod("test9")]
        public static void CopyFrom()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                ImportBlockReference("tstrm",@"D:\SourceDwg\sourceDrawing.dwg");
            
                acTrans.Commit();
            }
        }

        private static void ImportBlockReference(string blockName, string filenName)
        {
            if (!File.Exists(filenName))
                throw new FileNotFoundException("File not found", filenName);

            Database targetDb = HostApplicationServices.WorkingDatabase;
            ObjectId owner = SymbolUtilityServices.GetBlockModelSpaceId(targetDb);

            using (Database sourceDb = new Database(false, true))
            {
                sourceDb.ReadDwgFile(filenName, FileShare.ReadWrite, false, "");
                using (Transaction tr = sourceDb.TransactionManager.StartTransaction())
                {
                    BlockTable bt = (BlockTable)tr.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
                    if (!bt.Has(blockName))
                        throw new ArgumentException("Block definition not found", blockName);

                    ObjectIdCollection ids = new ObjectIdCollection();

                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[blockName], OpenMode.ForRead);
                    ObjectId mSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(sourceDb);
                    ObjectId brefId = new ObjectId();
                    foreach (ObjectId id in btr.GetBlockReferenceIds(true, false))
                    {
                        BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);

                        if (br.OwnerId == mSpaceId)
                        {
                            ids.Add(id);
                            brefId = id;
                            break;
                        }
                    }

                    if (ids.Count == 0)
                        throw new ArgumentException("Block reference not found", blockName);

                    IdMapping idMap = new IdMapping();
                    sourceDb.WblockCloneObjects(ids, owner, idMap, DuplicateRecordCloning.Ignore, false);
                    Document acDoc = Application.DocumentManager.MdiActiveDocument;
                    Database acCurDb = acDoc.Database;

                    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                    {
                        BlockReference bref = acTrans.GetObject(idMap[brefId].Value, OpenMode.ForWrite) as BlockReference;
                        if (bref != null)
                        {
                            Application.ShowAlertDialog(bref.Position.ToString());

                            Point3d newPoint = new Point3d(100,100,0);
                            Point3d oldPoint = new Point3d(0,0,0);

                            Vector3d acVec3d = oldPoint.GetVectorTo(newPoint);
                            bref.TransformBy(Matrix3d.Displacement(acVec3d));
                            Application.ShowAlertDialog(bref.Position.ToString());
                        }
                        acTrans.Commit();
                    }
                }
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2014 13:06:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905656#M44937</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-24T13:06:42Z</dc:date>
    </item>
    <item>
      <title>Re : Copy  Problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905724#M44938</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make the importBlockReference() method return the newly created ObjectId to the calling function from where you move the newly created block reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("TEST")]
        public void Tet()
        {
            ObjectId id = ImportBlockReference("tstrm", @"D:\SourceDwg\sourceDrawing.dwg");
            if (id != ObjectId.Null)
            {
                Database db = HostApplicationServices.WorkingDatabase;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForWrite);
                    br.TransformBy(Matrix3d.Displacement(new Vector3d(10, 20, 0)));
                    tr.Commit();
                }
            }
        }

        private ObjectId ImportBlockReference(string blockName, string filenName)
        {
            if (!File.Exists(filenName))
                throw new FileNotFoundException("File not found", filenName);

            Database targetDb = HostApplicationServices.WorkingDatabase;
            ObjectId owner = SymbolUtilityServices.GetBlockModelSpaceId(targetDb);

            using (Database sourceDb = new Database(false, true))
            {
                sourceDb.ReadDwgFile(filenName, FileShare.ReadWrite, false, "");
                using (Transaction tr = sourceDb.TransactionManager.StartTransaction())
                {
                    BlockTable bt = (BlockTable)tr.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
                    if (!bt.Has(blockName))
                        throw new ArgumentException("Block definition not found", blockName);

                    ObjectIdCollection ids = new ObjectIdCollection();

                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[blockName], OpenMode.ForRead);
                    ObjectId mSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(sourceDb);
                    foreach (ObjectId id in btr.GetBlockReferenceIds(true, false))
                    {
                        BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);
                        if (br.OwnerId == mSpaceId)
                        {
                            ids.Add(id);
                            break;
                        }
                    }

                    if (ids.Count == 0)
                        throw new ArgumentException("Block reference not found", blockName);

                    IdMapping idMap = new IdMapping();
                    sourceDb.WblockCloneObjects(ids, owner, idMap, DuplicateRecordCloning.Ignore, false);

                    return idMap[ids[0]].Value;
                }
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2014 13:21:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-problems/m-p/4905724#M44938</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-24T13:21:32Z</dc:date>
    </item>
  </channel>
</rss>

