ydp_00769 发表于 2010-12-7 15:32:00

[求助]请教一个填充的问题?



该图是我做的一个自定义块(由一椭圆、一条直线、一段圆弧封闭组成),块定义代码如下:
public ObjectId CreateStation(Database db, string strBlockName, double dRadius, double dLength, Point3d pt1, double dZxlc, double dStartAngle, double dEndAngle)
{
ObjectId blockId = ObjectId.Null;
BlockTableRecord record = new BlockTableRecord();
record.Name = strBlockName;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Point3d pStart = new Point3d(0, 0, 0);//块基点
Point3d pEnd = new Point3d(0, dLength, 0);//结束点
Point3d ptCir = new Point3d(0, dLength - dRadius, 0);
Vector3d vec1 = new Vector3d(0, dRadius, 0);
//Vector3d vec2 = new Vector3d(-6, 0, 0);
Ellipse eLL = new Ellipse(ptCir, Vector3d.ZAxis, vec1, 0.7, 0, 0);
Line lLen = new Line(pStart, pEnd);
//车站图例上文字标注
Point3d ptText = new Point3d(pt1.X, pt1.Y - dRadius * 2,0);
DBText txt = new DBText();
txt.TextString = Public.PublicClass.ConvertDmlc(CGlobal.GC, dZxlc);
txt.WidthFactor = 1;
txt.Height = 3;
//txt.ColorIndex = iColor;
txt.VerticalMode = TextVerticalMode.TextVerticalMid;
txt.HorizontalMode = TextHorizontalMode.TextMid;
txt.AlignmentPoint = ptText;
//txt.LayerId = layerId;
txt.Rotation = 90 * CMath.dConvertAngle;
//加入半圆
Arc objArc = new Arc(ptCir, dRadius * 0.5, dStartAngle, dEndAngle);
//块记录定义
record.Origin = pStart;//设置块基点
record.AppendEntity(eLL);
record.AppendEntity(lLen);
record.AppendEntity(txt);
record.AppendEntity(objArc);
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
if (!bt.Has(strBlockName))//判断是否存在同名块
{
blockId = bt.Add(record);
trans.AddNewlyCreatedDBObject(record, true);
//========图块填充============
BlockTableRecordEnumerator enume = record.GetEnumerator();//获取块中图元对象计数器
ObjectIdCollection ids1 = new ObjectIdCollection();
int i = 0;
while (enume.MoveNext())
{
DBObject dbobj = trans.GetObject(enume.Current, OpenMode.ForRead);
ids1.Add(dbobj.ObjectId);
}
List IDS = new List();
IDS.Add(ids1);
//填充图块
//CDraw.HatchObject(db, trans, record, IDS, "SOLID", eColor.White);
//============================
trans.Commit();
}
}
return blockId;
}请问,如果实现阴影部分的填充?我把该块的组成图元:圆弧、直线、椭圆添加到objectidcollection中,填充时则报错:eillegalityinput。

ydp_00769 发表于 2010-12-7 16:10:00

着急啊,请求大家的帮助,自已顶一下

ydp_00769 发表于 2010-12-7 17:11:00

搞定了,由一个内圈的弧、一个外圈的弧、两个弧中间的两个线段组成的封闭区间,这种情况下,可以填充。

雪山飞狐_lzh 发表于 2010-12-7 17:26:00

没错,填充区域必须是首尾相连的封闭区间

chpmould 发表于 2010-12-7 19:35:00

楼主可以将你修正好的代码贴上来学习以下吗。。。
页: [1]
查看完整版本: [求助]请教一个填充的问题?