简体   繁体   中英

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();

                    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. 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.

I would analyse the exact differences caused in the Revit database on the elements involved and their parameters by executing the manual modification. Once you have discovered exactly what is changed by the manual UI interaction, you can probably replicate the same changes programmatically through the API. Here is a more exhaustive description of how to address a Revit API programming task:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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