Exemplo n.º 1
0
        /// <summary>
        /// create truss in Revit
        /// </summary>
        /// <returns>new created truss</returns>
        public Autodesk.Revit.DB.Structure.Truss CreateTruss()
        {
            Autodesk.Revit.DB.Document          document  = m_commandData.Application.ActiveUIDocument.Document;
            Autodesk.Revit.Creation.Document    createDoc = document.Create;
            Autodesk.Revit.Creation.Application createApp = m_commandData.Application.Application.Create;
            //sketchPlane
            Autodesk.Revit.DB.XYZ origin     = new Autodesk.Revit.DB.XYZ(0, 0, 0);
            Autodesk.Revit.DB.XYZ xDirection = new Autodesk.Revit.DB.XYZ(1, 0, 0);
            Autodesk.Revit.DB.XYZ yDirection = new Autodesk.Revit.DB.XYZ(0, 1, 0);
            Plane       plane       = Plane.CreateByOriginAndBasis(xDirection, yDirection, origin);
            SketchPlane sketchPlane = SketchPlane.Create(document, plane);
            //new base Line
            AnalyticalModel frame1 = column1.GetAnalyticalModel();

            Autodesk.Revit.DB.XYZ centerPoint1 = (frame1.GetCurve() as Line).GetEndPoint(0);
            AnalyticalModel       frame2       = column2.GetAnalyticalModel();

            Autodesk.Revit.DB.XYZ  centerPoint2 = (frame2.GetCurve() as Line).GetEndPoint(0);
            Autodesk.Revit.DB.XYZ  startPoint   = new Autodesk.Revit.DB.XYZ(centerPoint1.X, centerPoint1.Y, 0);
            Autodesk.Revit.DB.XYZ  endPoint     = new Autodesk.Revit.DB.XYZ(centerPoint2.X, centerPoint2.Y, 0);
            Autodesk.Revit.DB.Line baseLine     = null;

            try
            { baseLine = Line.CreateBound(startPoint, endPoint); }
            catch (System.ArgumentException)
            {
                TaskDialog.Show("Argument Exception", "Two column you selected are too close to create truss.");
            }

            return(Autodesk.Revit.DB.Structure.Truss.Create(document, m_selectedTrussType.Id, sketchPlane.Id, baseLine));
        }
Exemplo n.º 2
0
        PlaceColumn(Autodesk.Revit.ApplicationServices.Application rvtApp, Document rvtDoc, Autodesk.Revit.DB.XYZ point2, double angle, FamilySymbol columnType, ElementId baseLevelId, ElementId topLevelId)
        {
            Autodesk.Revit.DB.XYZ point = point2;
            // Note: Must use level-hosted NewFamilyInstance!
            Level instLevel = (Level)rvtDoc.GetElement(baseLevelId);

            Autodesk.Revit.DB.FamilyInstance column = rvtDoc.Create.NewFamilyInstance(point, columnType, instLevel, StructuralType.Column);

            if (column == null)
            {
                MessageBox.Show("failed to create an instance of a column.");
                return;
            }

            Autodesk.Revit.DB.XYZ zVec = new Autodesk.Revit.DB.XYZ(0, 0, 1);


            Autodesk.Revit.DB.Line axis = Line.CreateUnbound(point, zVec);

            column.Location.Rotate(axis, angle);

            // Set the level Ids
            Parameter baseLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
            Parameter topLevelParameter  = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM);;

            baseLevelParameter.Set(baseLevelId);
            topLevelParameter.Set(topLevelId);
        }
Exemplo n.º 3
0
        //族实例化,创建族并对其进行旋转
        private FamilyInstance CreateFamlyInstance(DG.Point DGpoint, DG.Curve curve, FamilySymbol FamilySymbol, ExternalCommandData commandData)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument; //取得当前活动文档

            XYZ point = DGpoint.ToRevitType(false);                      //dynamo转Revit

            FamilyInstance familyInstance = uiDoc.Document.Create.NewFamilyInstance(point, FamilySymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
            LocationPoint  locationPoint  = familyInstance.Location as LocationPoint;//自适应族基点
            XYZ            axisP          = new XYZ(point.X, point.Y, point.Z + 100);

            Autodesk.Revit.DB.Line axis = Autodesk.Revit.DB.Line.CreateBound(point, axisP);//旋转轴

            //计算旋转角度
            double ratio = curve.ParameterAtPoint(DGpoint);

            DG.Vector vector = curve.TangentAtParameter(ratio);

            MessageBox.Show(vector.ToString());

            DG.Vector vector1 = DG.Vector.ByCoordinates(vector.X, vector.Y, 0);//三维切向量的平面向量
            DG.Vector vectorY = DG.Vector.ByCoordinates(0, 1, 0);
            double    angle   = vector1.AngleWithVector(vectorY) / 180 * Math.PI;

            MessageBox.Show(angle.ToString());
            //locationPoint.Rotate(axis, angle);//旋转横梁
            ElementTransformUtils.RotateElement(uiDoc.Document, familyInstance.Id, axis, -angle);

            return(familyInstance);
        }
Exemplo n.º 4
0
 private static bool ExtrachtHeightForStation(ref XYZ PointToFill, double StationToStudy, XYZ HeightPoint, XYZ PointBeforeIt = null)
 {
     if (HeightPoint.X == StationToStudy)
     {
         PointToFill = new XYZ(PointToFill.X, PointToFill.Y, HeightPoint.Z);
         return(true);
     }
     else
     {
         if (HeightPoint.X > StationToStudy)
         {
             if (PointBeforeIt != null)
             {
                 LineX LL     = LineX.CreateBound(PointBeforeIt, HeightPoint);
                 XYZ   Vector = HeightPoint - PointBeforeIt;
                 var   Angle  = XYZ.BasisX.AngleTo(Vector) * 180 / Math.PI;
                 var   XPoint = (StationToStudy - PointBeforeIt.X);
                 var   point  = LL.Evaluate((XPoint / (HeightPoint.X - PointBeforeIt.X)), true);
                 PointToFill = new XYZ(PointToFill.X, PointToFill.Y, point.Z);
             }
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        private static void ExtractHeightElements(List <HeightElements> HeightElements, ProfAlign Profilealign, int i, object CurrentPViPoint)
        {
            if (CurrentPViPoint is PVI)
            {
                XYZ PVIPoint         = ExtractPVIPoint((CurrentPViPoint as PVI).Text);
                var NextPVIPointLand = Profilealign.Items[i + 1];

                (double, double)Range = (0, 0);
                Range.Item1           = PVIPoint.X;

                Autodesk.Revit.DB.Line LineElement = GetLineElementForPVI(PVIPoint, NextPVIPointLand, ref Range);
                HeightElements.Add(new HeightElements(Range, LineElement));
            }
            else if (CurrentPViPoint is CircCurve)
            {
                (double, double)ARcRange, LineAfterRange;
                XYZ ArcPointEnd, NextPviPoint;
                Arc ARC;

                GetarcElementPVI(Profilealign, i, CurrentPViPoint, out ARcRange, out ArcPointEnd, out LineAfterRange, out NextPviPoint, out ARC);

                HeightElements.Add(new HeightElements(ARcRange, ARC));

                var LineAfterCurve = Autodesk.Revit.DB.Line.CreateBound(ArcPointEnd, NextPviPoint);
                HeightElements.Add(new HeightElements(LineAfterRange, LineAfterCurve));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            Transaction transaction = new Transaction(doc, "PointsOnCurve");

            transaction.Start();
            XYZ start = new XYZ(0, 0, 0);
            XYZ end   = new XYZ(50, 50, 0);

            Autodesk.Revit.DB.Line line = Autodesk.Revit.DB.Line.CreateBound(start, end);
            Plane       geometryPlane   = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, start);
            SketchPlane skplane         = SketchPlane.Create(doc, geometryPlane);
            ModelCurve  modelcurve      = doc.FamilyCreate.NewModelCurve(line, skplane);

            for (double i = 0.1; i <= 1; i = i + 0.1)
            {
                PointLocationOnCurve locationOnCurve = new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, i, PointOnCurveMeasureFrom.Beginning);
                PointOnEdge          poe             = app.Create.NewPointOnEdge(modelcurve.GeometryCurve.Reference, locationOnCurve);
                ReferencePoint       rp2             = doc.FamilyCreate.NewReferencePoint(poe);
            }
            transaction.Commit();

            return(Result.Succeeded);
        }
Exemplo n.º 7
0
        /// <summary>
        /// create truss in Revit
        /// </summary>
        /// <returns>new created truss</returns>
        public Autodesk.Revit.DB.Structure.Truss CreateTruss()
        {
            Autodesk.Revit.Creation.Document    createDoc = m_commandData.Application.ActiveUIDocument.Document.Create;
            Autodesk.Revit.Creation.Application createApp = m_commandData.Application.Application.Create;
            //sketchPlane
            Autodesk.Revit.DB.XYZ origin     = new Autodesk.Revit.DB.XYZ(0, 0, 0);
            Autodesk.Revit.DB.XYZ xDirection = new Autodesk.Revit.DB.XYZ(1, 0, 0);
            Autodesk.Revit.DB.XYZ yDirection = new Autodesk.Revit.DB.XYZ(0, 1, 0);
            Plane       plane       = createApp.NewPlane(xDirection, yDirection, origin);
            SketchPlane sketchPlane = createDoc.NewSketchPlane(plane);
            //new base Line
            AnalyticalModel frame1 = column1.GetAnalyticalModel();

            Autodesk.Revit.DB.XYZ centerPoint1 = (frame1.GetCurve() as Line).get_EndPoint(0);
            AnalyticalModel       frame2       = column2.GetAnalyticalModel();

            Autodesk.Revit.DB.XYZ  centerPoint2 = (frame2.GetCurve() as Line).get_EndPoint(0);
            Autodesk.Revit.DB.XYZ  startPoint   = new Autodesk.Revit.DB.XYZ(centerPoint1.X, centerPoint1.Y, 0);
            Autodesk.Revit.DB.XYZ  endPoint     = new Autodesk.Revit.DB.XYZ(centerPoint2.X, centerPoint2.Y, 0);
            Autodesk.Revit.DB.Line baseLine     = null;

            try
            { baseLine = createApp.NewLineBound(startPoint, endPoint); }
            catch (System.ArgumentException)
            { MessageBox.Show("Two column you selected are too close to create truss."); }

            return(createDoc.NewTruss(m_selectedTrussType, sketchPlane, baseLine));
        }
Exemplo n.º 8
0
        public static LineCurve ToRhino(DB.Line line)
        {
            var l = new Line(ToRhino(line.GetEndPoint(0)), ToRhino(line.GetEndPoint(1)));

            return(line.IsBound ?
                   new LineCurve(l, line.GetEndParameter(0), line.GetEndParameter(1)) :
                   null);
        }
Exemplo n.º 9
0
        public JObject ConvertToDTO(Autodesk.Revit.DB.Wall source)
        {
            Autodesk.Revit.DB.Curve curve = (source.Location as LocationCurve).Curve;
            Autodesk.Revit.DB.Line  line  = curve as Autodesk.Revit.DB.Line;

            if (line == null)
            {
                return(null);
            }

            BoundingBoxXYZ bb = source.get_BoundingBox(null);

            Autodesk.Revit.DB.XYZ origin   = line.Tessellate().First();
            Autodesk.Revit.DB.XYZ endpoint = line.Tessellate().Last(); /// origin + line.Direction * line.Length;

            List <LMAStudio.StreamVR.Common.Models.Face> wallFaces = new List <LMAStudio.StreamVR.Common.Models.Face>();

            Autodesk.Revit.DB.GeometryElement defaultGeometry = source.get_Geometry(new Options());
            if (defaultGeometry != null)
            {
                Solid solidGeometry = defaultGeometry.FirstOrDefault() as Solid;

                if (solidGeometry != null)
                {
                    wallFaces = GeometryConversion.ConvertToDTO(source, solidGeometry);
                }
            }

            LMAStudio.StreamVR.Common.Models.Wall dest = new LMAStudio.StreamVR.Common.Models.Wall
            {
                Id          = source.Id.ToString(),
                Name        = source.Name,
                Depth       = source.Width,
                Orientation = new LMAStudio.StreamVR.Common.Models.XYZ
                {
                    X = source.Orientation.X,
                    Y = source.Orientation.Y,
                    Z = source.Orientation.Z,
                },
                Endpoint0 = new LMAStudio.StreamVR.Common.Models.XYZ
                {
                    X = origin.X,
                    Y = origin.Y,
                    Z = bb.Min.Z,
                },
                Endpoint1 = new LMAStudio.StreamVR.Common.Models.XYZ
                {
                    X = endpoint.X,
                    Y = endpoint.Y,
                    Z = bb.Max.Z,
                },
                Faces = wallFaces
            };

            return(JObject.FromObject(dest));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Tessellate the curve:
        /// 1). If there are more than 2 points, create a polyline out of the points;
        /// 2). If there are exactly 2 points, create a line;
        /// 3). If there's exception thrown during the tessellation process, attempt to create
        /// a line from start and end points. If that fails, a point will be created instead.
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        private IEnumerable <GeometryObject> Tessellate(Curve curve)
        {
            var result = new List <GeometryObject>();

            try
            {
                // we scale the tesselation rather than the curve
                var conv = UnitConverter.DynamoToHostFactor(UnitType.UT_Length);

                // use the ASM tesselation of the curve
                var pkg = renderPackageFactory.CreateRenderPackage();
                curve.Tessellate(pkg, renderPackageFactory.TessellationParameters);

                // get necessary info to enumerate and convert the lines
                //var lineCount = pkg.LineVertexCount * 3 - 3;
                var verts = pkg.LineStripVertices.ToList();

                if (verts.Count > 2)
                {
                    var scaledXYZs = new List <XYZ>();
                    for (var i = 0; i < verts.Count; i += 3)
                    {
                        scaledXYZs.Add(new XYZ(verts[i] * conv, verts[i + 1] * conv, verts[i + 2] * conv));
                    }
                    result.Add(PolyLine.Create(scaledXYZs));
                }
                else if (verts.Count == 2)
                {
                    result.Add(Line.CreateBound(curve.StartPoint.ToXyz(), curve.EndPoint.ToXyz()));
                }
            }
            catch (Exception)
            {
                // Add a red bounding box geometry to identify that some errors occur
                var bbox = curve.BoundingBox;
                result.AddRange(ProtoToRevitMesh.CreateBoundingBoxMeshForErrors(bbox.MinPoint, bbox.MaxPoint));

                try
                {
                    result.Add(Line.CreateBound(curve.StartPoint.ToXyz(), curve.EndPoint.ToXyz()));
                }
                catch (Exception)
                {
                    try
                    {
                        result.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(curve.StartPoint.ToXyz()));
                    }
                    catch (ArgumentException)
                    {
                        //if either the X, Y or Z of the point is infinite, no need to add it for preview
                    }
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        /***************************************************/

        private static Element ToRevitElement(this ModelInstance modelInstance, MEPCurveType mEPType, RevitSettings settings)
        {
            if (mEPType == null || modelInstance == null)
            {
                return(null);
            }

            if (!(modelInstance.Location is ICurve))
            {
                Compute.InvalidFamilyPlacementTypeError(modelInstance, mEPType);
                return(null);
            }

            Document document = mEPType.Document;

            BH.oM.Geometry.Line line = modelInstance.Location as BH.oM.Geometry.Line;

            Level level = document.LevelBelow(line, settings);

            if (level == null)
            {
                return(null);
            }

            Autodesk.Revit.DB.Line revitLine = line.ToRevit();
            if (revitLine == null)
            {
                return(null);
            }

            XYZ startPoint = revitLine.GetEndPoint(0);
            XYZ endPoint   = revitLine.GetEndPoint(1);

            if (mEPType is Autodesk.Revit.DB.Electrical.CableTrayType)
            {
                return(Autodesk.Revit.DB.Electrical.CableTray.Create(document, mEPType.Id, startPoint, endPoint, level.Id));
            }
            else if (mEPType is Autodesk.Revit.DB.Electrical.ConduitType)
            {
                return(Autodesk.Revit.DB.Electrical.Conduit.Create(document, mEPType.Id, startPoint, endPoint, level.Id));
            }
            else if (mEPType is Autodesk.Revit.DB.Plumbing.PipeType)
            {
                Autodesk.Revit.DB.Plumbing.PipingSystemType pst = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Plumbing.PipingSystemType)).OfType <Autodesk.Revit.DB.Plumbing.PipingSystemType>().FirstOrDefault();
                return(Autodesk.Revit.DB.Plumbing.Pipe.Create(document, pst.Id, mEPType.Id, level.Id, startPoint, endPoint));
            }
            else if (mEPType is Autodesk.Revit.DB.Mechanical.DuctType)
            {
                Autodesk.Revit.DB.Mechanical.MechanicalSystemType mst = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Mechanical.MechanicalSystemType)).OfType <Autodesk.Revit.DB.Mechanical.MechanicalSystemType>().FirstOrDefault();
                return(Autodesk.Revit.DB.Mechanical.Duct.Create(document, mst.Id, mEPType.Id, level.Id, startPoint, endPoint));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 12
0
        public RevitPlacmenElement(XYZ placementPoint, double station, Alignment alignment, double rotationToAlignmentInX, Autodesk.Revit.DB.Line simplifiedAlignmentAxis)
        {
            PlacementPoint          = placementPoint;
            Station                 = Math.Round(station, 4);
            TextStation             = station;
            RotationToAlignmentInX  = rotationToAlignmentInX;
            SimplifiedAlignmentAxis = simplifiedAlignmentAxis;
            var PointElevation = LandXmlStationingObject.ExtractHeightForPoint(this.Station, alignment);

            this.PlacementPoint = new XYZ(PlacementPoint.X, PlacementPoint.Y, PointElevation);
        }
Exemplo n.º 13
0
 public static LineCurve ToRhino(DB.Line line)
 {
     return(line.IsBound ?
            new LineCurve
            (
                new Line(AsPoint3d(line.GetEndPoint(0)), AsPoint3d(line.GetEndPoint(1))),
                line.GetEndParameter(0),
                line.GetEndParameter(1)
            ) :
            null);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Private constructor that creates a new Element every time
        /// </summary>
        /// <param name="line"></param>
        private Grid(Autodesk.Revit.DB.Line line)
        {
            // Changing the underlying curve requires destroying the Grid
            TransactionManager.Instance.EnsureInTransaction(Document);

            Autodesk.Revit.DB.Grid g = Document.Create.NewGrid(line);
            InternalSetGrid(g);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, this.InternalElement);
        }
Exemplo n.º 15
0
        public override FScheme.Value Evaluate(FSharpList <FScheme.Value> args)
        {
            Solid thisSolid  = (Solid)((FScheme.Value.Container)args[0]).Item;
            Line  selectLine = (Line)((FScheme.Value.Container)args[1]).Item;

            FaceArray faceArr  = thisSolid.Faces;
            var       thisEnum = faceArr.GetEnumerator();

            SortedList <double, Autodesk.Revit.DB.Face> intersectingFaces = new SortedList <double, Autodesk.Revit.DB.Face>();

            for (; thisEnum.MoveNext();)
            {
                Autodesk.Revit.DB.Face  thisFace    = (Autodesk.Revit.DB.Face)thisEnum.Current;
                IntersectionResultArray resultArray = null;

                SetComparisonResult resultIntersect = thisFace.Intersect(selectLine, out resultArray);
                if (resultIntersect != SetComparisonResult.Overlap)
                {
                    continue;
                }
                bool   first   = true;
                double linePar = -1.0;
                foreach (IntersectionResult ir in resultArray)
                {
                    double irPar = ir.Parameter;
                    if (first == true)
                    {
                        linePar = irPar;
                        first   = false;
                    }
                    else if (irPar < linePar)
                    {
                        linePar = irPar;
                    }
                }
                intersectingFaces.Add(linePar, thisFace);
            }

            var result = FSharpList <FScheme.Value> .Empty;

            var intersectingFacesEnum = intersectingFaces.Reverse().GetEnumerator();

            for (; intersectingFacesEnum.MoveNext();)
            {
                Autodesk.Revit.DB.Face faceObj = intersectingFacesEnum.Current.Value;
                result = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewContainer(faceObj), result);
            }

            return(FScheme.Value.NewList(result));
        }
Exemplo n.º 16
0
        public XYZ FindIntersectwoline(Line line1, Line line2)
        {
            IntersectionResultArray resultArray;

            if (Line.CreateBound(line2.Origin + 10000.0 * line2.Direction, line2.Origin - 10000.0 * line2.Direction).Intersect((Curve)Line.CreateBound(line1.Origin + 10000.0 * line1.Direction, line1.Origin - 10000.0 * line1.Direction), out resultArray) != SetComparisonResult.Overlap)
            {
                throw new InvalidOperationException("Input lines did not intersect.");
            }
            if (resultArray == null || resultArray.Size != 1)
            {
                throw new InvalidOperationException("Could not extract line intersection point.");
            }
            return(resultArray.get_Item(0).XYZPoint);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Init by Elements
        /// </summary>
        /// <param name="view"></param>
        /// <param name="line"></param>
        /// <param name="references"></param>
        /// <param name="suffix"></param>
        /// <param name="prefix"></param>
        private void Init(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Line line, ReferenceArray references, string suffix, string prefix)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;
            TransactionManager.Instance.EnsureInTransaction(document);

            // get element from trace
            var element = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Dimension>(document);

            if (element == null)
            {
                element = document.Create.NewDimension(view, line, references);
            }
            else
            {
                LocationCurve location = element.Location as LocationCurve;
                location.Curve = line;
            }

            InternalSetElement(element);

            // apply suffix
            if (this.InternalRevitElement.NumberOfSegments == 0)
            {
                this.InternalRevitElement.Suffix = suffix;
            }
            else if (this.InternalRevitElement.NumberOfSegments > 1)
            {
                foreach (DimensionSegment segment in this.InternalRevitElement.Segments)
                {
                    segment.Suffix = suffix;
                }
            }

            // apply prefix
            if (this.InternalRevitElement.NumberOfSegments == 0)
            {
                this.InternalRevitElement.Prefix = prefix;
            }
            else if (this.InternalRevitElement.NumberOfSegments > 1)
            {
                foreach (DimensionSegment segment in this.InternalRevitElement.Segments)
                {
                    segment.Prefix = prefix;
                }
            }

            TransactionManager.Instance.TransactionTaskDone();
            ElementBinder.SetElementForTrace(this.InternalElement);
        }
Exemplo n.º 18
0
        private static XYZ ReviseYValue(XYZ nextPt, SeatBatch batch, bool alignBottom)
        {
            var line        = Line.CreateBound(new XYZ(nextPt.X, -10000000, nextPt.Z), new XYZ(nextPt.X, 10000000, nextPt.Z));
            var roomInsPts  = line.GetPlaneInsPointList(RoomEdges);
            var boxInsPts   = line.GetPlaneInsPointList(PickEdges);
            var roomInsMinY = roomInsPts.Min(m => m.Y);
            var boxInsMinY  = boxInsPts.Min(m => m.Y);
            var roomInsMaxY = roomInsPts.Max(m => m.Y);
            var boxInsMaxY  = boxInsPts.Max(m => m.Y);

            // Revises the next point y min value.
            var pt1 = new XYZ(nextPt.X, Math.Max(roomInsMinY, boxInsMinY) + 0.05, nextPt.Z);
            var pt2 = new XYZ(nextPt.X, Math.Min(roomInsMaxY, boxInsMaxY) - batch.Length - 0.05, nextPt.Z);

            return(alignBottom ? pt1 : pt2);
        }
 public static LineCurve ToRhino(DB.Line line)
 {
     return(line.IsBound ?
            new LineCurve
            (
                new Line(AsPoint3d(line.GetEndPoint(0)), AsPoint3d(line.GetEndPoint(1))),
                line.GetEndParameter(0),
                line.GetEndParameter(1)
            ) :
            new LineCurve
            (
                new Line(AsPoint3d(line.Origin) - (15000.0 * AsVector3d(line.Direction)), AsPoint3d(line.Origin) + (15000.0 * AsVector3d(line.Direction))),
                -15000,
                +15000
            ));
 }
Exemplo n.º 20
0
        public Autodesk.Revit.DB.Solid CreateSolidFromBoundingBox(Autodesk.Revit.DB.Solid inputSolid)
        {
            BoundingBoxXYZ bbox = inputSolid.GetBoundingBox();

            // Corners in BBox coords

            XYZ pt0 = new XYZ(bbox.Min.X, bbox.Min.Y, bbox.Min.Z);
            XYZ pt1 = new XYZ(bbox.Max.X, bbox.Min.Y, bbox.Min.Z);
            XYZ pt2 = new XYZ(bbox.Max.X, bbox.Max.Y, bbox.Min.Z);
            XYZ pt3 = new XYZ(bbox.Min.X, bbox.Max.Y, bbox.Min.Z);

            // Edges in BBox coords

            Autodesk.Revit.DB.Line edge0 = Autodesk.Revit.DB.Line.CreateBound(pt0, pt1);
            Autodesk.Revit.DB.Line edge1 = Autodesk.Revit.DB.Line.CreateBound(pt1, pt2);
            Autodesk.Revit.DB.Line edge2 = Autodesk.Revit.DB.Line.CreateBound(pt2, pt3);
            Autodesk.Revit.DB.Line edge3 = Autodesk.Revit.DB.Line.CreateBound(pt3, pt0);

            // Create loop, still in BBox coords

            List <Autodesk.Revit.DB.Curve> edges = new List <Autodesk.Revit.DB.Curve>();

            edges.Add(edge0);
            edges.Add(edge1);
            edges.Add(edge2);
            edges.Add(edge3);

            double height = bbox.Max.Z - bbox.Min.Z;

            CurveLoop baseLoop = CurveLoop.Create(edges);

            List <CurveLoop> loopList = new List <CurveLoop>();

            loopList.Add(baseLoop);

            Autodesk.Revit.DB.Solid preTransformBox = GeometryCreationUtilities
                                                      .CreateExtrusionGeometry(loopList, XYZ.BasisZ,
                                                                               height);


            Autodesk.Revit.DB.Solid transformBox = SolidUtils.CreateTransformed(
                preTransformBox, bbox.Transform);


            return(preTransformBox);
        }
Exemplo n.º 21
0
        private void CreateWall()
        {
            RevitCreation.Application createApp = m_commandData.Application.Application.Create;
            RevitCreation.Document    createDoc = m_commandData.Application.ActiveUIDocument.Document.Create;

            RevitDB.Line geometryLine = RevitDB.Line.CreateBound(m_startPoint, m_endPoint);
            if (null == geometryLine)
            {
                throw new Exception("Create the geometry line failed.");
            }

            RevitDB.Wall createdWall = RevitDB.Wall.Create(m_commandData.Application.ActiveUIDocument.Document,
                                                           geometryLine, m_createType.Id, m_createlevel.Id,
                                                           15, m_startPoint.Z + m_createlevel.Elevation, true, true);
            if (null == createdWall)
            {
                throw new Exception("Create the wall failed.");
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// This node will attempt to rotate a plan view into a 3D view. Use at your own risk!
        /// </summary>
        /// <param name="viewPlan">The plan view to rotate</param>
        /// <param name="rotationLine">The line to rotate along.</param>
        /// <param name="inputAngle">The plan view to get outline from.</param>
        /// <returns name="cropBox">The cropBox.</returns>
        /// <search>
        /// view, outline,rhythm
        /// </search>
        public static object Rotate(global::Revit.Elements.Element viewPlan, global::Revit.Elements.ModelCurve rotationLine, double inputAngle)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.View     internalView = (Autodesk.Revit.DB.View)viewPlan.InternalElement;
            var viewBbox = internalView.CropBox;

            Autodesk.Revit.DB.ModelCurve internalLine = (Autodesk.Revit.DB.ModelCurve)rotationLine.InternalElement;

            Autodesk.Revit.DB.Line rotationLineBound = Autodesk.Revit.DB.Line.CreateBound(internalLine.GeometryCurve.GetEndPoint(0), internalLine.GeometryCurve.GetEndPoint(1));

            Autodesk.Revit.DB.Element cropBoxElement = null;
            using (TransactionGroup tGroup = new TransactionGroup(doc))
            {
                tGroup.Start("Temp to find crop box element");
                using (Transaction t2 = new Transaction(doc, "Temp to find crop box element"))
                {
                    // Deactivate crop box
                    t2.Start();
                    internalView.CropBoxVisible = false;
                    t2.Commit();
                    // Get all visible elements;
                    // this excludes hidden crop box
                    FilteredElementCollector collector  = new FilteredElementCollector(doc, internalView.Id);
                    ICollection <ElementId>  shownElems = collector.ToElementIds();
                    // Activate crop box
                    t2.Start();
                    internalView.CropBoxVisible = true;
                    t2.Commit();
                    // Get all visible elements excluding
                    // everything except the crop box
                    collector = new FilteredElementCollector(doc, internalView.Id);
                    collector.Excluding(shownElems);
                    cropBoxElement = collector.FirstElement();
                }
                tGroup.RollBack();
            }
            TransactionManager.Instance.EnsureInTransaction(doc);
            ElementTransformUtils.RotateElement(doc, cropBoxElement.Id, rotationLineBound, inputAngle);
            TransactionManager.Instance.TransactionTaskDone();

            return(cropBoxElement);
        }
Exemplo n.º 23
0
        public static DB.Line[] ToLines(this Polyline value, double factor)
        {
            value.ReduceSegments(Revit.ShortCurveTolerance);

            int count = value.Count;
            var list  = new DB.Line[Math.Max(0, count - 1)];

            if (count > 1)
            {
                var    point = value[0];
                DB.XYZ end, start = new DB.XYZ(point.X * factor, point.Y * factor, point.Z * factor);
                for (int p = 1; p < count; start = end, ++p)
                {
                    point       = value[p];
                    end         = new DB.XYZ(point.X * factor, point.Y * factor, point.Z * factor);
                    list[p - 1] = DB.Line.CreateBound(start, end);
                }
            }

            return(list);
        }
Exemplo n.º 24
0
        /// <summary>
        /// create the curtain wall to the active document of Revit
        /// </summary>
        /// <returns>
        /// the created curtain wall
        /// </returns>
        public Wall CreateCurtainWall()
        {
            if (null == m_selectedWallType || null == m_selectedView)
            {
                return(null);
            }

            Autodesk.Revit.Creation.Document    createDoc = m_myDocument.Document.Create;
            Autodesk.Revit.Creation.Application createApp = m_myDocument.CommandData.Application.Application.Create;
            //baseline
            System.Drawing.Point point0 = m_drawing.WallLine2D.StartPoint;
            System.Drawing.Point point1 = m_drawing.WallLine2D.EndPoint;
            //new baseline and transform coordinate on windows UI to Revit UI
            m_startXYZ = new Autodesk.Revit.DB.XYZ(m_startPointD.X, m_startPointD.Y, 0);
            m_endXYZ   = new Autodesk.Revit.DB.XYZ(m_endPointD.X, m_endPointD.Y, 0);
            Autodesk.Revit.DB.Line baseline = null;
            try
            {
                baseline = Line.CreateBound(m_startXYZ, m_endXYZ);
            }
            catch (System.ArgumentException)
            {
                TaskDialog.Show("Revit", "The start point and the end point of the line are too close, please re-draw it.");
            }
            Transaction act = new Transaction(m_myDocument.Document);

            act.Start(Guid.NewGuid().GetHashCode().ToString());
            Wall wall = Wall.Create(m_myDocument.Document, baseline, m_selectedWallType.Id,
                                    m_selectedView.GenLevel.Id, 20, 0, false, false);

            act.Commit();
            Transaction act2 = new Transaction(m_myDocument.Document);

            act2.Start(Guid.NewGuid().GetHashCode().ToString());
            m_myDocument.UIDocument.ShowElements(wall);
            act2.Commit();
            return(wall);
        }
Exemplo n.º 25
0
        private static void PutSeatList(Document doc, List <SeatInfo> seatInfos)
        {
            Doc.AutoTransaction(() =>
            {
                foreach (var seatInfo in seatInfos)
                {
                    var offset       = seatInfo.Location - (RefSeat.Location as LocationPoint)?.Point;
                    var cloneSeatIds = ElementTransformUtils.CopyElement(Doc, RefSeat.Id, offset).ToList();

                    if (cloneSeatIds.Count == 0)
                    {
                        MessageBox.Show("Copys the seat, but gets not a seat.");
                        return;
                    }

                    var seat = Doc.GetElement(cloneSeatIds[0]);

                    // Sets the seat some parameters.
                    seat.SetSeatParameters(FillPattern, doc, seatInfo);

                    // Sets the seat fill color.
                    seat.SetColorFill(FillPattern, doc, seatInfo.FillColor);

                    if (!seatInfo.IsRotation)
                    {
                        continue;
                    }

                    var location = seatInfo.Location;
                    var startPt  = new XYZ(location.X, location.Y + seatInfo.Length / 2, 0);
                    var endPt    = new XYZ(location.X, location.Y + seatInfo.Length / 2, 1);
                    var line     = Line.CreateBound(startPt, endPt);

                    // No use mirror, mirror element is very slow.
                    ElementTransformUtils.RotateElement(Doc, seat.Id, line, Math.PI);
                }
            });
        }
Exemplo n.º 26
0
        /// <summary>
        /// Create parallel grids (horizontal or vertical)
        /// </summary>
        /// <param name="basePoint">Top left base point</param>
        /// <param name="spaces">space distances between grids</param>
        /// <param name="startName">Name of the first grid</param>
        /// <param name="isHorizontal">whether this is horizontal or not</param>
        private void createGrids(XYZ basePoint, List <double> spaces, string startName, bool isHorizontal)
        {
            Document doc = _revitApp.ActiveUIDocument.Document;
            double   gridLength = 30, extLength = 3; // Unit: feet

            using (Transaction t = new Transaction(doc, "Create Grids"))
            {
                t.Start();
                XYZ offsetDir  = isHorizontal ? XYZ.BasisY.Multiply(-1) : XYZ.BasisX;
                XYZ startPoint = isHorizontal ? basePoint.Add(XYZ.BasisX.Multiply(-extLength)) : basePoint.Add(XYZ.BasisY.Multiply(extLength));
                XYZ endPoint   = isHorizontal ? startPoint.Add(XYZ.BasisX.Multiply(gridLength)) : startPoint.Add(XYZ.BasisY.Multiply(-gridLength));
                Autodesk.Revit.DB.Line geoLine = Autodesk.Revit.DB.Line.CreateBound(startPoint, endPoint);
                Autodesk.Revit.DB.Grid grid    = Autodesk.Revit.DB.Grid.Create(doc, geoLine);
                grid.Name = startName;
                foreach (double space in spaces)
                {
                    startPoint = startPoint.Add(offsetDir.Multiply(space));
                    endPoint   = endPoint.Add(offsetDir.Multiply(space));
                    geoLine    = Autodesk.Revit.DB.Line.CreateBound(startPoint, endPoint);
                    Autodesk.Revit.DB.Grid.Create(doc, geoLine);
                }
                t.Commit();
            }
        }
Exemplo n.º 27
0
 private static Autodesk.DesignScript.Geometry.Line Convert(Autodesk.Revit.DB.Line crv)
 {
     return(Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(
                crv.GetEndPoint(0).ToPoint(), crv.GetEndPoint(1).ToPoint()));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Dimension by Elements
 /// </summary>
 /// <param name="view"></param>
 /// <param name="line"></param>
 /// <param name="references"></param>
 /// <param name="suffix"></param>
 /// <param name="prefix"></param>
 private Dimension(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Line line, ReferenceArray references, string suffix, string prefix)
 {
     SafeInit(() => Init(view, line, references, suffix, prefix));
 }
Exemplo n.º 29
0
        /// <summary>
        /// try to create a wall. if failed, keep this dialog,
        /// otherwise, close it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                Document document = m_commandData.Application.ActiveUIDocument.Document;
                double   x, y, z;
                Autodesk.Revit.DB.XYZ sPoint;

                //try to convert string to double, and return without closing dialog if failed
                if (Double.TryParse(this.spXTextBox.Text, out x) &&
                    Double.TryParse(this.spYTextBox.Text, out y) &&
                    Double.TryParse(this.spZTextBox.Text, out z))
                {
                    sPoint = new Autodesk.Revit.DB.XYZ(x, y, z);
                }
                else
                {
                    TaskDialog.Show("Revit", "Failed to get the start point.");
                    return;
                }

                //try to convert string to double, and return without closing dialog if failed
                Autodesk.Revit.DB.XYZ ePoint;
                if (Double.TryParse(this.epXTextBox.Text, out x) &&
                    Double.TryParse(this.epYTextBox.Text, out y) &&
                    Double.TryParse(this.epZTextBox.Text, out z))
                {
                    ePoint = new Autodesk.Revit.DB.XYZ(x, y, z);
                }
                else
                {
                    TaskDialog.Show("Revit", "Failed to get the end point.");
                    return;
                }

                if (sPoint.IsAlmostEqualTo(ePoint))
                {
                    TaskDialog.Show("Revit", "The start point and end point cannot have the same location.");
                    return;
                }

                Autodesk.Revit.DB.Line line = Line.CreateBound(sPoint, ePoint);

                Level    level    = this.levelsComboBox.SelectedItem as Level;
                WallType wallType = this.wallTypesComboBox.SelectedItem as WallType;

                //check whether parameters used to create wall are not null
                if (null == line)
                {
                    TaskDialog.Show("Revit", "Create line failed.");
                    return;
                }

                if (null == level || null == wallType)
                {
                    TaskDialog.Show("Revit", "Please select a level and a wall type.");
                    return;
                }

                m_createdWall = Wall.Create(document, line, wallType.Id, level.Id, 10, 0, true, true);
                document.Regenerate();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Revit", ex.Message);
            }
        }
Exemplo n.º 30
0
        private void OK(object sender, RoutedEventArgs e)
        {
            if (txtround.Text == "")
            {
                TaskDialog.Show("ERROR", " Please Enter The Round Value");
                return;
            }
            if (Frame.IsChecked == false && Walls.IsChecked == false && Column.IsChecked == false)
            {
                TaskDialog.Show("ERROR", " Please Select Element Types");
                return;
            }

            Hide();
            Document doc = Singleton.Instance.RevitData.Document;

            Reference gridrefX = Singleton.Instance.RevitData.Selection.PickObject(ObjectType.Element, new GridSelectionFilter(), "Select The First Grid");

            Autodesk.Revit.DB.Grid gridX = doc.GetElement(gridrefX) as Autodesk.Revit.DB.Grid;
            Reference gridrefY           = Singleton.Instance.RevitData.Selection.PickObject(ObjectType.Element, new GridSelectionFilter(), "Select The Second Grid");

            Autodesk.Revit.DB.Grid gridY = doc.GetElement(gridrefY) as Autodesk.Revit.DB.Grid;

            switch (th)
            {
            case th1:
            {
                List <Reference> elemreflist = Singleton.Instance.RevitData.Selection.PickObjects(ObjectType.Element, new BeamSelectionFilter(), "Select Beams") as List <Reference>;
                List <Element>   elemlist    = elemreflist.Select(x => Singleton.Instance.RevitData.Document.GetElement(x) as Autodesk.Revit.DB.Element).ToList();
                elemlist.ForEach(x => Singleton.Instance.WPFData.Elements.Add(x));
                using (Transaction transactionbeam = new Transaction(doc))
                {
                    transactionbeam.Start("Beam Moving");
                    foreach (Element elem in elemlist)
                    {
                        LocationCurve          elemcurve = elem.Location as LocationCurve;
                        Autodesk.Revit.DB.Line elemline  = elemcurve.Curve as Autodesk.Revit.DB.Line;
                        Autodesk.Revit.DB.Line gridlineX = gridX.Curve as Autodesk.Revit.DB.Line;
                        Autodesk.Revit.DB.Line gridlineY = gridY.Curve as Autodesk.Revit.DB.Line;

                        //Kiểm tra và đặt tên Grid, GridX song song với Location.Curve - Line, Grid Y vuông góc,...

                        if (Geometry.GeomUtil.IsSameOrOppositeDirection(elemline.Direction, gridlineY.Direction))
                        {
                            gridX     = doc.GetElement(gridrefY) as Autodesk.Revit.DB.Grid;
                            gridY     = doc.GetElement(gridrefX) as Autodesk.Revit.DB.Grid;
                            gridlineX = gridX.Curve as Autodesk.Revit.DB.Line;
                            gridlineY = gridY.Curve as Autodesk.Revit.DB.Line;
                        }
                        double movedis = Command.GetMoveDistance(elemline, gridX, roundto);
                        // Move dầm phương song song
                        if (movedis > precision)
                        {
                            XYZ movevector1 = new XYZ(-elemline.Direction.Y, elemline.Direction.X, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);
                            elem.Location.Move(movevector1);
                            if (Math.Abs(Command.GetMoveDistance(elemline, gridX, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemline, gridX, roundto) % roundto) < roundto - precision)
                            {
                                elem.Location.Move(-2 * movevector1);
                            }
                        }
                        movedis = Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto);
                        if (movedis >= precision)
                        {
                            XYZ movevector2 = new XYZ(elemline.Direction.X, elemline.Direction.Y, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);
                            elem.Location.Move(movevector2);
                            if (Math.Abs(Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto) % roundto) < (roundto - precision))
                            {
                                elem.Location.Move(-2 * movevector2);
                            }
                        }
                    }
                    transactionbeam.Commit();
                }

                break;
            }

            case th2:
            {
                List <Reference> elemreflist = Singleton.Instance.RevitData.Selection.PickObjects(ObjectType.Element, new StructuralColumnFilter(), "Select Columns") as List <Reference>;
                List <Element>   elemlist    = elemreflist.Select(x => Singleton.Instance.RevitData.Document.GetElement(x) as Autodesk.Revit.DB.Element).ToList();
                elemlist.ForEach(x => Singleton.Instance.WPFData.Elements.Add(x));
                using (Transaction transactioncolumn = new Transaction(doc))
                {
                    transactioncolumn.Start("Column Moving ");
                    foreach (Element elem in elemlist)
                    {
                        LocationPoint elemcurve = elem.Location as LocationPoint;

                        Autodesk.Revit.DB.Line gridlineX = gridX.Curve as Autodesk.Revit.DB.Line;
                        Autodesk.Revit.DB.Line gridlineY = gridY.Curve as Autodesk.Revit.DB.Line;


                        double movedis = Command.GetMoveDistance(elemcurve.Point, gridX, roundto);
                        if (movedis > precision)
                        {
                            XYZ movevector1 = new XYZ(-gridlineX.Direction.Y, gridlineX.Direction.X, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);

                            elem.Location.Move(movevector1);

                            if (Math.Abs(Command.GetMoveDistance(elemcurve.Point, gridX, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemcurve.Point, gridX, roundto) % roundto) < roundto - precision)
                            {
                                elem.Location.Move(-2 * movevector1);
                            }
                        }
                        movedis = Command.GetMoveDistance(elemcurve.Point, gridY, roundto);
                        if (movedis >= precision)
                        {
                            XYZ movevector2 = new XYZ(-gridlineY.Direction.Y, gridlineY.Direction.X, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);

                            //TaskDialog.Show("asas", Command.GetMoveDistance(elemcurve.Point, gridY, roundto).ToString());
                            elem.Location.Move(movevector2);
                            //TaskDialog.Show("asas", Command.GetMoveDistance(elemcurve.Point, gridY, roundto).ToString());
                            if (Math.Abs(Command.GetMoveDistance(elemcurve.Point, gridY, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemcurve.Point, gridY, roundto) % roundto) < (roundto - precision))
                            {
                                elem.Location.Move(-2 * movevector2);
                            }
                        }
                    }
                    transactioncolumn.Commit();
                }

                break;
            }

            case th3:

            {
                List <Reference> elemreflist = Singleton.Instance.RevitData.Selection.PickObjects(ObjectType.Element, new StructuralWallFilter(), "Select Walls") as List <Reference>;
                List <Element>   elemlist    = elemreflist.Select(x => Singleton.Instance.RevitData.Document.GetElement(x) as Autodesk.Revit.DB.Element).ToList();
                elemlist.ForEach(x => Singleton.Instance.WPFData.Elements.Add(x));
                using (Transaction transactionwall = new Transaction(doc))
                {
                    transactionwall.Start("Walls Moving");
                    foreach (Element elem in elemlist)
                    {
                        LocationCurve          elemcurve = elem.Location as LocationCurve;
                        Autodesk.Revit.DB.Line elemline  = elemcurve.Curve as Autodesk.Revit.DB.Line;
                        Autodesk.Revit.DB.Line gridlineX = gridX.Curve as Autodesk.Revit.DB.Line;
                        Autodesk.Revit.DB.Line gridlineY = gridY.Curve as Autodesk.Revit.DB.Line;
                        if (Geometry.GeomUtil.IsSameOrOppositeDirection(elemline.Direction, gridlineY.Direction))
                        {
                            gridX     = doc.GetElement(gridrefY) as Autodesk.Revit.DB.Grid;
                            gridY     = doc.GetElement(gridrefX) as Autodesk.Revit.DB.Grid;
                            gridlineX = gridX.Curve as Autodesk.Revit.DB.Line;
                            gridlineY = gridY.Curve as Autodesk.Revit.DB.Line;
                        }
                        double movedis = Command.GetMoveDistance(elemline, gridX, roundto);
                        if (movedis > precision)
                        {
                            XYZ movevector1 = new XYZ(-elemline.Direction.Y, elemline.Direction.X, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);
                            elem.Location.Move(movevector1);
                            if (Math.Abs(Command.GetMoveDistance(elemline, gridX, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemline, gridX, roundto) % roundto) < roundto - precision)
                            {
                                elem.Location.Move(-2 * movevector1);
                            }
                        }
                        movedis = Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto);

                        if (movedis >= precision)
                        {
                            XYZ movevector2 = new XYZ(elemline.Direction.X, elemline.Direction.Y, 0).Normalize() * Geometry.GeomUtil.milimeter2Feet(movedis);

                            elem.Location.Move(movevector2);
                            if (Math.Abs(Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto) % roundto) > precision && Math.Abs(Command.GetMoveDistance(elemline.GetEndPoint(0), gridY, roundto) % roundto) < (roundto - precision))
                            {
                                elem.Location.Move(-2 * movevector2);
                            }
                        }
                    }
                    transactionwall.Commit();
                }

                break;
            }
            }
        }