- 积分
- 1296
- 明经币
- 个
- 注册时间
- 2006-7-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
该图是我做的一个自定义块(由一椭圆、一条直线、一段圆弧封闭组成),块定义代码如下:- 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<ObjectIdCollection> IDS = new List<ObjectIdCollection>();
- IDS.Add(ids1);
- //填充图块
- //CDraw.HatchObject(db, trans, record, IDS, "SOLID", eColor.White);
- //============================
- trans.Commit();
- }
- }
- return blockId;
- }
请问,如果实现阴影部分的填充?我把该块的组成图元:圆弧、直线、椭圆添加到objectidcollection中,填充时则报错:eillegalityinput。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|