【问题标题】:Autodesk Revit plugin crashingAutodesk Revit 插件崩溃
【发布时间】:2013-10-18 09:17:50
【问题描述】:

我正在为 Autodesk Revit 2014 开发一个插件,将房间几何图形转换为概念体量。 但是当我运行脚本时,revit 会完全关闭。 我已经隔离了导致崩溃的代码:

Extrusion m_Extrusion = m_FamDoc.FamilyCreate.NewExtrusion(true, m_CurveArArray, m_SketchPlane, 8);

revit 日志显示此错误:

DBG_INFO:检测到未冻结的选择更改。:第 571 行 n:\build\2014_ship_x64_inst_20130308_1515\source\revit\revitui\modscope\ModScope.cpp

有人知道我使用挤压命令是否有问题吗?还是 Revit 中的某些东西?

提前致谢。

【问题讨论】:

    标签: c# revit autodesk revit-api


    【解决方案1】:

    通过定义任何类型的数组,我在代码中遇到了同样的问题。 几周后通过大量搜索,我什么也没找到,但我意识到我使用的是 dot net framework 5.0 版,当我将其更改为 dot net framework 4.8 时,一切正常。

    【讨论】:

    【解决方案2】:

    完全冻结很奇怪...可能与您的代码有关(在 NewExtrusion 调用之前)

    事实上,这个方法有一个完整的示例,请参阅 github 上这个文件中的 createSolid 方法(大约第 170 行):https://github.com/ADN-DevTech/RevitTrainingMaterial/blob/master/Labs/3_Revit_Family_API/SourceCS/1_ColumnRectangle.cs

    // ==========================================
        //   (1) create a simple solid by extrusion
        // ==========================================
        Extrusion createSolid()
        {
          //
          // (1) define a simple rectangular profile
          //
          //  3     2
          //   +---+
          //   |   | d    h = height
          //   +---+
          //  0     1
          //  4  w
          //
          CurveArrArray pProfile = createProfileRectangle();
          //
          // (2) create a sketch plane
          //
          // we need to know the template. If you look at the template (Metric Column.rft) and "Front" view,
          // you will see "Reference Plane" at "Lower Ref. Level". We are going to create an extrusion there.
          // findElement() is a helper function that find an element of the given type and name.  see below.
          //
          ReferencePlane pRefPlane = findElement(typeof(ReferencePlane), "Reference Plane") as ReferencePlane;
          //SketchPlane pSketchPlane = _doc.FamilyCreate.NewSketchPlane( pRefPlane.Plane ); // 2013
          SketchPlane pSketchPlane = SketchPlane.Create( _doc, pRefPlane.Plane ); // 2014
    
          // (3) height of the extrusion
          //
          // once again, you will need to know your template. unlike UI, the alightment will not adjust the geometry.
          // You will need to have the exact location in order to set alignment.
          // Here we hard code for simplicity. 4000 is the distance between Lower and Upper Ref. Level.
          // as an exercise, try changing those values and see how it behaves.
          //
          double dHeight = mmToFeet(4000.0);
    
          // (4) create an extrusion here. at this point. just an box, nothing else.
          //
          bool bIsSolid = true;
          return _doc.FamilyCreate.NewExtrusion(bIsSolid, pProfile, pSketchPlane, dHeight);
        }
    

    【讨论】:

      【解决方案3】:

      您是否为此创建了交易?就像是: 使用 (Transaction trans = new Transaction(doc, "Extrude")) { 反式开始(); 挤压 m_extrusion = m_FamDoc.FamilyCreate.NewExtrusion...... trans.Commit(); }

      【讨论】:

        【解决方案4】:

        A.没有创建我自己的任何挤压代码,并且 B. 不了解您正在做的事情的更大背景,

        我最好的建议是查看 Mastering Revit Architecture 2014 这本书。我现在正在看 2013 年的书,其中有一节介绍了 API(第 25 章)。在那一章中,他们深入研究了一个占用房间并产生质量的插件。它看起来正是您正在寻找的。​​p>

        我只是绕道看看 API 参考是否在 2014 年的书中,并且它没有在 TOC 中列出,所以你可能对那个版本不走运(我无法想象他们为什么会删除它),但 2013 年确实如此。

        http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118174089.html

        【讨论】:

        • 欢迎来到 SO!不幸的是,书籍推荐在这里并不是很有帮助。如果您从中得到答案,您当然可以相信一本书,但是 OP 可能没有资源来获取它(如果它在 OP 的区域中不可用或已经绝版,会发生什么情况?)。如果您可以在答案中提供一些示例代码,那将对 OP 有更多帮助。
        • 谢谢@Derek。我在精神上同意你的看法。尽管在三周内没有人触及这个答案。只需要写一行代码,我认为一本书参考了一个与用户意图相同的 API 示例,至少是低迷中的一阵风。
        猜你喜欢
        • 2016-11-23
        • 2021-08-08
        • 2021-10-16
        • 1970-01-01
        • 2019-01-21
        • 1970-01-01
        • 1970-01-01
        • 2019-03-03
        • 1970-01-01
        相关资源
        最近更新 更多