C#中如何绘制一个四分之一的圆锥

C#中如何绘制一个四分之一的圆锥

思路:在C#中有自带的绘制圆锥的方法,
ConeElement coneElementLeft = new ConeElement(DgnModel dgnModel, Element templateElement, double topRadius, double bottomRadius, DPoint3d topCenter, DPoint3d bottomCenter, DMatrix3d rotation, bool isCapped);(这个创建方法对应的是MicroStation CE版本)
可这是绘制一个标准的圆锥,不能直接绘制出一个四分之一的圆锥,我们要通过剪切的思想,将原形体剪切好再放置相应的位置即可。

1.首先剪切好四分之一圆锥

   //绘制圆锥
   BIM.SmartSolidElement Cone_L = app.SmartSolid.CreateCone(null, 0, boxStraightWingWallData.C2 * mm/ Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster);
   //绘制剪切圆锥的矩形体
   BIM.SmartSolidElement Slab_L = app.SmartSolid.CreateSlab(null, 2*boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, 2*boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster);
   //将矩形体移到圆锥的一半位置
   BIM.Point3d p1 = app.Point3dFromXYZ(boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, 0, 0);
   Slab_L.Move(p1);
   //剪切一半的圆锥
   BIM.SmartSolidElement Subtract_L = app.SmartSolid.SolidSubtract(Cone_L, Slab_L);
   //将矩形体移到一半圆锥的一半位置
   p1 = app.Point3dFromXYZ(-boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, boxStraightWingWallData.C2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster, 0);
   Slab_L.Move(p1);
   //剪切一半的圆锥一半,Subtract_L即是四分之一圆锥
   Subtract_L = app.SmartSolid.SolidSubtract(Subtract_L, Slab_L);

注:这里绘制出的剪切体是以原点为坐标,在移动矩形体剪切的时候默认为其几何中心点作为移动点的初始点,绘制方法对应的是MicroStation V8i版本。

2.其次通过旋转变换放置相应位置

  //绕Z轴旋转法向量与Y轴的正方向的夹角
  BIM.Matrix3d ma_L = app.Matrix3dFromVectorAndRotationAngle(app.Point3dFromXYZ(0, 0, 1), angle.Radians);
  BIM.Transform3d ta_L = app.Transform3dFromMatrix3d(ma_L);
  Subtract_L.Transform(ta_L);
  //剪切体放置的位置点
  BIM.Point3d P1 = ceDpoint_v8Point(leftCircleCenterPt);
  Subtract_L.Move(P1);
  P1 = app.Point3dFromXYZ(0, 0, boxStraightWingWallData.C2 / 2 * mm / Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster);
  Subtract_L.Move(P1);
  app.ActiveModelReference.AddElement(Subtract_L);
  long id_L = Subtract_L.ID;
  ElementId elemid_L = new ElementId(ref id_L);
  Element temp_L = Session.Instance.GetActiveDgnModel().FindElementById(elemid_L);

注:ceDpoint_v8Point()这个方法是将CE的DPoint3d点转换为V8i的DPoint3d点,将绘制方法与放置位置点统一。

3.最后处理好的形体绘制在图纸上

  temp_L.AddToModel();
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值