写描述折线
在每条多段线中写入多段线名称的以下代码。结果是相同的pic。没问题我需要使用代码
为所有包裹编写描述,如下所示
PH 101
北--
南PH 105
东PH 103
西--
另一个示例
PH106
北部PH 103
南PH 109
东部PH 106
西部PH 105
检查每个包裹是否在北部有包裹。ok write它,没有包裹,没有文字
和相同的签到(东南-西)
公共静态void polylinenumber()
{
双txth=1
int snumber=101
Document doc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
数据库db=doc.Database
编辑器ed=doc.Editor
使用(Transaction trans=db.TransactionManager.StartTransaction())
{
试试
{
BlockTable bt=trans.GetObject(db.BlockTableId,OpenMode.ForRead)作为BlockTable
BlockTableRecord btr=trans.GetObject(bt,OpenMode.ForWrite)作为blockTable记录
TypedValue[]tv=新的TypedValue
tv.SetValue(新类型dValue((int)DxfCode)。开始,“LW多段线”),0)
SelectionFilter=新的selectionfiller(电视)
PromptSelectionResult:ssPrompt
ssPrompt=ed.GetSelection(过滤器)
如果(ssPrompt.Status==PromptStatus.OK)
{
SelectionSet ss=ssPrompt.Value
List
lspl=新列表
()
foreach(在ss中选择对象sObj)
{
多段线poly=trans.GetObject(sObj.ObjectId,OpenMode.ForWrite)作为多段线
lspl.Add(poly)
}
var sortedpolyList=lspl。OrderByDescending(p=>p.StartPoint.Y)。然后通过(p=>p.StartPoint.X)
//var sortedpolyList=lspl。OrderByDescending(p=>p.StartPoint.Y)。然后通过(p=>p.StartPoint.X)
<div>foreach(sortedpolyList中的多段线项)<div div>
{
DBText-txtpl=new-DBText()
txtpl.SetDatabaseDefaults()
txtpl。TextString=“PH”+snumber.ToString()
//Point3d p2=多段线扩展。质心(项)
txtpl。位置=多段线延伸。质心(项目)
txtpl。旋转=0
txtpl。高度=txth
btr.AppendEntity(txtpl)
trans。AddNewlyCreatedDBObject(txtpl,true)
snumber++;
}
trans.Commit()
}
}
捕获(System.Exception.ex)
{
ed.WriteMessage(“错误请检查”+ex.Message)
trans.Abort()
}
}
}
**** Hidden Message *****
页:
[1]