.NET

Reply
Valued Mentor
kevin.barnett
Posts: 381
Registered: ‎08-13-2007
Message 1 of 3 (343 Views)
Accepted Solution

2012 interop copyobject dwg to dwg

343 Views, 2 Replies
06-21-2012 09:41 PM

autocad 2012. C# express 2010. dotnet framework 4. microsoft windows 7 enterprise 64.

 

This development project is a stand-alone running outside autocad, using the interop.

When you read this, please keep in mind that running dot net inside AutoCAD is not an option in this particular project.

 

Referenced:

Autdesk.AutoCAD.Interop (AutocAD)

Autdesk.AutoCAD.Interop.common (AXDBLib)

 

using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;

 

I found that creating an Acad Table via the COM, with hundreds of rows, is ... not workable - slower than slow.

So, I created the Acad Table in a DXF file - very fast - workable.

I have only one problem.

The CopyObject in the COM (Marshal.GetActiveObject("AutoCAD.Application.18"):smileywink: has either been discontinued or I my code is incorrect --- or there is another way to import the DXF into the DWG?

 

This is the CopyObject code that is doing nothin (does not even throw an exception):

 

Autodesk.AutoCAD.Interop.Common.AcadEntity[] set1 =
new Autodesk.AutoCAD.Interop.Common.AcadEntity[doc2.ModelSpace.Count];
for (int j = 0; j < set1.Length; j++)
{
    set1[j] = doc2.ModelSpace.Item(j);
}

object[] res1 = doc2.Database.CopyObjects(set1, doc1.ModelSpace, Type.Missing);

 

doc1 and doc2 files ar open in acad.

doc1 is the DWG, the drawing that will be the reulting product of this task

doc2 is a temporary DXF that is currenty open

 

Alternatively, what other method could I use to import the DXF straight into doc1 without opening it (bypassing CopyObject)?

I could not find a method, I used:

AcadDocument doc2 = acadApp.Documents.Open(dxfname1, Type.Missing, Type.Missing);

where, dxfname1 is the filename of the temporary DXF file.

 

Thank You ..

Kevin.

 

Moderator
Alexander.Rivilis
Posts: 1,398
Registered: ‎04-09-2008
Message 2 of 3 (340 Views)

Re: 2012 interop copyobject dwg to dwg

06-21-2012 10:19 PM in reply to: kevin.barnett

kevin.barnett wrote:
[...]

I found that creating an Acad Table via the COM, with hundreds of rows, is ... not workable - slower than slow.

[...]


What about AcadTable.RegenerateTableSuppressed property?

AutoCAD ActiveX and VBA Reference say:

Recomputing large tables consumes a lot of time and memory because the Table object is reconstructed from scratch. 

To avoid performance problems, you should temporarily disable the regeneration of the Table object when modifying large tables through the VBA APIs, then apply the modifications and re-enable regeneration.

Also instead of :

object[] res1 = doc2.Database.CopyObjects(set1, doc1.ModelSpace, Type.Missing);

 must be:

object[] res1 = doc1.Database.CopyObjects(set1, doc1.ModelSpace, Type.Missing);

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Mentor
kevin.barnett
Posts: 381
Registered: ‎08-13-2007
Message 3 of 3 (336 Views)

Re: 2012 interop copyobject dwg to dwg

06-21-2012 11:16 PM in reply to: Alexander.Rivilis

wow ... fantastic response ... u absolutely ROCK! thank you thank you thank you

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community