本文整理汇总了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;
}
示例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;
}