Example #1
0
        /// <summary>
        /// Create an Advance Steel Shear Stud Pattern By Circle
        /// </summary>
        /// <param name="circle"> Input Dynamo Circle </param>
        /// <param name="referenceVector"> Input Dynamo Vector for alignment of circle</param>
        /// <param name="objectToConnect"> Object to attached ShearStud </param>
        /// <param name="studLength"> Input Shear Stud Length</param>
        /// <param name="studDiameter"> Input Shear Stud Diameter</param>
        /// <param name="noOfShearStudsInCircle"> Input Number of Shear Stud to be placed in the Circle Pattern</param>
        /// <param name="shearStudConnectionType"> Input Shear Bolt Connection type - Shop Bolt Default</param>
        /// <param name="additionalShearStudParameters"> Optional Input ShearStud Build Properties </param>
        /// <returns name="circularShearStudsPattern"> shear studs</returns>
        public static CircularShearStudsPattern ByCircle(Autodesk.DesignScript.Geometry.Circle circle,
                                                         Autodesk.DesignScript.Geometry.Vector referenceVector,
                                                         SteelDbObject objectToConnect,
                                                         double studLength,
                                                         double studDiameter,
                                                         [DefaultArgument("9;")] int noOfShearStudsInCircle,
                                                         [DefaultArgument("2;")] int shearStudConnectionType,
                                                         [DefaultArgument("null")] List <Property> additionalShearStudParameters)
        {
            var norm = Utils.ToAstVector3d(circle.Normal, true);
            var vx   = Utils.ToAstVector3d(referenceVector, true);
            var vy   = norm.CrossProduct(vx);
            var vz   = norm;

            vx = vx.Normalize();
            vy = vy.Normalize();
            vz = vz.Normalize();

            List <SteelDbObject> tempList = new List <SteelDbObject>()
            {
                objectToConnect
            };
            List <string> handlesList = Utils.GetSteelDbObjectsToConnect(tempList);

            Matrix3d matrix3D = new Matrix3d();

            matrix3D.SetCoordSystem(Utils.ToAstPoint(circle.CenterPoint, true), vx, vy, vz);

            additionalShearStudParameters = PreSetValuesInListProps(additionalShearStudParameters, noOfShearStudsInCircle, Utils.ToInternalDistanceUnits(circle.Radius, true), Utils.ToInternalDistanceUnits(studLength, true), Utils.ToInternalDistanceUnits(studDiameter, true));

            return(new CircularShearStudsPattern(handlesList[0], matrix3D, additionalShearStudParameters, shearStudConnectionType));
        }
        public static PdfAnnotation ToPDFCircle(this Autodesk.DesignScript.Geometry.Circle circle, string content, PdfWriter writer)
        {
            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(
                (float)circle.BoundingBox.MinPoint.X, (float)circle.BoundingBox.MinPoint.Y,
                (float)circle.BoundingBox.MaxPoint.X, (float)circle.BoundingBox.MaxPoint.Y
                );

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateSquareCircle(writer, rect, content, false);

            return(anno);
        }
Example #3
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static PdfAnnotation ToPDFCircle(this Autodesk.DesignScript.Geometry.Circle circle, string content, PdfWriter writer)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(
                (float)circle.BoundingBox.MinPoint.X, (float)circle.BoundingBox.MinPoint.Y,
                (float)circle.BoundingBox.MaxPoint.X, (float)circle.BoundingBox.MaxPoint.Y
                );

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateSquareCircle(writer, rect, content, false);

            return(anno);
        }
Example #4
0
        /// <summary>
        /// Create an Advance Steel Circular Anchor Pattern By Circle
        /// </summary>
        /// <param name="circle"> Input circle</param>
        /// <param name="referenceVector"> Input Dynamo Vector for alignment of circle</param>
        /// <param name="objectsToConnect"> Input Objects to be bolted </param>
        /// <param name="anchorBoltConnectionType"> Input Bolt Connection type - Shop Bolt Default</param>
        /// <param name="additionalAnchorBoltParameters"> Optional Input Bolt Build Properties </param>
        /// <returns name="circularAnchorPattern"> anchor</returns>
        public static CircularAnchorPattern ByCircle(DynGeometry.Circle circle,
                                                     DynGeometry.Vector referenceVector,
                                                     IEnumerable <SteelDbObject> objectsToConnect,
                                                     [DefaultArgument("2;")] int anchorBoltConnectionType,
                                                     [DefaultArgument("null")] List <Property> additionalAnchorBoltParameters)
        {
            var norm = Utils.ToAstVector3d(circle.Normal, true);
            var vx   = Utils.ToAstVector3d(referenceVector, true);
            var vy   = norm.CrossProduct(vx);

            vx = vx.Normalize();
            vy = vy.Normalize();

            List <string> handlesList = Utils.GetSteelDbObjectsToConnect(objectsToConnect);

            additionalAnchorBoltParameters = PreSetValuesInListProps(additionalAnchorBoltParameters, Utils.ToInternalDistanceUnits(circle.Radius, true));
            return(new CircularAnchorPattern(Utils.ToAstPoint(circle.CenterPoint, true), handlesList, vx, vy, additionalAnchorBoltParameters, anchorBoltConnectionType));
        }
Example #5
0
        private static Autodesk.Revit.DB.Arc Convert(Autodesk.DesignScript.Geometry.Circle circ)
        {
            // convert
            var center = circ.CenterPoint.ToXyz(false);
            var sp     = circ.StartPoint.ToXyz(false);

            // get the xaxis of the arc base plane normalized
            var x = (sp - center).Normalize();

            // get a second vector in the plane
            var vecY = (circ.PointAtParameter(0.1).ToXyz(false) - center);

            // get the normal to the plane
            var n2 = x.CrossProduct(vecY).Normalize();

            // obtain the y axis in the plane - perp to x and z
            var y = n2.CrossProduct(x);

            var plane = Autodesk.Revit.DB.Plane.CreateByOriginAndBasis(center, x, y);

            return(Autodesk.Revit.DB.Arc.Create(plane, circ.Radius, 0, 2 * System.Math.PI));
        }
Example #6
0
        private bool Intersects(Circle circle)
        {
            //http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection

            var circleDistX = System.Math.Abs(circle.CenterPoint.X - Bounds.CenterPoint.U);
            var circleDistY = System.Math.Abs(circle.CenterPoint.Y - Bounds.CenterPoint.V);

            if (circleDistX > (Bounds.Width / 2 + circle.Radius)) { return false; }
            if (circleDistY > (Bounds.Height / 2 + circle.Radius)) { return false; }

            if (circleDistX <= (Bounds.Width / 2)) { return true; }
            if (circleDistY <= (Bounds.Height / 2)) { return true; }

            var cornerDistance_sq = System.Math.Pow(circleDistX - Bounds.Width / 2, 2) +
                                 System.Math.Pow(circleDistY - Bounds.Height / 2, 2);

            return (cornerDistance_sq <= System.Math.Pow(circle.Radius, 2));
        }
Example #7
0
        public void ToPDF(iTextSharp.text.pdf.PdfWriter w)
        {
            PdfContentByte cb = w.DirectContent;

            cb.SetLineWidth((float)Settings.Thickness);
            if (Settings.Fill != null)
            {
                cb.SetColorFill(Settings.Fill.ToPDFColor());
            }

            if (Settings.Stroke != null)
            {
                cb.SetColorStroke(Settings.Stroke.ToPDFColor());
            }

            if (Geometry.GetType() == typeof(Dyn.Arc))
            {
                Dyn.Arc arc = Geometry as Dyn.Arc;
                cb.MoveTo(arc.StartPoint.X, arc.EndPoint.Y);
                cb.CurveTo(arc.PointAtParameter(0.5).X, arc.PointAtParameter(0.5).Y, arc.EndPoint.X, arc.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Line))
            {
                Dyn.Line line = Geometry as Dyn.Line;
                cb.MoveTo(line.StartPoint.X, line.StartPoint.Y);
                cb.LineTo(line.EndPoint.X, line.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Circle))
            {
                Dyn.Circle circle = Geometry as Dyn.Circle;
                cb.Circle(circle.CenterPoint.X, circle.CenterPoint.Y, circle.Radius);
            }
            else if (Geometry.GetType() == typeof(Dyn.Ellipse))
            {
                Dyn.Ellipse ellipse = Geometry as Dyn.Ellipse;
                cb.Ellipse(ellipse.StartPoint.X, ellipse.StartPoint.Y, ellipse.EndPoint.X, ellipse.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Rectangle))
            {
                Dyn.Rectangle rect = Geometry as Dyn.Rectangle;
                cb.Rectangle(rect.Center().X, rect.Center().Y, rect.Width, rect.Height);
            }
            else if (Geometry.GetType() == typeof(Dyn.Polygon))
            {
                Dyn.Polygon p = Geometry as Dyn.Polygon;
                foreach (var curve in p.Curves())
                {
                    CurveToPDF(curve, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.PolyCurve))
            {
                Dyn.PolyCurve pc = Geometry as Dyn.PolyCurve;
                foreach (var curve in pc.Curves())
                {
                    CurveToPDF(curve, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.NurbsCurve))
            {
                Dyn.NurbsCurve nc = Geometry as Dyn.NurbsCurve;

                foreach (var linearc in nc.ApproximateWithArcAndLineSegments())
                {
                    CurveToPDF(linearc, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.Curve))
            {
                Dyn.Curve curve = Geometry as Dyn.Curve;
                CurveToPDF(curve, cb);
            }
            else
            {
                throw new Exception(Properties.Resources.NotSupported);
            }

            if (Settings.Fill != null && Settings.Stroke != null)
            {
                cb.FillStroke();
            }
            else
            {
                if (Settings.Stroke != null)
                {
                    cb.Stroke();
                }
                if (Settings.Fill != null)
                {
                    cb.Fill();
                }
            }
        }
 public ExportToDXF AddCircles(Circle[][] circles, string layerName = "0", short ACADcolor = (short) 7)
 {
     CheckLayer(layerName, ACADcolor);
     for (int i = 0; i < circles.Length; i++) for (int j = 0; j < circles[i].Length; j++)
     {
         DXFLibrary.Circle circle = new DXFLibrary.Circle(circles[i][j].CenterPoint.X, circles[i][j].CenterPoint.Y, circles[i][j].Radius, layerName);
         dxf.add(circle);
     }
     return this;
 }