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


C# Autodesk.GetObjectIds方法代码示例

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


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

示例1: CalcRazm

        private RazmCollection CalcRazm(Autodesk.AutoCAD.EditorInput.SelectionSet sset)
        {
            using (var trans = AcadApp.StartTransaction())
            {
                try
                {
                    //result ********************************************
                    RazmCollection result = new RazmCollection();
                    //***************************************************
                    foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId id in sset.GetObjectIds())
                    {
                        //подсчет длин и площадей для Polyline Line Arc Circle и штук для BlockReference
                        Autodesk.AutoCAD.DatabaseServices.DBObject selOb;

                        selOb = trans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);

                        if (selOb.GetType().Name == "Polyline" || selOb.GetType().Name == "Line" || selOb.GetType().Name == "Arc" ||
                            selOb.GetType().Name == "Circle" || selOb.GetType().Name == "BlockReference")
                        {
                            foreach (var lineType in listOfTypes)
                            {
                                if ((lineType.EntityType == RazmType.typeOfEntity.Block) && (selOb.GetType().Name == "BlockReference"))
                                {
                                    Autodesk.AutoCAD.DatabaseServices.BlockReference blr = selOb as Autodesk.AutoCAD.DatabaseServices.BlockReference;
                                    if (blr.Name == lineType.Type)
                                    {
                                        string area = "";
                                        foreach (var paint in lineType.Paints)
                                        {
                                            area += paint.ShortTitle + ":" + paint.Amount + " ";
                                        }
                                        //For block references calculated only total amount and area inside RazmCollection into RazmData.NPP
                                        result.Add(new RazmData("1", lineType.Description, lineType.Type, "0.0", area, lineType.EntityType));
                                        break; // lineType
                                    }
                                }//BlockReference
                                else if ((lineType.EntityType == RazmType.typeOfEntity.Area) && (selOb.GetType().Name != "BlockReference"))
                                {
                                    Autodesk.AutoCAD.DatabaseServices.Curve cur = selOb as Autodesk.AutoCAD.DatabaseServices.Curve;
                                    if (cur.Linetype == lineType.LineTypeName)
                                    {
                                        string area = "";
                                        foreach (var paint in lineType.Paints)
                                        {
                                            area += paint.ShortTitle + ":" + (paint.Amount * GetArea(selOb)).ToString() + " ";
                                        }
                                        //For the area type calculated only area
                                        result.Add(new RazmData("1", lineType.Description, lineType.Type, "0.0", area, lineType.EntityType));
                                    }
                                }//Area
                                else if (((lineType.EntityType == RazmType.typeOfEntity.Line) ||
                                          (lineType.EntityType == RazmType.typeOfEntity.DoubleLineCenter) ||
                                          (lineType.EntityType == RazmType.typeOfEntity.DoubleLineSide)) && (selOb.GetType().Name != "BlockReference"))
                                {
                                    Autodesk.AutoCAD.DatabaseServices.Curve cur = selOb as Autodesk.AutoCAD.DatabaseServices.Curve;
                                    if (cur.Linetype == lineType.LineTypeName)
                                    {
                                        string area = "";
                                        foreach (var paint in lineType.Paints)
                                        {
                                            //This area without width. Width applayed in DisplayResult
                                            area += paint.ShortTitle + ":" + (paint.Amount * GetPaintedLength(GetLength(selOb), lineType)).ToString() + " ";
                                        }
                                        //For the line type calculated length and area
                                        result.Add(new RazmData("1", lineType.Description, lineType.Type, GetLength(selOb).ToString(), area, lineType.EntityType));
                                    }
                                }//Line
                            }// Foreach in listOfTypes
                        }//If allowed entity
                    }// Foreach in ssget
                    return result;
                }
                catch (System.Exception ex)
                {
                    AcadApp.AcaEd.WriteMessage("ERROR: MarkingCalc().CalcRazm " + ex + "\n");
                }
            }// using transaction
            return null;
        }
开发者ID:Lufan,项目名称:Genplan2012,代码行数:79,代码来源:MarkingCalc.cs

示例2: CalcRes

        private double[] CalcRes(Autodesk.AutoCAD.EditorInput.SelectionSet sset, Boolean isOnlyModelSpace, Boolean isOnlyPlineAllowed)
        {
            try
            {
                using (var trans = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
                {
                    double length = 0;
                    double area = 0;
                    int count = 0;
                    foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId id in sset.GetObjectIds())
                    {

                        Autodesk.AutoCAD.DatabaseServices.BlockTableRecord BTR = (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord)trans.GetObject(
                                                  trans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead).OwnerId,
                                                  Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);
                        string BTR_name = (BTR.Name).ToUpper();
                        if (isOnlyModelSpace && BTR_name != "*MODEL_SPACE")
                        {
                            continue;
                        }

                        if (isOnlyPlineAllowed)
                        {
                            Autodesk.AutoCAD.DatabaseServices.Polyline pline;
                            pline = (Autodesk.AutoCAD.DatabaseServices.Polyline)trans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);
                            length += pline.Length;
                            area += pline.Area;
                            count++;
                        }
                        else
                        {
                            Autodesk.AutoCAD.DatabaseServices.DBObject selOb;
                            selOb = trans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);
                            if (selOb.GetType().Name == "Polyline")
                            {
                                length += ((Autodesk.AutoCAD.DatabaseServices.Polyline)selOb).Length;
                                area += ((Autodesk.AutoCAD.DatabaseServices.Polyline)selOb).Area;
                                count++;
                            }
                            else if (selOb.GetType().Name == "Line")
                            {
                                length += ((Autodesk.AutoCAD.DatabaseServices.Line)selOb).Length;
                                count++;
                            }
                            else if (selOb.GetType().Name == "Arc")
                            {
                                length += ((Autodesk.AutoCAD.DatabaseServices.Arc)selOb).Length;
                                area += ((Autodesk.AutoCAD.DatabaseServices.Arc)selOb).Area;
                                count++;
                            }
                            else if (selOb.GetType().Name == "Circle")
                            {
                                length += ((Autodesk.AutoCAD.DatabaseServices.Circle)selOb).Circumference;
                                area += ((Autodesk.AutoCAD.DatabaseServices.Circle)selOb).Area;
                                count++;
                            }
                        }
                    }
                    double[] result = { length, area, count };
                    return result;
                }// using transaction
            }
            catch (System.Exception ex)
            {
                LufsGenplan.AcadApp.AcaEd.WriteMessage("\nERROR: AcadApp.CalcRes() " + ex + "\n");
            }
            double[] result_error = { -1, -1, -1 };
            return result_error;
        }
开发者ID:Lufan,项目名称:Genplan2012,代码行数:69,代码来源:AreaLinearCalc.cs


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