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");) 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.
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
@Anonymous.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);
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
wow ... fantastic response ... u absolutely ROCK! thank you thank you thank you
Can't find what you're looking for? Ask the community or share your knowledge.