Editor.command

Editor.command

giskumar
Enthusiast Enthusiast
3,389 Views
4 Replies
Message 1 of 5

Editor.command

giskumar
Enthusiast
Enthusiast

Hi All,

 

Below code is working fine for me

 

[CommandMethod("T")]
        public void T()
        {
            Autodesk.AutoCAD.ApplicationServices.Document doc =
                   Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            List<ObjectId> oidlist = GlobalFunction.SS.ClsSelection.GetEntsOnScreen("*", "*");

            PromptPointResult ppr = ed.GetPoint("");
            Point3d pt1 = ppr.Value;
            ppr = ed.GetPoint("");
            Point3d pt2 = ppr.Value;
            ppr = ed.GetPoint("");
            Point3d pt3 = ppr.Value;
            ppr = ed.GetPoint("");
            Point3d pt4 = ppr.Value;

            try
            {
                ed.Command("_.ALIGN", oidlist[0], "", pt1, pt2, pt3, pt4, "", "Y");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            MessageBox.Show("Hi");
            
            ed.Command("_.Circle", new Point3d(), 1.0);
        }

But when i call below line from form button click, it is throwing error invalid input.

ed.Command("_.ALIGN", oidlist[0], "", pt1, pt2, pt3, pt4, "", "Y");

Any one plese help me where i am doing mistake.

 

Thanks,

Kumar. 

0 Likes
3,390 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

just Google it - you will find plenty of examples such as

 

http://stackoverflow.com/questions/29371567/calling-autocad-commands-from-c-net

0 Likes
Message 3 of 5

norman.yuan
Mentor
Mentor

What kind of form? modeless form/PaletteSet, which is usually shown from a session command? Or modal form?

 

Keep in mind, Editor.Command() only works in document context, not in application context.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 5

giskumar
Enthusiast
Enthusiast

Hi,

 

Thanks for the reply.

 

What kind of form? modeless form/PaletteSet, which is usually shown from a session command? Or modal form?

It's a pallet set shown from a session command.

 

Thanks & Regards,

Kumar.

0 Likes
Message 5 of 5

norman.yuan
Mentor
Mentor

Therefore, you cannot use Editor.Command().

 

However, you can use Document.SendStringToExecute(....), where the Document is Application.DocumentManager.MdiActiveDocument.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes