.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Import dwg content into current dwg:

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
My_Civil_3D
231 Views, 2 Replies

Import dwg content into current dwg:

Hi guys i am looking for a way to import content from a dwg into my current drawing. ive seen several different code to import blocks from a drawing into another which i can do. but it needs to import all content of the model space into the current one at a user specified point. i cant seem to figure this out its way above my skill level if its possible

Civil 3D Certified Professional
2 REPLIES 2
Message 2 of 3
_gile
in reply to: My_Civil_3D

Hi,

You can use this overload of the Database.Insert method.

Here's an example:

private static void InsertDwgContents(string fileName, Point3d insertionPoint)
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var transform = Matrix3d.Displacement(insertionPoint.GetAsVector());
    using (var sourceDatabase = new Database(false, true))
    {
        sourceDatabase.ReadDwgFile(fileName, FileOpenMode.OpenForReadAndAllShare, true, null);
        db.Insert(transform, sourceDatabase, true);
    }
}

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
My_Civil_3D
in reply to: My_Civil_3D

thank you sir that worked

Civil 3D Certified Professional

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report