简体   繁体   English

零件或通用模型Revit附带的尺寸

[英]Dimensions attached to Parts or Generic Models Revit

I would like to dimension all my generic models ie panels and parts. 我想确定所有通用模型的尺寸,即面板和零件。 I have chosed a way to accomplish this. 我选择了一种方法来完成此任务。 But the only issue I can see is that, when repanelize the wall, its not going to override the dimension. 但是我能看到的唯一问题是,在对墙重新镶板时,它不会覆盖尺寸。

private static void CreateDimension(XYZ start, XYZ end, View view, string text, XYZ dir, double offset) { try { if (!start.IsEqual(end)) { using (Transaction t = new Transaction(AppMain.Settings.ActiveDoc, "Add dimensions")) { t.Start(); 私有静态无效CreateDimension(XYZ开始,XYZ结束,视图视图,字符串文本,XYZ目录,双偏移量){尝试{如果(!start.IsEqual(end)){ ,“添加尺寸”))){t.Start();

                    Curve c = Line.CreateBound(start, end);

                    XYZ normal = dir.Multiply(offset);

                    Line tranformed = c.CreateTransformed(Transform.CreateTranslation(normal)) as Line;

                    if (null != tranformed)
                    {
                        XYZ ai = start;
                        XYZ ao = tranformed.GetEndPoint(0);
                        Line lineA = Line.CreateBound(ai, ao);
                        DetailCurve modelcurveA = AppMain.Settings.ActiveDoc.Create.NewDetailCurve(view, lineA);

                        XYZ bi = end;
                        XYZ bo = tranformed.GetEndPoint(1);
                        Line lineB = Autodesk.Revit.DB.Line.CreateBound(bi, bo);
                        DetailCurve modelcurveB = AppMain.Settings.ActiveDoc.Create.NewDetailCurve(view, lineB);

                        ReferenceArray ra = new ReferenceArray();
                        ra.Append(modelcurveA.GeometryCurve.Reference);
                        ra.Append(modelcurveB.GeometryCurve.Reference);

                        Line lineAB = Line.CreateBound(ao, bo);
                        Dimension dimension = AppMain.Settings.ActiveDoc.Create.NewDimension(view, lineAB, ra);
                        dimension.Below = text;
                    }


                    t.Commit();
                }
            }
        }
        catch (Exception ex)
        {
            AppMain.Settings.LogErrorMessage(ex.Message);
        }
    }

Is there any other way to do it? 还有其他方法吗?

Thanks, Rob 谢谢,罗伯

Have you found a way to address this manually through the user interface? 您是否找到了一种通过用户界面手动解决此问题的方法? That is mostly the best place to start when tackling a Revit API task. 这是处理Revit API任务的最佳起点。 If you can solve it through the UI, the chances are good it can also be automated. 如果您可以通过用户界面解决问题,则很有可能也可以将其自动化。 If no UI solution is found, automation is mostly impossible as well. 如果找不到UI解决方案,那么自动化几乎也是不可能的。

I would analyse the exact differences caused in the Revit database on the elements involved and their parameters by executing the manual modification. 我将通过执行手动修改来分析Revit数据库中涉及的元素及其参数引起的确切差异。 Once you have discovered exactly what is changed by the manual UI interaction, you can probably replicate the same changes programmatically through the API. 一旦发现手动UI交互所做的确切更改,您就可以通过API以编程方式复制相同的更改。 Here is a more exhaustive description of how to address a Revit API programming task: 这是有关如何解决Revit API编程任务的更详尽的描述:

http://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontology.html#3 http://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontology.html#3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM