Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
Bentley 中国优先社区
  • Welcome to Bentley Communities
  • Bentley's Communities
  • Bentley 中国优先社区
  • Cancel
Bentley 中国优先社区
技术资料库 10-如何创建几何元素
    • Sign In
    Bentley 中国优先社区 requires membership for participation - click to join
    • -Bentley 中文技术资料库
      • +AutoPIPE
      • +Bentley Civil
      • +Bentley Navigator
      • +Bentley Substation
      • +BRCM
      • +BridgeMasterModeler/OpenBridgeModeler
      • -i-model / DgnDb
        • DgnDb i-model Importer
        • DgnDb介绍
        • i-model 1.0/1.5 SDK
        • i-model常见问题解答
        • 为何一个DGN文件发布成iModel2.0后体积增大了快100倍?
        • 为何我用Mstn V8iSS4发布的.imodel无法用Navigator CE Update2打开
        • 发布带有图片的i-model
        • 哪里能找到Revit转i-model的插件?
        • 如何利用iTwin平台发布.imodel格式的文件?
        • 如何简单判断i-model的版本
        • 如何运行github上的simple-viewer-app例子代码
        • 将带有文件链接的dgn发布成imodel
        • 我只有MicroStation V8iSS3,如何将DGN发布成移动端用的imodel?
        • -新版imodel
          • 01-imodel开发文档
          • 02-imodel培训视频
          • 03-imodel读取几何数据
          • 04-imodel获取schemas
          • 05-imodel获取instances
          • 06-imodel格式转换
          • 07-imodel关键技术之TT
          • 08-如何对cell元素进行嵌套遍历
          • 09-如何给元素加links信息
          • 10-如何创建几何元素
          • 11-如何遍历元素的tag信息
          • 12-如何获取imodel文件的odbc连接
          • 13 - 如何通过视图访问imodel数据
        • 查询i-model的来源
        • 给一个DGN中元素添加EC属性
      • +LumenRT/ContextCapture
      • +MicroStation
      • +MOSES
      • +OpenBuildings Designer
      • +OpenFlows
      • +OpenPlant
      • +OpenPlant Electrical CCK
      • Plaxis 地质分析
      • +ProjectWise
      • +ProStructures
      • +SACS
      • +STAAD.Pro
      • +SYNCHRO Pro
      • +其 它
      • +建筑设计之思考(赵大师专作)
      • +桥梁大师<BridgeMaster>
      • +现浇箱梁
      • +软件激活及授权
    • +iTwin 数字孪生平台
    • Bentley二次开发资料库
    • +常见问题汇总
    • Bentley-Learn 官方教学平台-使用方法
    • +中国优先社区使用指南
    • +Bentley学习资料库
    • +Bentley用户成功活动精选
    • +服务合作伙伴计划

     
     Questions about this article, topic, or product? Click here. 

    10-如何创建几何元素

    创建几何元素最终是通过IModel类的CreateElement接口实现的,参数设置好几何信息。示例代码如下:

               //创建直线
                Bentley.GeometryNET.Common.LineSegment geoLine = new Bentley.GeometryNET.Common.LineSegment(new DPoint3d(5 * duorPerMaster, 5 * duorPerMaster, 0), new DPoint3d(100 * duorPerMaster, 150 * duorPerMaster, 0));
                IModelElement imLine = imodel.CreateElement(geoLine);
    
    
                //创建圆
                PlacementZX placeCirc = new PlacementZX(new DPoint3d(10 * duorPerMaster, 15 * duorPerMaster, 0));
                Bentley.GeometryNET.Common.CircularArc geoCirc = new Bentley.GeometryNET.Common.CircularArc(placeCirc, 150 * duorPerMaster, Angle.Zero, Angle.TWOPI);
                IModelElement imCirc = imodel.CreateElement(geoCirc);
    
                //创建矩形
                Bentley.GeometryNET.Common.Block geoBlock = new Bentley.GeometryNET.Common.Block(new PlacementZX(new DPoint3d(0, 0, 0)), new DPoint3d(3 * duorPerMaster, 4 * duorPerMaster, 0), new DPoint3d(300 * duorPerMaster, 400 * duorPerMaster, 0), true);
                IModelElement imBlock = imodel.CreateElement(geoBlock);
    
                //创建多边形
                Bentley.GeometryNET.Common.Polygon geoPoly = new Bentley.GeometryNET.Common.Polygon();
                geoPoly.AddPoint(new DPoint3d(607 * duorPerMaster, -130 * duorPerMaster, 0));
                geoPoly.AddPoint(new DPoint3d(697 * duorPerMaster, 25 * duorPerMaster, 0));
                geoPoly.AddPoint(new DPoint3d(607 * duorPerMaster, 181 * duorPerMaster, 0));
                geoPoly.AddPoint(new DPoint3d(427 * duorPerMaster, 182 * duorPerMaster, 0));
                geoPoly.AddPoint(new DPoint3d(337 * duorPerMaster, 26 * duorPerMaster, 0));
                geoPoly.AddPoint(new DPoint3d(427 * duorPerMaster, -130 * duorPerMaster, 0));
                IModelElement imPoly = imodel.CreateElement(geoPoly);
    
                //创建弧
                PlacementZX placeArc = new PlacementZX(new DPoint3d(800 * duorPerMaster, 15 * duorPerMaster, 0));
                Bentley.GeometryNET.Common.CircularArc geoArc = new Bentley.GeometryNET.Common.CircularArc(placeArc, 150 * duorPerMaster, Angle.Zero, Angle.TWOPI * 0.08);
                IModelElement imArc = imodel.CreateElement(geoArc);
    
                //创建文字
                DPoint3d textOrigin             = new DPoint3d(1 * duorPerMaster, 4 * duorPerMaster, 0);
                PlacementZX textPlacementPoint  = new PlacementZX(textOrigin);
                double characterSize            = 100 * duorPerMaster;
                Bentley.GeometryNET.Common.SingleLineText Geotext = new Bentley.GeometryNET.Common.SingleLineText(textPlacementPoint, "Hello i-model", "宋体", characterSize, characterSize, (int)TextElementJustification.CenterTop);
                IModelElement imText = imodel.CreateElement(Geotext);
    
                //创建线串
                Bentley.GeometryNET.Common.LineString geoLineS = new Bentley.GeometryNET.Common.LineString();
                geoLineS.AddPoint(new DPoint3d(900 * duorPerMaster, -100 * duorPerMaster, 0));
                geoLineS.AddPoint(new DPoint3d(1000 * duorPerMaster, 10 * duorPerMaster, 0));
                geoLineS.AddPoint(new DPoint3d(1100 * duorPerMaster, 200 * duorPerMaster, 0));
                geoLineS.AddPoint(new DPoint3d(1200 * duorPerMaster, 250 * duorPerMaster, 0));
                IModelElement imLineS = imodel.CreateElement(geoLineS);
    
                //创建三维元素
                DPoint3d point = new DPoint3d(1000 * duorPerMaster, 1200 * duorPerMaster, 1300 * duorPerMaster);
                PlacementZX solidOrigin = new PlacementZX(point);
                Bentley.GeometryNET.Common.SurfacePatch surfacepatch = new Bentley.GeometryNET.Common.SurfacePatch();
                Bentley.GeometryNET.Common.CurveChain outer = new Bentley.GeometryNET.Common.CurveChain();
                outer.AddCurve(new Bentley.GeometryNET.Common.CircularArc(solidOrigin, 500 * duorPerMaster, Angle.FromDegrees(0), Angle.FromDegrees(360)));
                Bentley.GeometryNET.Common.CurveChain inner = new Bentley.GeometryNET.Common.CurveChain();
                inner.AddCurve(new Bentley.GeometryNET.Common.CircularArc(solidOrigin, 100 * duorPerMaster, Angle.FromDegrees(0), Angle.FromDegrees(-360)));
                surfacepatch.SetExteriorLoop(outer);
                surfacepatch.AddHoleLoop(inner);
                SolidBySweptSurface solid = new SolidBySweptSurface();
                solid.SetBaseGeometry(surfacepatch);
                Bentley.GeometryNET.Common.LineSegment extrusionPath = new Bentley.GeometryNET.Common.LineSegment(new DPoint3d(50 * duorPerMaster, 50 * duorPerMaster, 0), new DPoint3d(50 * duorPerMaster, 50 * duorPerMaster, 50 * duorPerMaster));
                solid.SetRailCurve(extrusionPath);
                IModelElement imSolid3d = imodel.CreateElement(solid);
    • imodel 几何元素
    • Share
    • History
    • More
    • Cancel
    • lijun.ma Created by lijun.ma
    • When: Mon, May 25 2015 3:51 AM
    • Revisions: 1
    • Comments: 0
    • Sign in to reply
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies