Author Topic: Using AutoCAD dialogs  (Read 922 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Using AutoCAD dialogs
« on: June 17, 2012, 10:34:21 AM »
Code: [Select]
       using Autodesk.AutoCAD.Runtime;
        using Autodesk.AutoCAD.ApplicationServices;
        using Autodesk.AutoCAD.DatabaseServices;
        using Autodesk.AutoCAD.Geometry;
        using Autodesk.AutoCAD.EditorInput;
        using Autodesk.AutoCAD.EditorInput;
        using Autodesk.AutoCAD.Windows;
        //________________________________________//

        [Obsolete]//   just for use ObjectId.Open method below
        [CommandMethod("setlt")]
        public static void SetLinetype()
        {
            var db = HostApplicationServices.WorkingDatabase;
            var ld = new Autodesk.AutoCAD.Windows.LinetypeDialog();
            if (ld.ShowDialog() != DialogResult.OK) return;
            var ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;           
            LinetypeTableRecord ltr = ld.Linetype.Open(OpenMode.ForRead, false) as LinetypeTableRecord;
            ed.WriteMessage("\nSelected linetype: " + ltr.Name);
            db.Celtype = ld.Linetype;
        }


        [CommandMethod("setc")]
        public static void SetColor()
        {
            var db = HostApplicationServices.WorkingDatabase;
            var cd = new Autodesk.AutoCAD.Windows.ColorDialog();
            if (cd.ShowDialog() != DialogResult.OK) return;
            var ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("\nSelected color: " + cd.Color);
            db.Cecolor = cd.Color;

        }
   
        [CommandMethod("setlw")]
        public static void SetLineWeight()
        {
            var db = HostApplicationServices.WorkingDatabase;
            var lw = new Autodesk.AutoCAD.Windows.LineWeightDialog();
            if (lw.ShowDialog() != DialogResult.OK) return;
            var ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            LineWeight lwt = lw.LineWeight;
            ed.WriteMessage("\nSelected linetype: " + lwt.ToString());
            db.Celweight = lwt;
        }

~'J'~