.NET

Reply
Active Member
namrata.nekkanti
Posts: 8
Registered: ‎11-01-2005
Message 1 of 6 (140 Views)

copy block

140 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
*Lisa
Message 2 of 6 (140 Views)

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
Active Member
namrata.nekkanti
Posts: 8
Registered: ‎11-01-2005
Message 3 of 6 (140 Views)

Re: copy block

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


regards,
namrata
*Bobby C. Jones
Message 4 of 6 (140 Views)

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
Active Member
namrata.nekkanti
Posts: 8
Registered: ‎11-01-2005
Message 5 of 6 (140 Views)

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"
*Bobby C. Jones
Message 6 of 6 (140 Views)

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"
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.