当前位置: 首页>>代码示例>>C#>>正文


C# Polyline.SetDatabaseDefaults方法代码示例

本文整理汇总了C#中Polyline.SetDatabaseDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Polyline.SetDatabaseDefaults方法的具体用法?C# Polyline.SetDatabaseDefaults怎么用?C# Polyline.SetDatabaseDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polyline的用法示例。


在下文中一共展示了Polyline.SetDatabaseDefaults方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePolyline

        /// <summary>
        /// Creates a Polyline with default settings (layer, color, etc.) with the specified vertices. 
        /// Only the X and Y coordinates are taken into account, width is zero, and no bulges are added.
        /// </summary>
        /// <param name="vertices">Vertices that will compose the polyline.</param>
        public static Polyline CreatePolyline(Point3dCollection vertices)
        {
            Polyline polyline = new Polyline();
            polyline.SetDatabaseDefaults();

            for (int i = 0; i < vertices.Count; i++)
            {
                polyline.AddVertexAt(i, new Point2d(vertices[i].X, vertices[i].Y), 0, 0, 0);
            }

            return polyline;
        }
开发者ID:ahmedfelix,项目名称:DrawingSpace,代码行数:17,代码来源:DrawingTools.cs

示例2: Create

        public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t)
        {
            var cellWidth = ColorBookHelper.CellWidth;
            var cellHeight = ColorBookHelper.CellHeight;
            var margin = ColorBookHelper.Margin;
            var marginHalf = margin * 0.5;

            Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0);

            Polyline pl = new Polyline(4);
            pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0);
            pl.Closed = true;
            pl.SetDatabaseDefaults();
            pl.Color = Color;

            cs.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            Hatch h = new Hatch();
            h.SetDatabaseDefaults();
            h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
            h.Annotative = AnnotativeStates.False;

            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);

            h.Associative = true;
            h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
            h.Color = Color;
            h.EvaluateHatch(true);

            DBText text = new DBText();
            text.SetDatabaseDefaults();
            text.HorizontalMode = TextHorizontalMode.TextCenter;
            text.Annotative = AnnotativeStates.False;
            text.Height = ColorBookHelper.TextHeight;
            text.AlignmentPoint = ptText;
            text.AdjustAlignment(cs.Database);
            text.TextStyleId = ColorBookHelper.IdTextStylePik;
            text.TextString = Name;

            cs.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);
        }
开发者ID:vildar82,项目名称:AcadLib,代码行数:47,代码来源:ColorItem.cs

示例3: Extents3d

        private void сreateHatch(Extents3d extText, BlockTableRecord btr)
        {
            if (extText.Diagonal() < 100)
            {
                return;
            }
            // Отступ контура штриховки от границ текста
            Extents3d ext = new Extents3d(new Point3d(extText.MinPoint.X - 10, extText.MinPoint.Y - 10, 0),
                                          new Point3d(extText.MaxPoint.X + 10, extText.MaxPoint.Y + 10, 0));
            var h = new Hatch();
            h.SetDatabaseDefaults(btr.Database);
            if (!panelBtr.CaptionLayerId.IsNull)
                h.LayerId = panelBtr.CaptionLayerId;
            h.LineWeight = LineWeight.LineWeight015;
            h.Linetype = SymbolUtilityServices.LinetypeContinuousName;
            h.Color = Color.FromRgb(250, 250, 250);
            h.Transparency = new Transparency(80);
            h.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
            h.PatternScale = 25.0;
            btr.AppendEntity(h);
            var t = btr.Database.TransactionManager.TopTransaction;
            t.AddNewlyCreatedDBObject(h, true);
            h.Associative = true;
            h.HatchStyle = HatchStyle.Normal;

            // Полилиния по контуру текста
            Polyline pl = new Polyline();
            pl.SetDatabaseDefaults(btr.Database);
            pl.LineWeight = LineWeight.LineWeight015;
            pl.Linetype = SymbolUtilityServices.LinetypeContinuousName;
            pl.ColorIndex = 256; // ПоСлою
            if (!panelBtr.CaptionLayerId.IsNull)
                pl.LayerId = panelBtr.CaptionLayerId;
            pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0);
            pl.AddVertexAt(0, ext.MaxPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MinPoint.X, ext.MaxPoint.Y), 0, 0, 0);
            pl.Closed = true;

            ObjectId idPl = btr.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            // добавление контура полилинии в гштриховку
            var ids = new ObjectIdCollection();
            ids.Add(idPl);
            h.AppendLoop(HatchLoopTypes.Default, ids);
            h.EvaluateHatch(true);

            // Замена текстов - чтобы они стали поверх штриховки.
            panelBtr.IdCaptionMarkSb = replaceText(panelBtr.IdCaptionMarkSb, btr);
            panelBtr.IdCaptionPaint = replaceText(panelBtr.IdCaptionPaint, btr);
        }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:52,代码来源:ConvertCaption.cs

示例4: Create

        public static DBObject Create(this Grevit.Types.Room r, Transaction tr)
        {
            DictionarySpaceStyle ss = new DictionarySpaceStyle(Command.Database);



            try
            {
                BlockTable bt = (BlockTable)tr.GetObject(Command.Database.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                Polyline acPoly = new Polyline();
                acPoly.SetDatabaseDefaults();

                int i = 0;
                foreach (Grevit.Types.Point p in r.points)
                {
                    acPoly.AddVertexAt(i, new Point2d(p.x, p.y), 0, 0, 0);
                    i++;
                }
                acPoly.Closed = true;
                ms.AppendEntity(acPoly);
                tr.AddNewlyCreatedDBObject(acPoly, true);


                Autodesk.Aec.Geometry.Profile myProfile = Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, Command.Editor.CurrentUserCoordinateSystem);

                Space space;


                bool newEnt = false;

                if (Command.existing_objects.ContainsKey(r.GID))
                {
                    space = (Space)tr.GetObject(Command.existing_objects[r.GID], OpenMode.ForWrite);
                }
                else
                {
                    newEnt = true;
                    space = new Space();
                    space.SetDatabaseDefaults(Command.Database);
                    space.SetToStandard(Command.Database);
                }

                space.Associative = r.associative;
                space.Name = r.name;

                space.GeometryType = SpaceGeometryType.TwoD;
                space.Location = new Point3d(0, 0, 0);
                space.SetBaseProfile(myProfile, Matrix3d.Identity);

                LayerTable lt = (LayerTable)tr.GetObject(Command.Database.LayerTableId, OpenMode.ForRead);
                if (r.TypeOrLayer != "") { if (lt.Has(r.TypeOrLayer)) space.LayerId = lt[r.TypeOrLayer]; }
                if (ss.Has(r.FamilyOrStyle, tr)) space.StyleId = ss.GetAt(r.FamilyOrStyle);

                if (newEnt)
                {
                    ms.AppendEntity(space);
                    tr.AddNewlyCreatedDBObject(space, true);
                    ms.Dispose();
                }
                return space;

            }

            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
            }

            return null;
        }
开发者ID:samuto,项目名称:Grevit,代码行数:71,代码来源:CreateExtension.cs

示例5: testpara

        public void testpara(ListView mylist)
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            DocumentLock loc = acDoc.LockDocument();
            Polyline test = new Polyline();

            using (loc)
            {
                Database acCurDb = acDoc.Database;
                PromptPointOptions pPtOpts = new PromptPointOptions(" 점을 입력하세요");
                PromptPointResult pPtRes = acDoc.Editor.GetPoint(pPtOpts);// PromptPointResult pPtRes = acDoc.Editor.GetPoint(pPtOpts); // 점을 사용자에게 가져온다
                Point2dCollection ptStart = new Point2dCollection(); // Point3d 의 배열형이라 생각하면 쉽다.

                pPtOpts.BasePoint = pPtRes.Value; // 기준점 (점선)
                pPtOpts.UseBasePoint = true;

                //pPtOpts.UseDashedLine = true;
                int count = 0; // 점갯수 count

                ptStart.Add(new Point2d(pPtRes.Value.X, pPtRes.Value.Y));

                while (pPtRes.Status == PromptStatus.OK) // 사용자한테 받는값이 있을때까지
                {
                    if (pPtRes.Status == PromptStatus.Cancel) { return; } // 캔슬시 리턴
                    pPtOpts.BasePoint = pPtRes.Value;
                    pPtOpts.Message = " 점을 입력하세요"; // ㅇㅇ
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);  // 사용자에게 점값을 받아온다

                    ptStart.Add(new Point2d(pPtRes.Value.X, pPtRes.Value.Y)); // 그값을 콜렉션에다가 배열로 저장
                    count++;

                }

                test.SetDatabaseDefaults(); // 폴리라인 초기화(버튼 두번누르면 초기화 안되므로)

                for (int i = 0; i < count; i++)
                {
                    test.AddVertexAt(i, ptStart[i], 0, 0, 0);
                }

                //          test.Closed = true; // 폴리라인을 폐합선으로 만들어줌 (도형)
                //

                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) // 트랜잭션으로 묵어줌 라인그리기 위해서
                {
                    BlockTable acBlkTbl;
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                 OpenMode.ForRead) as BlockTable;

                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                    OpenMode.ForWrite) as BlockTableRecord;

                    acBlkTblRec.AppendEntity(test); // 폴리라인을 블럭테이블 레코드에 그려준다.
                    acTrans.AddNewlyCreatedDBObject(test, true);//디비 데이터에 넣어줌
                    acTrans.Commit(); // 트랜잭션 실행
                }

            }
            Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen(); // 화면 한번 업뎃 해주고

            Alignment al = this.CreateAlign(test); // 만들어논 메소드를 이용해서 만들어진 평면선형 클래스의 변수값을 가져온다.

                int temp=0;

                temp = 0;
                foreach(AlignmentEntity myAe in al.Entities) //  일반 라인과 호의 순서가 맞진 않지만 정보는 다 맞음
                {                                                   ///추후에 정교한 작업 필요할듯
                    temp++;
                    string msg1 = "";
                    mylist.BeginUpdate();
                    ListViewItem testLvi2 = new ListViewItem(string.Format("{0}",temp));   // 리스트뷰 값 넣어주는 부분
                    switch(myAe.EntityType)
                    {
                        case AlignmentEntityType.Line:
                            AlignmentLine myLine = myAe as AlignmentLine;
                            msg1 = myLine.StartPoint.ToString(); // 시작점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.EndPoint.ToString(); // 끝점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.Length.ToString(); // 길이
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.StartStation.ToString(); // 시작 스테이션
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myLine.EndStation.ToString(); // 끝 스테이션
                            testLvi2.SubItems.Add(msg1);

                            mylist.Items.Add(testLvi2);
                            break;
                        case AlignmentEntityType.Arc:
                            AlignmentArc myArc = myAe as AlignmentArc;
                            msg1 = myArc.StartPoint.ToString(); // 시작점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.EndPoint.ToString(); // 끝점
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.Length.ToString(); // 길이
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.StartStation.ToString(); // 시작 스테이션
                            testLvi2.SubItems.Add(msg1);
                            msg1 = myArc.EndStation.ToString(); // 끝 스테이션
//.........这里部分代码省略.........
开发者ID:flycoflyco,项目名称:HyeSeong,代码行数:101,代码来源:Class1.cs

示例6: placementAparts

        private static void placementAparts(Database db)
        {
            using (var t = db.TransactionManager.StartTransaction())
            {
                ObjectId idTextStylePik = db.GetTextStylePIK();

                var bt = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
                var ms = bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite) as BlockTableRecord;
                int countAparts;
                var btrApartGroups = getGroupedAparts(bt, out countAparts);
                Point3d pt = Point3d.Origin;
                Point3d ptCenterPlace;

                using (var progress = new ProgressMeter())
                {
                    progress.SetLimit(countAparts);
                    progress.Start("Расстановка квартир...");

                    foreach (var btrApartGroup in btrApartGroups)
                    {
                        progress.MeterProgress();

                        foreach (var idBtrApart in btrApartGroup)
                        {
                            var curPlaceWidth = placeWidth;

                            var blRefApart = new BlockReference(pt, idBtrApart);
                            blRefApart.SetDatabaseDefaults(db);
                            var extApart = blRefApart.GeometricExtents;
                            var lenApart = extApart.MaxPoint.X - extApart.MinPoint.X;
                            if (lenApart > placeWidth)
                            {
                                curPlaceWidth = lenApart + 1000;
                            }

                            ptCenterPlace = new Point3d(pt.X + curPlaceWidth*0.5, pt.Y - placeHeight*0.5, 0);

                            var ptBlCenter = extApart.Center();
                            // Перемещение блока в центр прямоугольной области
                            Matrix3d displace = Matrix3d.Displacement(ptCenterPlace - ptBlCenter);
                            blRefApart.TransformBy(displace);
                            ms.AppendEntity(blRefApart);
                            t.AddNewlyCreatedDBObject(blRefApart, true);

                            // Подпись квартиры
                            DBText text = new DBText();
                            text.SetDatabaseDefaults();
                            text.TextStyleId = idTextStylePik;
                            text.Height = 900;
                            text.TextString = getApartName(blRefApart.Name);
                            text.Position = new Point3d (pt.X+300, pt.Y+300,0);
                            ms.AppendEntity(text);
                            t.AddNewlyCreatedDBObject(text, true);

                            // Прямоугольник расположения квартиры
                            Polyline pl = new Polyline(4);
                            pl.AddVertexAt(0, pt.Convert2d(), 0, 0, 0);
                            pl.AddVertexAt(1, new Point2d (pt.X+ curPlaceWidth, pt.Y), 0, 0, 0);
                            pl.AddVertexAt(2, new Point2d(pt.X + curPlaceWidth, pt.Y-placeHeight), 0, 0, 0);
                            pl.AddVertexAt(3, new Point2d(pt.X, pt.Y - placeHeight), 0, 0, 0);
                            pl.Closed = true;
                            pl.SetDatabaseDefaults();
                            ms.AppendEntity(pl);
                            t.AddNewlyCreatedDBObject(pl, true);

                            pt = new Point3d(pt.X + curPlaceWidth, pt.Y, 0);
                        }
                        pt = new Point3d(0, pt.Y - placeHeight - 8000, 0);
                    }
                    progress.Stop();
                }
                t.Commit();
            }
        }
开发者ID:vildar82,项目名称:AR_ApartmentsBase,代码行数:74,代码来源:ApartmentPlacement.cs

示例7: addRectangle

        private static Polyline addRectangle(BlockTableRecord btr, Transaction t, Point2d ptSegment, double length, double height)
        {
            Polyline pl = new Polyline(4);
            pl.SetDatabaseDefaults();
            pl.AddVertexAt(0, ptSegment, 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(ptSegment.X, ptSegment.Y + height), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(ptSegment.X + length, ptSegment.Y + height), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(ptSegment.X + length, ptSegment.Y), 0, 0, 0);
            pl.Closed = true;

            btr.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);
            return pl;
        }
开发者ID:vildar82,项目名称:AR_Materials,代码行数:14,代码来源:Flat.cs

示例8: addLayout

        private static void addLayout(Point3d pt,int layout ,double width, double height , BlockTableRecord cs, Transaction t)
        {
            // Полилиния контура листа
            Polyline pl = new Polyline(4);
            pl.AddVertexAt(0, new Point2d(pt.X, pt.Y), 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(pt.X +width, pt.Y), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(pt.X + width, pt.Y - height), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(pt.X,  pt.Y-height), 0, 0, 0);
            pl.Closed = true;
            pl.SetDatabaseDefaults();

            cs.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            // Подпись номера листа
            var textHeight = height * 0.008;
            Point3d ptText = new Point3d(pt.X+textHeight*0.5, pt.Y-textHeight*1.5, 0);

            DBText text = new DBText();
            text.SetDatabaseDefaults();
            text.Height = textHeight;
            text.TextStyleId = IdTextStylePik;
            text.TextString = layout.ToString();
            text.Position = ptText;

            cs.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);

            // Layout
            //createLayout(pl, layout, width, height, t);
        }
开发者ID:vildar82,项目名称:AcadLib,代码行数:31,代码来源:ColorBookHelper.cs

示例9: Create

        public static void Create(Grevit.Types.Room r)
        {
            Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
            Transaction tr = db.TransactionManager.StartTransaction();
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            DictionarySpaceStyle ss = new DictionarySpaceStyle(db);

            try
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                Polyline acPoly = new Polyline();
                acPoly.SetDatabaseDefaults();

                int i = 0;
                foreach (Grevit.Types.Point p in r.points)
                {
                    acPoly.AddVertexAt(i, new Point2d(p.x, p.y), 0, 0, 0);
                    i++;
                }
                acPoly.Closed = true;
                ms.AppendEntity(acPoly);
                tr.AddNewlyCreatedDBObject(acPoly, true);

                Autodesk.Aec.Geometry.Profile myProfile = Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, ed.CurrentUserCoordinateSystem);

                Space space;

                bool newEnt = false;

                if (Command.existing_objects.ContainsKey(r.GID))
                {
                    space = (Space)tr.GetObject(Command.existing_objects[r.GID], OpenMode.ForWrite);
                }
                else
                {
                    newEnt = true;
                    space = new Space();
                    space.SetDatabaseDefaults(db);
                    space.SetToStandard(db);
                }

                space.Associative = r.associative;
                space.Name = r.name;

                space.GeometryType = SpaceGeometryType.TwoD;
                space.Location = new Point3d(0, 0, 0);
                space.SetBaseProfile(myProfile, Matrix3d.Identity);

                LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                if (r.TypeOrLayer != "") { if (lt.Has(r.TypeOrLayer)) space.LayerId = lt[r.TypeOrLayer]; }
                if (ss.Has(r.FamilyOrStyle, tr)) space.StyleId = ss.GetAt(r.FamilyOrStyle);

                if (newEnt)
                {
                    ms.AppendEntity(space);
                    tr.AddNewlyCreatedDBObject(space, true);
                }
                AddXData(r, space);
                writeProperties(space, r.parameters, tr);
                storeID(r, space.Id);
                tr.Commit();
            }

            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                ed.WriteMessage(e.Message);
                tr.Abort();
            }

            finally
            {
                tr.Dispose();
            }
        }
开发者ID:bbrangeo,项目名称:Grevit,代码行数:76,代码来源:CreateExtension.cs


注:本文中的Polyline.SetDatabaseDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。