Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:51:39+00:00 2026-05-30T14:51:39+00:00

I need to insert an external DWG into an AutoCAD drawing via C# plugin.

  • 0

I need to insert an external DWG into an AutoCAD drawing via C# plugin.
I need to “ask” to the user the insertion point and rotation of the inserted block.
Until now I’ve always used a lisp function that calls the command “._-insert” which gives a thumbnail of the block under the mouse, allows the user to click into the drawing to set the insertion point and from that point allows the user to click one more time to set the rotation.
Now I want to avoid the use of Lisp or the use of low level API of AutoCAD because I need a solution that runs over various CAD environments.
What I found is something like this:

public static void InsertDwg(string dwgName)
    {
        CADAPI.ApplicationServices.Document doc = CADAPI.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
        CADDB.Database db = doc.Database;
        CADAPI.EditorInput.Editor ed = doc.Editor;
        CADDB.ObjectId ObjId;
        using (CADDB.Transaction trx = db.TransactionManager.StartTransaction())
        {
            CADDB.BlockTable bt = db.BlockTableId.GetObject(CADDB.OpenMode.ForRead) as CADDB.BlockTable;
            CADDB.BlockTableRecord btrMs = bt[CADDB.BlockTableRecord.ModelSpace].GetObject(CADDB.OpenMode.ForWrite) as CADDB.BlockTableRecord;
            using (CADDB.Database dbInsert = new CADDB.Database(false, true))
            {
                dbInsert.ReadDwgFile(dwgName, CADDB.FileOpenMode.OpenForReadAndAllShare, true, string.Empty);
                ObjId = db.Insert(Path.GetFileNameWithoutExtension(dwgName), dbInsert, true);
            }
            CADAPI.EditorInput.PromptPointOptions ppo = new CADAPI.EditorInput.PromptPointOptions("\nInsertion Point");
            CADAPI.EditorInput.PromptAngleOptions ppa = new CADAPI.EditorInput.PromptAngleOptions("\nInsert Rotation");
            CADAPI.EditorInput.PromptPointResult ppr;
            ppr = ed.GetPoint(ppo);
            CADAPI.EditorInput.PromptDoubleResult ppd = ed.GetAngle(ppa);
            if (ppr.Status == CADAPI.EditorInput.PromptStatus.OK)
            {
                CADGEOM.Point3d insertPt = ppr.Value;
                CADDB.BlockReference bref = new CADDB.BlockReference(insertPt, ObjId);
                btrMs.AppendEntity(bref);
                trx.AddNewlyCreatedDBObject(bref, true);
                trx.Commit();
            }
        }
    }

But here I have two problems:
The main one is that there is no preview under the mouse.
The second is that the user needs to click 3 times instead of 2 to set both the insertion point and the rotation.

Is there any way that doesn’t use some kind of SendCommand and does all of this stuff?
TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:51:40+00:00Added an answer on May 30, 2026 at 2:51 pm

    It seems Jigging is the way to go to allow the preview. I have three links for you.

    • Jigging multiple entities with the DrawJig
    • Using a jig to rotate an AutoCAD entity via .NET
    • Using transient graphics to simulate AutoCAD’s MOVE command using .NET

    The first is an example of creating a simple jig with polylines – you could extend this to a block.

    The second link is similar but applies rotation to the mix. This is applied to a rectangle but again could be modified to accomodate a block.

    The third link describes a different method – AutoCADs transient graphics interface. You must be using AutoCAD 2009 or later to use this method.

    The last two links are from the Through the Interface blog, where you may find some more examples and is a very good starting point if you have problems, especially for coding C#.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to insert selected text on the page into textarea. There must be some
I need to insert records into a table that has no primary key using
I need to insert an HTML string into the <head> tag of the current
I need to insert about 1.8 million rows from a CSV file into a
I need to insert data from table1 into table2. However, I would like to
I need to insert values in to the db. INSERT INTO tblname(f1,f2,f3) SELECT f1,f2,f3
I need a list where when a user types a letter into an above
Hi need insert data in table if the record is not already exits Ex:
I need to insert string to text file, for example, before first line from
I need to insert/update data by using link or image I need a code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.