• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Member
    Posts: 8
    Registered: ‎11-01-2005

    copy block

    115 Views, 5 Replies
    11-09-2005 04:09 AM
    hi,

    I am unable to copy a block from one ACAD drawing to another can any one help me on this.

    thanks in advance
    namrata
    Please use plain text.
    *Lisa

    Re: copy block

    11-09-2005 10:42 AM in reply to: namrata.nekkanti
    cut and paste it?

    wrote in message news:5007941@discussion.autodesk.com...
    hi,

    I am unable to copy a block from one ACAD drawing to another can any one
    help me on this.

    thanks in advance
    namrata
    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎11-01-2005

    Re: copy block

    11-09-2005 08:43 PM in reply to: namrata.nekkanti
    yah copy and paste using dot net API


    regards,
    namrata
    Please use plain text.
    *Bobby C. Jones

    Re: copy block

    11-11-2005 10:38 AM in reply to: namrata.nekkanti
    Here's an example to start with.

    public void CopyBlock(string sourceFileName, string blockName)
    {
    try
    {
    using(Database sourceDatabase =
    GetDatabaseFromFile(sourceFileName))
    {

    HostApplicationServices.WorkingDatabase.Insert(blockName, sourceDatabase,
    false);
    }
    }
    catch (Autodesk.AutoCAD.Runtime.Exception e)
    {
    //Application.ShowAlertDialog(e.Message);
    }
    }

    public Database GetDatabaseFromFile(string fileName)
    {
    Database databaseFromFile = new Database(false, true);
    databaseFromFile.ReadDwgFile(fileName, System.IO.FileShare.None,
    false, null);
    return databaseFromFile;
    }

    --
    Bobby C. Jones
    http://www.acadx.com

    wrote in message news:5007941@discussion.autodesk.com...
    hi,

    I am unable to copy a block from one ACAD drawing to another can any one
    help me on this.

    thanks in advance
    namrata
    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎11-01-2005

    Re: copy block

    11-13-2005 11:54 PM in reply to: namrata.nekkanti
    this code snippet is giving an eror
    it says " self refrenced"
    Please use plain text.
    *Bobby C. Jones

    Re: copy block

    11-14-2005 12:58 PM in reply to: namrata.nekkanti
    The example I posted probably isn't what you're looking for and if you used
    it to try and copy a block from a drawing into another with the same name,
    then I imagine that is the error you would get :-)

    This is the overload of the Insert method that I think you are after.

    currentDatabase.Insert(sourceBlockName, destinationBlockName,
    sourceDatabase, true);

    However, this is creating two btr's. The one with the name provided as the
    sourceBlockName parameter is good, but the one provided as the
    destinationBlockName is empty and can be purged. I did a quick search on
    the ADN site and this was reported a while back. Like in the R2004
    timeframe.
    --
    Bobby C. Jones
    http://www.acadx.com


    wrote in message news:5011912@discussion.autodesk.com...
    this code snippet is giving an eror
    it says " self refrenced"
    Please use plain text.