- 积分
- 481
- 明经币
- 个
- 注册时间
- 2011-5-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Line Bottomline, wall1, wall2; //定义三条直线构成路面和两面墙壁
Arc top; //定义半圆顶拱
Bottomline = new Line(point1, point2);
wall1 = new Line(new Point3d(0, 0, 0), point3);
wall2 = new Line(new Point3d( width,0, 0), point4);
top = new Arc(center,radius,0,-3.1415);
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,OpenMode.ForWrite);
btr.AppendEntity(Bottomline);
btr.AppendEntity(wall1);
btr.AppendEntity(wall2);
btr.AppendEntity(top);
//以上完成大体的轮廓
//主体轮廓向外偏移,构成锚网
//墙的顶点向外偏移100
Point3d point13=new Point3d(-100,wallHeight,0);
Point3d point14 = new Point3d(width + 100, wallHeight, 0);
double radius2 = radius + 100;
Line line1 = new Line(point1,point13);
Line line2 = new Line(point2,point14);
Arc newarc = new Arc(center, radius2, 0, -3.1415);
ObjectId id4= btr.AppendEntity(line1);
ObjectId id5 = btr.AppendEntity(line2);
ObjectId id6 = btr.AppendEntity(newarc);
//画锚喷
//先取样点
double thickness = 100;//锚喷厚度
Point3dCollection points = new Point3dCollection();
points.Add(new Point3d(point1.X-thickness,0,0));
points.Add(new Point3d(point13.X-thickness-150,wallHeight,0));
points.Add(new Point3d(center.X-radius2-400,center.Y+150+thickness,0));
points.Add(new Point3d(center.X, center.Y + radius2 + thickness+200, 0));
points.Add(new Point3d(center.X+radius2+250,center.Y+thickness+50,0));
points.Add(new Point3d(point14.X+thickness+150,wallHeight,0));
points.Add(new Point3d(point2.X + thickness, 0, 0));
ObjectId id3=huamaopen.draw(points);
//将底部直线与样条曲线闭合
Line l1 = new Line(new Point3d(point1.X, 0, 0), new Point3d(point1.X - thickness, 0, 0));
Line l2 = new Line(new Point3d(point2.X, 0, 0), new Point3d(point2.X + thickness, 0, 0));
ObjectId id1= btr.AppendEntity(l1);
ObjectId id2 = btr.AppendEntity(l2);
//增加填充
Hatch hatch = new Hatch();
hatch.Normal = new Vector3d(0, 0, 1);
hatch.Elevation = 0.0;
hatch.SetHatchPattern(HatchPatternType.PreDefined,"AR-CONC");
ObjectIdCollection objectids = new ObjectIdCollection();
objectids.Add(id1);
objectids.Add(id2);
objectids.Add(id3);
objectids.Add(id4);
objectids.Add(id5);
objectids.Add(id6);
//在下面这句出现eInvalidInput错误,高手能不能帮我看看?
hatch.AppendLoop(Autodesk.AutoCAD.DatabaseServices.HatchLoopTypes.External,objectids);
hatch.EvaluateHatch(true);
btr.AppendEntity(hatch);
trans.Commit();
trans.Dispose();
}
|
|