1

(11 ответов, оставленных в .NET)

Константин пишет:

А вариант acad2010+ Visual Studio 2008 + ObjectARX SDK для ac2010 и ac2014 у меня прокатит ?

для ac2010 и ac2014 Visual Studio 2010 будет нормально, Visual Studio 2008
только для А2010 и ниже

2

(11 ответов, оставленных в .NET)

Константин пишет:

или мне придется ставить себе acad2014+Visual Studio 2010 ?

Я лично так и делаю acad2014 Плюс Visual Studio 2010 библиотеки
гружу из папки Program Files\Autodes\AutoCAD 2014... без проблем

3

(11 ответов, оставленных в .NET)

Пробуй таким макаром:

[assembly: CommandClass(typeof(ProjectName.ClassName))]
namespace ProjectName
{
    public class ClassName
    {

        [CommandMethod("myCommandName", CommandFlags.Session)]или другой нужный CommandFlags

        public void TestMyCommand()// или public static void
        {
    //--------------------------------//
    }
  }
}

4

(3 ответов, оставленных в .NET)

Ирина пишет:

Подскажите, где найти описание свойствам объекта DimStyleTableRecord.

Посмотри рабочие примеры (А2014)

       /// <summary>
        /// Settings For STD1 DimStyle
        /// </summary>
        /// <param name="doc"></param>
        public static void SettingsForSTD1DimStyle(Document doc)
        {
            try
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    Database db = doc.Database;

                    DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true);

                    // Initialise a DimStyleTableRecord
                    DimStyleTableRecord dstr = null;
                    // If the required dimension style exists
                    if (dst.Has("STD1"))
                    {
                        // get the dimension style table record open for writing
                        dstr = (DimStyleTableRecord)tr.GetObject(dst["STD1"], OpenMode.ForWrite);
                    }
                    else
                        // Initialise as a new dimension style table record
                        dstr = new DimStyleTableRecord();
                    dstr.Name = "STD1";
                    // dstr.Annotative = AnnotativeStates.True;
                    dstr.Dimadec = 2;
                    dstr.Dimalt = false;
                    dstr.Dimaltd = 2;
                    dstr.Dimaltf = 25.4;
                    dstr.Dimaltrnd = 0;
                    dstr.Dimalttd = 2;
                    dstr.Dimalttz = 0;
                    dstr.Dimaltu = 2;
                    dstr.Dimaltz = 0;
                    dstr.Dimapost = "";
                    dstr.Dimarcsym = 0;
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMASSOC", 2);
                    dstr.Dimasz = 0.1;
                    dstr.Dimatfit = 3;
                    dstr.Dimaunit = 0;
                    dstr.Dimazin = 0;
                    dstr.Dimblk = ObjectId.Null;
                    dstr.Dimblk1 = ObjectId.Null;
                    dstr.Dimblk2 = ObjectId.Null;
                    dstr.Dimcen = 0.09;
                    dstr.Dimclrd = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclre = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclrt = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONSTRAINTICON", 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONTINUEMODE", 1);
                    dstr.Dimdec = 4;
                    dstr.Dimdle = 0;
                    dstr.Dimdli = 0.5;
                    dstr.Dimdsep = Convert.ToChar(".");
                    dstr.Dimexe = 0.1;
                    dstr.Dimexo = 0.0625;
                    dstr.Dimfrac = 2;
                    dstr.Dimfxlen = 1.0;
                    dstr.DimfxlenOn = false;
                    dstr.Dimgap = 0.03;
                    dstr.Dimjogang = 0.7854;
                    dstr.Dimjust = 0;
                    dstr.Dimldrblk = ObjectId.Null;
                    dstr.Dimlfac = 1;
                    dstr.Dimlim = false;
                    dstr.Dimlunit = 5;
                    dstr.Dimlwd = LineWeight.ByLineWeightDefault;//-2;
                    dstr.Dimlwe = LineWeight.ByLineWeightDefault;//-2
                    dstr.Dimpost = "";
                    dstr.Dimrnd = 0;
                    dstr.Dimsah = false;
                    dstr.Dimscale = 24.0;
                    dstr.Dimsd1 = false;
                    dstr.Dimsd2 = false;
                    dstr.Dimse1 = false;
                    dstr.Dimse2 = false;
                    dstr.Dimsoxd = false;
                    dstr.Dimtad = 1;
                    dstr.Dimtdec = 5;
                    dstr.Dimtfac = 1;
                    dstr.Dimtfill = 0;
                    dstr.Dimtfillclr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimtih = false;
                    dstr.Dimtix = false;
                    dstr.Dimtm = 0;
                    dstr.Dimtmove = 0;
                    dstr.Dimtofl = true;
                    dstr.Dimtoh = false;
                    dstr.Dimtol = false;
                    dstr.Dimtolj = 1;
                    dstr.Dimtp = 0;
                    dstr.Dimtsz = 0;
                    dstr.Dimtvp = 0;
                    dstr.Dimtxsty = db.Dimtxsty;
                    dstr.Dimtxt = 0.125;
                    dstr.Dimtxtdirection = false;
                    dstr.Dimtzin = 0;
                    dstr.Dimupt = false;
                    dstr.Dimzin = 4;

                    // If the dimension style doesn't exist
                    if (!dst.Has("STD1"))
                    {
                        // Add it to the dimension style table and collect its Id
                        Object dsId = dst.Add(dstr);
                        // Add the new dimension style table record to the document
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    if (dstr.ObjectId != db.Dimstyle)
                    {

                        db.Dimstyle = dstr.ObjectId;

                        db.SetDimstyleData(dstr);

                    }
                    // Commit the changes.
                    tr.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                doc.Editor.WriteMessage(e.Message + "\n" + e.StackTrace);
            }
        }

        /// <summary>
        /// Settings For 24 Standard
        /// </summary>
        /// <param name="doc"></param>
        public static void SettingsFor24Standard(Document doc)
        {
            try
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    Database db = doc.Database;

                    DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true);

                    // Initialise a DimStyleTableRecord
                    DimStyleTableRecord dstr = null;
                    // If the required dimension style exists
                    if (dst.Has("24 standard"))
                    {
                        // get the dimension style table record open for writing
                        dstr = (DimStyleTableRecord)tr.GetObject(dst["24 standard"], OpenMode.ForWrite);
                    }
                    else
                        // Initialise as a new dimension style table record
                        dstr = new DimStyleTableRecord();
                    dstr.Name = "24 standard";
                    dstr.Dimadec = 2;
                    dstr.Dimalt = false;
                    dstr.Dimaltd = 2;
                    dstr.Dimaltf = 25.4;
                    dstr.Dimaltrnd = 0;
                    dstr.Dimalttd = 2;
                    dstr.Dimalttz = 0;
                    dstr.Dimaltu = 2;
                    dstr.Dimaltz = 0;
                    dstr.Dimapost = "";
                    dstr.Dimarcsym = 0;
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMASSOC", 2);
                    dstr.Dimasz = 0.1175;
                    dstr.Dimatfit = 3;
                    dstr.Dimaunit = 0;
                    dstr.Dimazin = 0;
                    dstr.Dimblk = ObjectId.Null;
                    dstr.Dimblk1 = ObjectId.Null;
                    dstr.Dimblk2 = ObjectId.Null;
                    dstr.Dimcen = 0.09;
                    dstr.Dimclrd = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimclre = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimclrt = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONSTRAINTICON", 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONTINUEMODE", 1);
                    dstr.Dimdec = 5;
                    dstr.Dimdle = 0;
                    dstr.Dimdli = 0.38;
                    dstr.Dimdsep = Convert.ToChar(".");
                    dstr.Dimexe = 0.0863;
                    dstr.Dimexo = 0.0625;
                    dstr.Dimfrac = 0;
                    //dstr.Dimfxl = 1.0;
                    dstr.DimfxlenOn = false;
                    dstr.Dimgap = 0.09;
                    dstr.Dimjogang = 0.7854;
                    dstr.Dimjust = 0;
                    dstr.Dimldrblk = ObjectId.Null;
                    dstr.Dimlfac = 1;
                    dstr.Dimlim = false;
                    dstr.Dimlunit = 4;
                    dstr.Dimlwd = LineWeight.LineWeight025;//-2;
                    dstr.Dimlwe = LineWeight.LineWeight025;//-2
                    dstr.Dimpost = "";
                    dstr.Dimrnd = 0.0625;
                    dstr.Dimsah = false;
                    dstr.Dimscale = 24.0;
                    dstr.Dimsd1 = false;
                    dstr.Dimsd2 = false;
                    dstr.Dimse1 = false;
                    dstr.Dimse2 = false;
                    dstr.Dimsoxd = false;
                    dstr.Dimtad = 1;
                    dstr.Dimtdec = 4;
                    dstr.Dimtfac = 1;
                    dstr.Dimtfill = 0;
                    dstr.Dimtfillclr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimtih = false;
                    dstr.Dimtix = true;
                    dstr.Dimtm = 0;
                    dstr.Dimtmove = 2;
                    dstr.Dimtofl = true;
                    dstr.Dimtoh = false;
                    dstr.Dimtol = false;
                    dstr.Dimtolj = 1;
                    dstr.Dimtp = 0;
                    dstr.Dimtsz = 0;
                    dstr.Dimtvp = 0;
                    dstr.Dimtxsty = db.Dimtxsty;
                    dstr.Dimtxt = 0.18;
                    dstr.Dimtxtdirection = false;
                    dstr.Dimtzin = 0;

                    // If the dimension style doesn't exist
                    if (!dst.Has("roughopening"))
                    {
                        // Add it to the dimension style table and collect its Id
                        Object dsId = dst.Add(dstr);
                        // Add the new dimension style table record to the document
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    if (dstr.ObjectId != db.Dimstyle)
                    {

                        db.Dimstyle = dstr.ObjectId;

                        db.SetDimstyleData(dstr);

                    }
                    // Commit the changes.
                    tr.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                doc.Editor.WriteMessage(e.Message + "\n" + e.StackTrace);
            }
        }

        /// <summary>
        /// Settings For RoughOpening
        /// </summary>
        /// <param name="doc"></param>
        public static void SettingsForRoughOpening(Document doc)
        {
            try
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    Database db = doc.Database;

                    DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true);

                    // Initialise a DimStyleTableRecord
                    DimStyleTableRecord dstr = null;
                    // If the required dimension style exists
                    if (dst.Has("ROUGHOPENING"))
                    {
                        // get the dimension style table record open for writing
                        dstr = (DimStyleTableRecord)tr.GetObject(dst["ROUGHOPENING"], OpenMode.ForWrite);
                    }
                    else
                        // Initialise as a new dimension style table record
                        dstr = new DimStyleTableRecord();
                    dstr.Name = "ROUGHOPENING";
                    //
                    dstr.Dimadec = 2;
                    dstr.Dimalt = true;
                    dstr.Dimaltd = 5;
                    dstr.Dimaltf = 1.0000;
                    dstr.Dimaltrnd = 0.0000;
                    dstr.Dimalttd = 5;
                    dstr.Dimalttz = 0;
                    dstr.Dimaltu = 7;
                    dstr.Dimaltz = 4;
                    dstr.Dimapost = "''";
                    dstr.Dimarcsym = 0;
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMASSOC", 2);
                    dstr.Dimasz = 0.1000;
                    dstr.Dimatfit = 3;
                    dstr.Dimaunit = 1;
                    dstr.Dimazin = 0;
                    dstr.Dimblk = ObjectId.Null;
                    dstr.Dimblk1 = ObjectId.Null;
                    dstr.Dimblk2 = ObjectId.Null;
                    dstr.Dimcen = 0.0900;
                    dstr.Dimclrd = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclre = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclrt = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONSTRAINTICON", 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONTINUEMODE", 1);
                    dstr.Dimdec = 5;
                    dstr.Dimdle = 0.0000;
                    dstr.Dimdli = 0.5000;
                    dstr.Dimdsep = '.';
                    dstr.Dimexe = 0.1000;
                    dstr.Dimexo = 0.0625;
                    dstr.Dimfrac = 2;
                    //dstr.Dimfxl= 1.0000;
                    //dstr.Dimfxlon= 0;
                    dstr.Dimgap = 0.0300;
                    dstr.Dimjogang = 0.7854;
                    dstr.Dimjust = 0;
                    dstr.Dimldrblk = ObjectId.Null;
                    dstr.Dimlfac = 1.0000;
                    dstr.Dimlim = false;
                    dstr.Dimlunit = 4;
                    dstr.Dimlwd = LineWeight.ByLineWeightDefault;
                    dstr.Dimlwe = LineWeight.ByLineWeightDefault;
                    dstr.Dimpost = @" R.O. \X ";
                    dstr.Dimrnd = 0.0000;
                    dstr.Dimsah = false;
                    dstr.Dimscale = 24.0000;
                    dstr.Dimsd1 = false;
                    dstr.Dimsd2 = false;
                    dstr.Dimse1 = false;
                    dstr.Dimse2 = false;
                    dstr.Dimsoxd = false;
                    dstr.Dimtad = 1;
                    dstr.Dimtdec = 5;
                    dstr.Dimtfac = 1.0000;
                    dstr.Dimtfill = 0;
                    dstr.Dimtfillclr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimtih = false;
                    dstr.Dimtix = false;
                    dstr.Dimtm = 0.0000;
                    dstr.Dimtmove = 0;
                    dstr.Dimtofl = true;
                    dstr.Dimtoh = false;
                    dstr.Dimtol = false;
                    dstr.Dimtolj = 1;
                    dstr.Dimtp = 0.0000;
                    dstr.Dimtsz = 0.0000;
                    dstr.Dimtvp = 0.0000;
                    dstr.Dimtxsty = db.Dimtxsty;
                    dstr.Dimtxt = 0.1250;
                    dstr.Dimtxtdirection = false;
                    dstr.Dimtzin = 0;
                    dstr.Dimupt = false;
                    dstr.Dimzin = 3;

                    // If the dimension style doesn't exist
                    if (!dst.Has("ROUGHOPENING"))
                    {
                        // Add it to the dimension style table and collect its Id
                        Object dsId = dst.Add(dstr);
                        // Add the new dimension style table record to the document
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    if (dstr.ObjectId != db.Dimstyle)
                    {

                        db.Dimstyle = dstr.ObjectId;

                        db.SetDimstyleData(dstr);

                    }
                    // Commit the changes.
                    tr.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                doc.Editor.WriteMessage(e.Message + "\n" + e.StackTrace);
            }
        }
        /// <summary>
        /// Settings For Dlo Dimstyle
        /// </summary>
        /// <param name="doc"></param>
        public static void SettingsForDloDim(Document doc)
        {
            try
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    Database db = doc.Database;

                    DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true);

                    // Initialise a DimStyleTableRecord
                    DimStyleTableRecord dstr = null;
                    // If the required dimension style exists
                    if (dst.Has("DLODIM"))
                    {
                        // get the dimension style table record open for writing
                        dstr = (DimStyleTableRecord)tr.GetObject(dst["DLODIM"], OpenMode.ForWrite);
                    }
                    else
                        // Initialise as a new dimension style table record
                        dstr = new DimStyleTableRecord();
                    dstr.Name = "DLODIM";
                    //_________dlodim________________//
                    dstr.Dimadec = 2;
                    dstr.Dimalt = false;
                    dstr.Dimaltd = 3;
                    dstr.Dimaltf = 1.0000;
                    dstr.Dimaltrnd = 0.0000;
                    dstr.Dimalttd = 3;
                    dstr.Dimalttz = 0;
                    dstr.Dimaltu = 7;
                    dstr.Dimaltz = 4;
                    dstr.Dimapost = "''";
                    dstr.Dimarcsym = 0;
                    //dstr.Dimassoc= 2;
                    dstr.Dimasz = 0.1000;
                    dstr.Dimatfit = 3;
                    dstr.Dimaunit = 0;
                    dstr.Dimazin = 0;
                    dstr.Dimblk = ObjectId.Null;
                    dstr.Dimblk1 = ObjectId.Null;
                    dstr.Dimblk2 = ObjectId.Null;
                    dstr.Dimcen = 0.0900;
                    dstr.Dimclrd = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclre = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclrt = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONSTRAINTICON", 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONTINUEMODE", 1);
                    dstr.Dimdec = 5;
                    dstr.Dimdle = 0.0000;
                    dstr.Dimdli = 0.5000;
                    dstr.Dimdsep = '.';
                    dstr.Dimexe = 0.1000;
                    dstr.Dimexo = 0.0625;
                    dstr.Dimfrac = 2;
                    dstr.Dimfxlen = 1.0000;
                    //dstr.Dimfxlon= 0;
                    dstr.Dimgap = 0.0300;
                    dstr.Dimjogang = 0.7854;
                    dstr.Dimjust = 0;
                    dstr.Dimldrblk = ObjectId.Null;
                    dstr.Dimlfac = 1.0000;
                    dstr.Dimlim = false;
                    dstr.Dimlunit = 5;
                    dstr.Dimlwd = LineWeight.LineWeight025;//-2;
                    dstr.Dimlwe = LineWeight.LineWeight025;//-2
                    dstr.Dimpost = "\\XD.L.O.";
                    dstr.Dimrnd = 0.0000;
                    dstr.Dimsah = false;
                    dstr.Dimscale = 24.0000;
                    dstr.Dimsd1 = false;
                    dstr.Dimsd2 = false;
                    dstr.Dimse1 = false;
                    dstr.Dimse2 = false;
                    dstr.Dimsoxd = false;
                    dstr.Dimtad = 1;
                    dstr.Dimtdec = 5;
                    dstr.Dimtfac = 1.0000;
                    dstr.Dimtfill = 0;
                    dstr.Dimtfillclr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimtih = false;
                    dstr.Dimtix = false;
                    dstr.Dimtm = 0.0000;
                    dstr.Dimtmove = 0;
                    dstr.Dimtofl = true;
                    dstr.Dimtoh = false;
                    dstr.Dimtol = false;
                    dstr.Dimtolj = 1;
                    dstr.Dimtp = 0.0000;
                    dstr.Dimtsz = 0.0000;
                    dstr.Dimtvp = 0.0000;
                    dstr.Dimtxsty = db.Dimtxsty;
                    dstr.Dimtxt = 0.1250;
                    dstr.Dimtxtdirection = false;
                    dstr.Dimtzin = 0;
                    dstr.Dimupt = false;
                    dstr.Dimzin = 4;
                    //_________roughopening________________//
                    // If the dimension style doesn't exist
                    if (!dst.Has("DLODIM"))
                    {
                        // Add it to the dimension style table and collect its Id
                        Object dsId = dst.Add(dstr);
                        // Add the new dimension style table record to the document
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    if (dstr.ObjectId != db.Dimstyle)
                    {

                        db.Dimstyle = dstr.ObjectId;

                        db.SetDimstyleData(dstr);

                    }
                    // Commit the changes.
                    tr.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                doc.Editor.WriteMessage(e.Message + "\n" + e.StackTrace);
            }
        }

        /// <summary>
        /// Settings For Frame Dimstyle
        /// </summary>
        /// <param name="doc"></param>
        public static void SettingsForFrameDim(Document doc)
        {
            try
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    Database db = doc.Database;

                    DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true);

                    // Initialise a DimStyleTableRecord
                    DimStyleTableRecord dstr = null;
                    // If the required dimension style exists
                    if (dst.Has("FRAMEDIM"))
                    {
                        // get the dimension style table record open for writing
                        dstr = (DimStyleTableRecord)tr.GetObject(dst["FRAMEDIM"], OpenMode.ForWrite);
                    }
                    else
                        // Initialise as a new dimension style table record
                        dstr = new DimStyleTableRecord();
                    dstr.Name = "FRAMEDIM";
                    //___________FRAMEDIM_________________
                    dstr.Dimadec = 2;
                    dstr.Dimalt = false;
                    dstr.Dimaltd = 3;
                    dstr.Dimaltf = 1.0000;
                    dstr.Dimaltrnd = 0.0000;
                    dstr.Dimalttd = 3;
                    dstr.Dimalttz = 0;
                    dstr.Dimaltu = 7;
                    dstr.Dimaltz = 4;
                    dstr.Dimapost = "";
                    dstr.Dimarcsym = 0;
                    //dstr.Dimassoc= 2;
                    dstr.Dimasz = 0.1000;
                    dstr.Dimatfit = 3;
                    dstr.Dimaunit = 1;
                    dstr.Dimazin = 0;
                    dstr.Dimblk = ObjectId.Null;
                    dstr.Dimblk1 = ObjectId.Null;
                    dstr.Dimblk2 = ObjectId.Null;
                    dstr.Dimcen = 0.0900;
                    dstr.Dimclrd = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclre = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1);
                    dstr.Dimclrt = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONSTRAINTICON", 3);
                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("DIMCONTINUEMODE", 1);
                    dstr.Dimdec = 5;
                    dstr.Dimdle = 0.0000;
                    dstr.Dimdli = 0.5000;
                    dstr.Dimdsep = '.';
                    dstr.Dimexe = 0.1000;
                    dstr.Dimexo = 0.0625;
                    dstr.Dimfrac = 2;
                    dstr.Dimfxlen = 1.0000;
                    //dstr.Dimfxlon= 0;
                    dstr.Dimgap = 0.0300;
                    dstr.Dimjogang = 0.7854;
                    dstr.Dimjust = 0;
                    dstr.Dimldrblk = ObjectId.Null;
                    dstr.Dimlfac = 1.0000;
                    dstr.Dimlim = false;
                    dstr.Dimlunit = 5;
                    dstr.Dimlwd = LineWeight.LineWeight025;//-2;
                    dstr.Dimlwe = LineWeight.LineWeight025;//-2
                    dstr.Dimpost = @"\X F.D.";
                    dstr.Dimrnd = 0.0000;
                    dstr.Dimsah = false;
                    dstr.Dimscale = 24.0000;
                    dstr.Dimsd1 = false;
                    dstr.Dimsd2 = false;
                    dstr.Dimse1 = false;
                    dstr.Dimse2 = false;
                    dstr.Dimsoxd = false;
                    dstr.Dimtad = 1;
                    dstr.Dimtdec = 5;
                    dstr.Dimtfac = 1.0000;
                    dstr.Dimtfill = 0;
                    dstr.Dimtfillclr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 0);
                    dstr.Dimtih = false;
                    dstr.Dimtix = false;
                    dstr.Dimtm = 0.0000;
                    dstr.Dimtmove = 2;
                    dstr.Dimtofl = true;
                    dstr.Dimtoh = false;
                    dstr.Dimtol = false;
                    dstr.Dimtolj = 1;
                    dstr.Dimtp = 0.0000;
                    dstr.Dimtsz = 0.0000;
                    dstr.Dimtvp = 0.0000;
                    dstr.Dimtxsty = db.Dimtxsty;
                    dstr.Dimtxt = 0.1250;
                    dstr.Dimtxtdirection = false;
                    dstr.Dimtzin = 0;
                    dstr.Dimupt = false;
                    dstr.Dimzin = 4;
                    //___________FRAMEDIM_________________
                    // If the dimension style doesn't exist
                    if (!dst.Has("FRAMEDIM"))
                    {
                        // Add it to the dimension style table and collect its Id
                        Object dsId = dst.Add(dstr);
                        // Add the new dimension style table record to the document
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    if (dstr.ObjectId != db.Dimstyle)
                    {

                        db.Dimstyle = dstr.ObjectId;

                        db.SetDimstyleData(dstr);

                    }
                    // Commit the changes.
                    tr.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                doc.Editor.WriteMessage(e.Message + "\n" + e.StackTrace);
            }
        }

5

(14 ответов, оставленных в LISP)

Кулик Алексей aka kpblc пишет:

Я, наверно, слишком хорошо понимаю AutoCAD с точки зрения лиспа...

Я прям разрыдался от умиления

6

(14 ответов, оставленных в .NET)

Ирина пишет:

Попробовала, не работает, также как и ed.SelectCrossingWindow(new Point3d(pt1.X - 0.1, pt1.Y - 0.1, pt1.Z - 0.1), new Point3d(pt1.X + 0.1, pt1.Y + 0.1, pt1.Z + 0.1), acSelFtr).

Забыла уточнить, что чертеж состоит из 3DSolid.

Попробуй выполнить команду '_vscurrent 2d' перед запуском кода,
у меня выбирает 3DSolid без проблем, проверял в 2014-м

Удачи :)

8

(14 ответов, оставленных в .NET)

Попробуй так, установи привязку на 512 или 513 вначале
(нет под рукой где проверить на ближайшую)
   

  Dim ppo As New PromptPointOptions(vbLf & "Pick a Point: ")
                    Dim ppr As PromptPointResult
                    ppr = ed.GetPoint(ppo)
                    If ppr.Status <> PromptStatus.OK Then
                        ed.WriteMessage(vbCrLf & "wrong point specification!")
                        Exit Sub
                    End If
                    Dim p As Point3d = ppr.Value
                    '------------------------------------------------------------''
                    Dim vd As Vector3d = New Vector3d(1e-4, 1e-4, 1e-4) '<--  dicrease a fuzz to suit
                    Dim pMin As Point3d = p - vd
                    Dim pMax As Point3d = p + vd              
                    Dim tvs() As TypedValue = New TypedValue() { New TypedValue(0, "line")} '<--  измени тип объекта здесь
                    Dim points As Point3dCollection = New Point3dCollection
                    points.Add(pMin)
                    points.Add(pMax)
                    Dim sf As SelectionFilter = New SelectionFilter(tvs)
                    Dim sres As PromptSelectionResult = ed.SelectFence(points, sf)
                    If sres.Status <> PromptStatus.OK Then
                        ed.WriteMessage("\nWrong selection!")
                        Return
                    End If

                    If sres.Value.Count = 0 Then
                        ed.WriteMessage("\nNothing selected!")
                        Return
                    End If
                    '' cast entity as Line
                    Dim eid As ObjectId = sres.Value.GetObjectIds(0)
                    Dim ent As Entity = TryCast(tr.GetObject(eid, OpenMode.ForRead), Entity)
                    ''-----------------------------------------------------------''
                    Dim ln As Line = TryCast(ent, Line)
                    If ln IsNot Nothing Then
                        ed.WriteMessage(vbLf + "{0},{1},{2}", ln.StartPoint.X, ln.StartPoint.Y, ln.StartPoint.Z)
                    End If

Типа этого?

        [CommandMethod("cda", CommandFlags.Redraw)]
        public static void ChangeBlockDefault()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;

            Database db = HostApplicationServices.WorkingDatabase;
            string blkName = "PART";
            string mytag = "JOBNO";
            string myvalue = "New Attribute Value";
            using (DocumentLock dlock = doc.LockDocument())
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    doc.TransactionManager.EnableGraphicsFlush(true);
                    try
                    {
                        BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
                        
                        if (!bt.Has(blkName)) return;
                        BlockTableRecord bdef = trans.GetObject(bt[blkName], OpenMode.ForRead) as BlockTableRecord;
                        if (bdef == null) return;
                        bt.UpgradeOpen();
                        bdef.UpgradeOpen();
                        foreach (ObjectId id in bdef)
                        {
                            if (id.ObjectClass.IsDerivedFrom(RXClass.GetClass(typeof(AttributeDefinition))))
                            {
                                AttributeDefinition atdef = trans.GetObject(id, OpenMode.ForWrite) as AttributeDefinition;
                                if (atdef.Tag == mytag)
                                {
                                    atdef.TextString = myvalue;
                                    trans.TransactionManager.QueueForGraphicsFlush();
                                    break;
                                }
                            }
                        }
                        bdef.DowngradeOpen();
                        bt.DowngradeOpen();
                        ObjectIdCollection brids = bdef.GetBlockReferenceIds(true, true);
                        foreach (ObjectId brid in brids)
                        {
                            DBObject obj = trans.GetObject(brid, OpenMode.ForWrite);
                            BlockReference bref = (BlockReference)obj;
                            AttributeCollection atcol = bref.AttributeCollection;
                            foreach (ObjectId attid in atcol)
                            {
                                AttributeReference atref = trans.GetObject(attid, OpenMode.ForRead) as AttributeReference;
                                if (atref.Tag == mytag)
                                {
                                    if (!atref.IsWriteEnabled) atref.UpgradeOpen();
                                    atref.TextString = myvalue;
                                }
                            }
                            bref.RecordGraphicsModified(true);
                            trans.TransactionManager.QueueForGraphicsFlush();
                        }


                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception ex)
                    {
                        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message);
                    }
                    doc.TransactionManager.FlushGraphics();
                    trans.Commit();
                }
            }
        }
Денис Перепецкий пишет:

Может база не готова к моменту когда меTод начинает работу... не знаю.
Просьба оказать посильную помощь кто может.

Я думаю ошибка в том что документ не блокируется
при изменении системных переменных
добавь LockDocument перед транзакцией

Если точки известны, попробуй так (не уверен, что правильно)

(setq sset (ssget "_WP" (list p1 p2 p3)))

12

(2 ответов, оставленных в .NET)

Василий Рубашка пишет:

Как можно наклонить текст в определённой ячейке таблицы?

Получить ответ можно везде, где есть знающие люди, напр.
после заполнения таблицы данными можешь использовать
такой вариант:

Cell cell = tb.Cells[0, 0];
                cell.Contents[0].Rotation = Math.PI / 4;

Поверено в 2010-м, номер ячейки произвольный

Можно попробовать сохранить файл временно с другим именем,
распечатать копию и потом удалить, нету принтера на моем компе,
проверить не могу, только идея...

Попробуй так, проверено в 2014-м:

        [CommandMethod("sav", CommandFlags.Session)]
public static void SaveDrawingDialog()
{
    string dwgname = "";
    var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
            using(var dc = doc.LockDocument()){
    Autodesk.AutoCAD.Windows.SaveFileDialog sdia = new Autodesk.AutoCAD.Windows.SaveFileDialog(
                     "File name to save:",
                     "",//имя файла можно без расширения
                     "dwg",//расширение файла, обязательно
                     "SaveFile Dialog",// имя диалога, необязательно
                     Autodesk.AutoCAD.Windows.SaveFileDialog.SaveFileDialogFlags.DoNotTransferRemoteFiles);
    // показываем диалог сохранения          
   sdia.ShowDialog();
                // получаем результат
   dwgname = sdia.Filename;
   // если не пустая строка сохраняем с указанным именем
   if (dwgname != "")
   {
       try
       {
           db.SaveAs(dwgname, true, DwgVersion.Current, db.SecurityParameters);
           
       }

       catch { }
   }
            }
            // закрываем файл после сохранения, если нужно, в противном случае закомментируй строку:
            doc.CloseAndSave(dwgname);
}

15

(3 ответов, оставленных в LISP)

Думаю, проблема возникла из-за реализации функции ‘setq’.

Правильно думаешь :)

16

(3 ответов, оставленных в LISP)

Используй функцию equal с допуском,
напр.:

(setq a 0.0012346
          b 0.0012356)
(if (equal a b 0.00001);|допуск = 0.00001|:
(alert "равно")
(alert "не равно")
)

Писал без автокада но как-то так...

17

(1 ответов, оставленных в .NET)

Попробуй так но не уверен

hDoc.Editor.Regen();
tr.Commit(); 
hDoc.Editor.UpdateScreen();

18

(3 ответов, оставленных в .NET)

Попробуй по-другому

        [CommandMethod("tho", CommandFlags.UsePickSet)]
        static public void makeHatch()
        {
            Document aDoc = AcAp.Application.DocumentManager.MdiActiveDocument;
            Database db = aDoc.Database;
            Editor ed = aDoc.Editor;

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                    ObjectIdCollection lnIds = new ObjectIdCollection();
                    DBObjectCollection objs = new DBObjectCollection();
                    Circle crc = new Circle();
                    crc.Center = new Point3d(0, 0, 0);
                    crc.Radius = 10;
                    btr.AppendEntity(crc);
                    tr.AddNewlyCreatedDBObject(crc, true);
               
                        Line ln1 = new Line();
                        ln1.StartPoint = new Point3d(0, 0, 0);
                        ln1.EndPoint = new Point3d(-crc.Radius, 0, 0);
                      //  ln1.TransformBy(Matrix3d.Rotation(Math.PI / 2, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        btr.AppendEntity(ln1);
                        tr.AddNewlyCreatedDBObject(ln1, true);
                        objs.Add(ln1);
               
            
                        Line ln2 = new Line();
                        ln2.StartPoint = new Point3d(0, 0, 0);
                        ln2.EndPoint = new Point3d(0, crc.Radius, 0);
                      //  ln2.TransformBy(Matrix3d.Rotation(Math.PI, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        btr.AppendEntity(ln2);
                        tr.AddNewlyCreatedDBObject(ln2, true);
                        objs.Add(ln2);
         
                    {

                        Arc arc = new Arc(new Point3d(0, 0, 0), Vector3d.ZAxis, crc.Radius, Math.PI, Math.PI/2);
                       //       OR:     //
                       // Arc arc = new Arc(new Point3d(0, 0, 0), crc.Radius, Math.PI / 2, Math.PI);
                        arc.Normal = ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis;
                        btr.AppendEntity(arc);
                        tr.AddNewlyCreatedDBObject(arc, true);
                        objs.Add(arc);
                    }
                    Region reg = new Region();
                    DBObjectCollection regs = Region.CreateFromCurves(objs);
                    reg = (Region)regs[0];
                    lnIds.Add(btr.AppendEntity(reg));
                    tr.AddNewlyCreatedDBObject(reg, true);
                    Hatch oHatch = new Hatch();
                    btr.AppendEntity(oHatch);
                    tr.AddNewlyCreatedDBObject(oHatch, true);
                    oHatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
                    oHatch.Associative = true;
                    oHatch.AppendLoop(HatchLoopTypes.Default, lnIds);
                    oHatch.EvaluateHatch(true);
                    ln1.EndPoint = new Point3d(-15, 0, 0);
                    ln2.EndPoint = new Point3d(0, 15, 0);
                    tr.Commit();
                }

        } 

19

(7 ответов, оставленных в VBA)

Посмотри еще здесь
http://adn-cis.org/forum/
тут на русском
Насчет старых программ, боюсь что тебе
нужно будет переходить на managed API вместо COM
Можешь скинуть простую программу попробую переписать

20

(5 ответов, оставленных в LISP)

Не за что,
удачи  :D

21

(5 ответов, оставленных в LISP)

То что стоит в угловых скобках я думаю это по дизайну, т.е.
нельзя изменить, можно попробовать написать команду так:

(command "_.-style" "My Style Name" (getenv "EmergencyFont") pause)

установить значение перед этим так:

(setenv "EmergencyFont" "simplex.shx" ;|или arial.ttf и т.д.|;)

22

(5 ответов, оставленных в LISP)

Проверь переменную  FONTALT, у меня по умолчанию "simplex.shx",
но можешь заменить на любой из установленных в папке AutoCAD\Fonts

23

(2 ответов, оставленных в LISP)

Леонид пишет:

Господа! Существует ли возможность получить Swept Solid Object методами AutoLisp/ActiveX/ObjectARX... etc. Если да, то как?
Заранее благодарен.

Нашел похожее, может приспособишь под свою задачу:

(defun C:ww(/ eh ents nxt path sset wall win)
;;FH 2010
(command "_.rectang" "_non" "0,0" "_non" "1809,275")
(command "_.region" "_L" "")
(setq wall (entlast))
(setq sset (ssadd))
(command "_.rectang" "_non" "160,82" "_non" "249,245")
(setq eh (entlast))
(command "_.region" eh "")
(setq eh (entlast))
(setq ents nil)
(command "_.array" "_L" "" "_R" 1 8 200)
 ;; collect objects after arraying 
(while (setq nxt (entnext eh)) 
  (setq ents (cons nxt ents))
  (setq eh nxt)
)
  
(setq eh (entlast))
  ;; create separate regions from collected objects
(command "_.region" ents "")
 ;; select created regions  by window selection
(setq sset (ssget "W" (list 0 5 0) (list 1804 270 0 ) (list (cons 0 "REGION"))))
;; union  created regions 
  (command "_.union" sset "")
  (setq win (entlast))
  (setq ents nil)

;; subtract created regions from the main region (eg wall)
(command "_.subtract" wall "" win "")
(setq wall (entlast))
;; create path to extrude
(command "_.line" "_non" "0,0,0" "_non" "0,0,25.4" "")
(setq path (entlast))
;; create swept solid through this path
(command "_.sweep" wall "" path)
;; erase path
(command "_.erase" path "" )
;; zoom to selected region with small extension  
(command "_.zoom" "_W" "-10,-10"  "1830,285" )
;; change solid color, may to change some other props too 
(command "_.change" "_L" "" "_P"  "_Co" "_T" "111,112,113" "")
(princ)
)

24

(2 ответов, оставленных в .NET)

Попробуй из немодальной формы:

        // in myPlugin.cs Initialize():
  Form frm = new Form1();
            Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(frm);


// in Form1.cs
        /// <summary>
        /// zoom to extents by Luis Esquivel
        /// </summary>
        /// <param name="db">drawing database</param>
        static public void ZoomExtents(Database db)
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Point3d max = db.Extmax;
            Point3d min = db.Extmin;
            Point2d max_2d = new Point2d(max.X, max.Y);
            Point2d min_2d = new Point2d(min.X, min.Y);
            ViewTableRecord view = new ViewTableRecord();
            view.CenterPoint = (min_2d + (max_2d - min_2d) / 2.0);
            view.Height = (max_2d.Y - min_2d.Y);
            view.Width = (max_2d.X - min_2d.X);
            doc.Editor.SetCurrentView(view);
            db.UpdateExt(true);
        }

      private void button1_Click(object sender, EventArgs e)
        {
            TestBatchOpenDocs();
        }

        [CommandMethod("bat1", CommandFlags.Session)]
        public void TestBatchOpenDocs()
        {
            string FolderPath = @"C:\Test\Blah\Blah";
            System.IO.DirectoryInfo rootDir = new System.IO.DirectoryInfo(FolderPath);
            System.IO.FileInfo[] files = null;
            files = rootDir.GetFiles("*.dwg");

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;         
            Editor ed = doc.Editor;
            
            using (DocumentLock doclock = doc.LockDocument())
            {
                if (Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("dwgtitled"))==0)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(
                        "Could not perform the batch operation\nfrom unnamed drawing\nOpen another drawing and try again");
                    return;
                }
                foreach (System.IO.FileInfo file in files)
                {
                    
                    string FileToOpen = file.FullName;

                    using (Database dwgDB = new Database(false, true))
                    {
                          // для А2014 синтаксис может быть другой:
                        dwgDB.ReadDwgFile(FileToOpen, System.IO.FileShare.ReadWrite, false, null);

                        System.Threading.Thread.Sleep(200);

                        HostApplicationServices.WorkingDatabase = dwgDB;

                            using (Transaction dwgTr = dwgDB.TransactionManager.StartTransaction())
                            {
                                //Здесь будут какие-нибудь манипуляции с базой 

                                BlockTable dwgBt = (BlockTable)dwgTr.GetObject(dwgDB.BlockTableId, OpenMode.ForRead);
                                BlockTableRecord DwgBtr = (BlockTableRecord)dwgTr.GetObject(dwgBt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                                Circle circ = new Circle(new Point3d(0, 0, 0), new Vector3d(0, 0, 1), 10.0);
                                circ.ColorIndex = 5;
                                circ.LineWeight = LineWeight.LineWeight053;
                                circ.Layer = "0";
                                DwgBtr.AppendEntity(circ);
                                dwgTr.AddNewlyCreatedDBObject(circ, true);
                                dwgTr.Commit();
                            }
                          
                           // пример Purge, ищи пример сам

                            //пример зума:
                            ZoomExtents(dwgDB);

                           // dwgDB.SaveAs(FileToOpen, false, DwgVersion.AC1800, dwgDB.SecurityParameters);
                            dwgDB.SaveAs(FileToOpen, false, DwgVersion.Current, dwgDB.SecurityParameters);
                        }

                    }
                }
            HostApplicationServices.WorkingDatabase = doc.Database;

            MessageBox.Show("Done");
            }

25

(3 ответов, оставленных в VBA)

"SIGN" - зарезервированное слово, или бери его в [скобки]
или замени на другое