/// <summary> /// 由截面面域、旋转轴起点、旋转轴终点和旋转角度创建旋转体 /// </summary> /// <param name="region">截面面域</param> /// <param name="axisPt1">旋转轴起点</param> /// <param name="axisPt2">旋转轴终点</param> /// <param name="angle">旋转角度</param> /// <returns>返回创建的旋转体的Id</returns> public static ObjectId AddRevolvedSolid(Region region, Point3d axisPt1, Point3d axisPt2, double angle) { Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Solid3d ent = new Solid3d(); ent.Revolve(region, axisPt1, axisPt2 - axisPt1, angle); ObjectId entId = ObjectId.Null; using (Transaction tr = db.TransactionManager.StartTransaction()) { entId = db.AddToModelSpace(ent); tr.Commit(); } return(entId); } catch { ed.WriteMessage("\n参数不当,创建旋转体失败!"); return(ObjectId.Null); } }
// 由截面面域、旋转轴起点、旋转轴终点和旋转角度创建旋转体的函数. public static ObjectId AddRevolvedSolid(Region region, Point3d axisPt1, Point3d axisPt2, double angle) { try { Solid3d ent = new Solid3d(); ent.Revolve(region, axisPt1, axisPt2 - axisPt1, angle); ObjectId entId = AppendEntity(ent); return(entId); } catch { ObjectId nullId = ObjectId.Null; return(nullId); } }