Пример #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uiDoc      = commandData.Application.ActiveUIDocument;
            Document   doc        = uiDoc.Document;
            View       activeview = uiDoc.ActiveView;

            Reference refe = uiDoc.Selection.PickObject(ObjectType.Element);

            DetailArc da = doc.GetElement(refe) as DetailArc;

            Arc arc = da.GeometryCurve as Arc;

            Arc newarc1 = arc.CreateOffset(500 / 304.8, new XYZ(0, 0, 1)) as Arc;
            Arc newarc2 = arc.CreateOffset(500 / 304.8, new XYZ(0, 0, -1)) as Arc;

            using (Transaction creat_line = new Transaction(doc))
            {
                creat_line.Start("start");

                doc.Create.NewDetailCurve(activeview, newarc1);
                doc.Create.NewDetailCurve(activeview, newarc2);


                creat_line.Commit();
            }

            return(Result.Succeeded);
        }
Пример #2
0
        private void Stream( ArrayList data, DetailArc detArc )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( DetailArc ) ) );

              // nothing at this level
        }
Пример #3
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app   = commandData.Application;
            UIDocument    uidoc = app.ActiveUIDocument;
            Document      doc   = uidoc.Document;
            View          view  = doc.ActiveView;

            Autodesk.Revit.Creation.Document creDoc
                = doc.Create;

            #region Check for pre-selected wall element
            Selection sel = uidoc.Selection;
            ICollection <ElementId> ids = sel.GetElementIds();

            if (1 == ids.Count)
            {
                Element e = doc.GetElement(ids.First <ElementId>());
                if (e is Wall)
                {
                    LocationCurve lc    = e.Location as LocationCurve;
                    Curve         curve = lc.Curve;

                    using (Transaction tx = new Transaction(doc))
                    {
                        tx.Start("Create Detail Line in Wall Centre");
                        creDoc.NewDetailCurve(view, curve);
                        tx.Commit();
                    }
                    return(Result.Succeeded);
                }
            }
            #endregion // Check for pre-selected wall element

            // Create a geometry line

            XYZ startPoint = new XYZ(0, 0, 0);
            XYZ endPoint   = new XYZ(10, 10, 0);

            //Line geomLine = creApp.NewLine( startPoint, endPoint, true ); // 2013

            Line geomLine = Line.CreateBound(startPoint, endPoint); // 2014

            // Create a geometry arc

            XYZ end0         = new XYZ(0, 0, 0);
            XYZ end1         = new XYZ(10, 0, 0);
            XYZ pointOnCurve = new XYZ(5, 5, 0);

            //Arc geomArc = creApp.NewArc( end0, end1, pointOnCurve ); // 2013

            Arc geomArc = Arc.Create(end0, end1, pointOnCurve); // 2014

#if NEED_PLANE
            // Create a geometry plane

            XYZ origin = new XYZ(0, 0, 0);
            XYZ normal = new XYZ(1, 1, 0);

            Plane geomPlane = creApp.NewPlane(
                normal, origin);

            // Create a sketch plane in current document

            SketchPlane sketch = creDoc.NewSketchPlane(
                geomPlane);
#endif // NEED_PLANE

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Create Detail Line and Arc");

                // Create a DetailLine element using the
                // newly created geometry line and sketch plane

                DetailLine line = creDoc.NewDetailCurve(
                    view, geomLine) as DetailLine;

                // Create a DetailArc element using the
                // newly created geometry arc and sketch plane

                DetailArc arc = creDoc.NewDetailCurve(
                    view, geomArc) as DetailArc;

                // Change detail curve colour.
                // Initially, this only affects the newly
                // created curves. However, when the view
                // is refreshed, all detail curves will
                // be updated.

                GraphicsStyle gs = arc.LineStyle as GraphicsStyle;

                gs.GraphicsStyleCategory.LineColor
                    = new Color(250, 10, 10);

                tx.Commit();
            }
            return(Result.Succeeded);
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app  = commandData.Application;
            Document      doc  = app.ActiveUIDocument.Document;
            View          view = doc.ActiveView;

            Autodesk.Revit.Creation.Application creApp = app.Application.Create;
            Autodesk.Revit.Creation.Document    creDoc = doc.Create;

            // Create a geometry line

            XYZ startPoint = new XYZ(0, 0, 0);
            XYZ endPoint   = new XYZ(10, 10, 0);

            //Line geomLine = creApp.NewLine( startPoint, endPoint, true ); // 2013

            Line geomLine = Line.CreateBound(startPoint, endPoint); // 2014

            // Create a geometry arc

            XYZ end0         = new XYZ(0, 0, 0);
            XYZ end1         = new XYZ(10, 0, 0);
            XYZ pointOnCurve = new XYZ(5, 5, 0);

            //Arc geomArc = creApp.NewArc( end0, end1, pointOnCurve ); // 2013

            Arc geomArc = Arc.Create(end0, end1, pointOnCurve); // 2014

#if NEED_PLANE
            // Create a geometry plane

            XYZ origin = new XYZ(0, 0, 0);
            XYZ normal = new XYZ(1, 1, 0);

            Plane geomPlane = creApp.NewPlane(
                normal, origin);

            // Create a sketch plane in current document

            SketchPlane sketch = creDoc.NewSketchPlane(
                geomPlane);
#endif // NEED_PLANE

            // Create a DetailLine element using the
            // newly created geometry line and sketch plane

            DetailLine line = creDoc.NewDetailCurve(
                view, geomLine) as DetailLine;

            // Create a DetailArc element using the
            // newly created geometry arc and sketch plane

            DetailArc arc = creDoc.NewDetailCurve(
                view, geomArc) as DetailArc;

            // Change detail curve colour.
            // Initially, this only affects the newly
            // created curves. However, when the view
            // is refreshed, all detail curves will
            // be updated.

            GraphicsStyle gs = arc.LineStyle as GraphicsStyle;

            gs.GraphicsStyleCategory.LineColor
                = new Color(250, 10, 10);

            return(Result.Succeeded);
        }