- 积分
- 656
- 明经币
- 个
- 注册时间
- 2010-8-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2015-9-12 20:52:15
|
显示全部楼层
天圆地方曲面
本帖最后由 lamntree 于 2015-9-12 20:53 编辑
直接loft的天圆地方实际做钣金是做不出来的,我把它分成4个三角面,4个曲面,组合出来,这样就和实际钣金做出来的一样了
public void hopper3d()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
PromptPointResult ppr = ed.GetPoint("\nspecify inset point");
if (ppr.Status == PromptStatus.OK)
{
Matrix3d UCS = ed.CurrentUserCoordinateSystem;
Point3d pt = ppr.Value.TransformBy(UCS);
PromptDoubleResult pdrDia = ed.GetDouble("\nspecify diameter of circle");
if (pdrDia.Status == PromptStatus.OK)
{
double D = pdrDia.Value;
PromptDoubleResult pdrL = ed.GetDouble("\nspecify Length");
if (pdrL.Status == PromptStatus.OK)
{
double L = pdrL.Value;
PromptDoubleResult pdrW = ed.GetDouble("\nspecify width");
if (pdrW.Status == PromptStatus.OK)
{
double W = pdrW.Value;
PromptDoubleResult pdrH = ed.GetDouble("\nspecify height");
if (pdrH.Status == PromptStatus.OK)
{
Application.SetSystemVariable("clayer", "0");
Vector3d vec = pt - new Point3d(0, 0, 0);
double H = pdrH.Value;
LoftOptions lo = new LoftOptions();
Line l1 = new Line(new Point3d(0, -D / 2, 0), new Point3d(-L / 2, -W / 2, -H));
l1.TransformBy(Matrix3d.Displacement(vec));
Line l2 = new Line(new Point3d(0, -D / 2, 0), new Point3d(L / 2, -W / 2, -H));
l2.TransformBy(Matrix3d.Displacement(vec));
Entity[] l1l2=new Entity[]{l1,l2};
LoftedSurface lf1 = new LoftedSurface();
lf1.CreateLoftedSurface(l1l2, null, null, lo);
btr.AppendEntity(lf1);
trans.AddNewlyCreatedDBObject(lf1, true);
Arc a1 = new Arc(new Point3d(0, 0, 0), D / 2, -Math .PI /2, 0);
a1.TransformBy(Matrix3d.Displacement(vec));
Entity[] l2a1 = new Entity[] { l2, a1 };
LoftedSurface lf2 = new LoftedSurface();
lf2.CreateLoftedSurface(l2a1, null, null, lo);
btr.AppendEntity(lf2);
trans.AddNewlyCreatedDBObject(lf2, true);
Line l3 = new Line(new Point3d(D / 2, 0, 0), new Point3d(L / 2, -W / 2, -H));
l3.TransformBy(Matrix3d.Displacement(vec));
Line l4 = new Line(new Point3d(D / 2, 0, 0), new Point3d(L / 2, W / 2, -H));
l4.TransformBy(Matrix3d.Displacement(vec));
Entity[] l3l4 = new Entity[] { l3, l4 };
LoftedSurface lf3 = new LoftedSurface();
lf3.CreateLoftedSurface(l3l4, null, null, lo);
btr.AppendEntity(lf3);
trans.AddNewlyCreatedDBObject(lf3, true);
Arc a2 = new Arc(new Point3d(0, 0, 0), D / 2, 0,Math.PI / 2);
a2.TransformBy(Matrix3d.Displacement(vec));
Entity[] l4a2 = new Entity[] { l4, a2 };
LoftedSurface lf4 = new LoftedSurface();
lf4.CreateLoftedSurface(l4a2, null, null, lo);
btr.AppendEntity(lf4);
trans.AddNewlyCreatedDBObject(lf4, true);
Line l5 = new Line(new Point3d(0, D / 2, 0), new Point3d(L / 2, W / 2, -H));
l5.TransformBy(Matrix3d.Displacement(vec));
Line l6 = new Line(new Point3d(0, D / 2, 0), new Point3d(-L / 2, W / 2, -H));
l6.TransformBy(Matrix3d.Displacement(vec));
Entity[] l5l6 = new Entity[] { l5, l6 };
LoftedSurface lf5 = new LoftedSurface();
lf5.CreateLoftedSurface(l5l6, null, null, lo);
btr.AppendEntity(lf5);
trans.AddNewlyCreatedDBObject(lf5, true);
Arc a3 = new Arc(new Point3d(0, 0, 0), D / 2, Math.PI / 2,Math.PI );
a3.TransformBy(Matrix3d.Displacement(vec));
Entity[] l6a3 = new Entity[] { l6, a3 };
LoftedSurface lf6 = new LoftedSurface();
lf6.CreateLoftedSurface(l6a3, null, null, lo);
btr.AppendEntity(lf6);
trans.AddNewlyCreatedDBObject(lf6, true);
Line l7 = new Line(new Point3d(-D / 2,0, 0), new Point3d(-L / 2, W / 2, -H));
l7.TransformBy(Matrix3d.Displacement(vec));
Line l8 = new Line(new Point3d(-D / 2, 0, 0), new Point3d(-L / 2, -W / 2, -H));
l8.TransformBy(Matrix3d.Displacement(vec));
Entity[] l7l8 = new Entity[] { l7, l8 };
LoftedSurface lf7 = new LoftedSurface();
lf7.CreateLoftedSurface(l7l8, null, null, lo);
btr.AppendEntity(lf7);
trans.AddNewlyCreatedDBObject(lf7, true);
Arc a4 = new Arc(new Point3d(0, 0, 0), D / 2, Math.PI, Math.PI*3/2);
a4.TransformBy(Matrix3d.Displacement(vec));
Entity[] l8a4 = new Entity[] { l8, a4 };
LoftedSurface lf8 = new LoftedSurface();
lf8.CreateLoftedSurface(l8a4, null, null, lo);
btr.AppendEntity(lf8);
trans.AddNewlyCreatedDBObject(lf8, true);
}
}
}
}
}
trans.Commit();
}
}
|
|