.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 6
namrata.nekkanti
300 Views, 5 Replies

copy block

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
5 REPLIES 5
Message 2 of 6
Anonymous
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
Message 3 of 6

yah copy and paste using dot net API


regards,
namrata
Message 4 of 6
Anonymous
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
Message 5 of 6

this code snippet is giving an eror
it says " self refrenced"
Message 6 of 6
Anonymous
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"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost