コード例 #1
0
        /// <summary>
        /// Creates the corresponding Dynamo Geometry
        /// </summary>
        /// <param name="geometryPrimitive">type</param>
        /// <search>
        /// create, vector, line, point, dynamo, geometry 3d, primitive
        /// </search>
        public static object Create(object geometryPrimitive)
        {
            if (geometryPrimitive.GetType().ToString() == "dtGeometryPrimitives.Point")
            {
                Point p = geometryPrimitive as Point;
                Autodesk.DesignScript.Geometry.Point dynPoint = Autodesk.DesignScript.Geometry.Point.ByCoordinates(p.X, p.Y, p.Z);
                return(dynPoint);
            }

            if (geometryPrimitive.GetType().ToString() == "dtGeometryPrimitives.Line")
            {
                Line l = geometryPrimitive as Line;
                Autodesk.DesignScript.Geometry.Point startPoint = Autodesk.DesignScript.Geometry.Point.ByCoordinates(l.StartPoint.X, l.StartPoint.Y, l.StartPoint.Z);
                Autodesk.DesignScript.Geometry.Point endPoint   = Autodesk.DesignScript.Geometry.Point.ByCoordinates(l.EndPoint.X, l.EndPoint.Y, l.EndPoint.Z);
                Autodesk.DesignScript.Geometry.Line  dynLine    = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(startPoint, endPoint);
                startPoint.Dispose();
                endPoint.Dispose();
                return(dynLine);
            }
            if (geometryPrimitive.GetType().ToString() == "dtGeometryPrimitives.Vector")
            {
                Vector v = geometryPrimitive as Vector;
                Autodesk.DesignScript.Geometry.Point  startPoint = Autodesk.DesignScript.Geometry.Point.ByCoordinates(v.StartPoint.X, v.StartPoint.Y, v.StartPoint.Z);
                Autodesk.DesignScript.Geometry.Point  endPoint   = Autodesk.DesignScript.Geometry.Point.ByCoordinates(v.EndPoint.X, v.EndPoint.Y, v.EndPoint.Z);
                Autodesk.DesignScript.Geometry.Vector vector     = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(startPoint, endPoint);
                startPoint.Dispose();
                endPoint.Dispose();
                return(vector);
            }
            else
            {
                return("Primitive Type not found");
            }
        }
コード例 #2
0
        internal void GenerateLeftHand(int faceIndex)
        {
            // Generate Lines
            for (int i = 0; i < 4; i++)
            {
                Geo.Line memberLine = GetMemberLineL(faceIndex, i, false);
                this.lines.Add(memberLine);

                // Dispose
                //memberLine.Dispose();
            }

            mesh.faces[faceIndex].visited = true;

            // Propogate
            for (int i = 0; i < 4; i++)
            {
                int adjacentFaceIndex = mesh.GetAdjacentFaceIndex(mesh.faces[faceIndex], i);

                if (adjacentFaceIndex >= 0 && !mesh.faces[adjacentFaceIndex].visited)
                {
                    GenerateRightHand(adjacentFaceIndex);
                }
            }
        }
コード例 #3
0
        public void IsLineLike_Curve_CorrectlyIdentifiesLine()
        {
            var line = Line.ByStartPointEndPoint(
                Point.Origin(),
                Point.ByCoordinates(12, 3, 2));

            var revitCurve = line.ToRevitType(false);

            Assert.True(CurveUtils.IsLineLike(revitCurve));
        }
コード例 #4
0
        public void ByParameterOnCurveReference_ShouldPlaceReferencePointCorrectly()
        {
            var l          = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0));
            var modelCurve = ModelCurve.ByCurve(l);
            var rp         = ReferencePoint.ByParameterOnCurveReference(modelCurve.ElementCurveReference, 0.5);

            var pt = Point.ByCoordinates(0.5, 0, 0);

            rp.Point.ShouldBeApproximately(pt);
            InternalPosition(rp).ShouldBeApproximately(pt.InHostUnits());
        }
コード例 #5
0
 protected RevolvedSurface(Curve profile, Line axis, double startAngle, double sweepAngle, bool persist)
     : base(ByProfileAxisAngleCore(profile, axis, startAngle, sweepAngle), persist)
 {
     InitializeGuaranteedProperties();
     Profile = profile;
     AxisOrigin = axis.StartPoint;
     AxisDirection = axis.Direction;
     StartAngle = startAngle;
     SweepAngle = sweepAngle;
     Axis = axis;
 }
コード例 #6
0
        public static PdfAnnotation ToPDFLine(this Autodesk.DesignScript.Geometry.Line line, string content, PdfWriter writer)
        {
            var start = line.StartPoint.ToPDFCoords();
            var end   = line.EndPoint.ToPDFCoords();

            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(start.X, start.Y);

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateLine(writer, rect, content, start.X, start.Y, end.X, end.Y);

            return(anno);
        }
コード例 #7
0
        /// <summary>
        /// Sort a series of curves in the shortest printing path.
        /// </summary>
        /// <param name="_curves"></param>
        /// <returns name="Curves"></returns>
        public static List <Autodesk.DesignScript.Geometry.Curve> SortPrintableCurves(List <Autodesk.DesignScript.Geometry.Curve> _curves)
        {
            List <Autodesk.DesignScript.Geometry.Curve> sortedCurves = new List <Autodesk.DesignScript.Geometry.Curve>();
            List <Autodesk.DesignScript.Geometry.Curve> curves       = new List <Autodesk.DesignScript.Geometry.Curve>();

            curves.AddRange(_curves); // Copying elements to curves to avoid modifying the original list of curves

            Autodesk.DesignScript.Geometry.Curve currentCurve = curves[curves.Count - 1];
            curves.RemoveAt(curves.Count - 1);
            sortedCurves.Add(currentCurve);

            // find ouf next curve either startpoint or endpoint is closest to the end point of the current curve

            while (curves.Count != 0)
            {
                int    bestI        = 0;
                double bestDistance = double.MaxValue;
                Autodesk.DesignScript.Geometry.Point currentPoint = currentCurve.EndPoint;
                for (int i = 0; i < curves.Count; ++i)
                {
                    Autodesk.DesignScript.Geometry.Curve c = curves[i];

                    Autodesk.DesignScript.Geometry.Line l1 = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(currentPoint, c.StartPoint);
                    Autodesk.DesignScript.Geometry.Line l2 = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(currentPoint, c.EndPoint);

                    double distanceToStartPoint = l1.Length;
                    double distanceToEndPoint   = l2.Length;

                    double d = Math.Min(distanceToStartPoint, distanceToEndPoint);

                    if (bestDistance > d)
                    {
                        bestI        = i;
                        bestDistance = d;
                    }
                }

                currentCurve = curves[bestI];
                curves.RemoveAt(bestI);

                double distanceToCurrentCurveEndPoint   = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(currentPoint, currentCurve.EndPoint).Length;
                double distanceToCurrentCurveStartPoint = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(currentPoint, currentCurve.StartPoint).Length;

                if (distanceToCurrentCurveEndPoint < distanceToCurrentCurveStartPoint)
                {
                    currentCurve = currentCurve.Reverse();
                }

                sortedCurves.Add(currentCurve);
            }

            return(sortedCurves);
        }
コード例 #8
0
        internal void Setup()
        {
            _currentParameter = 0.5;

            Geo.Vector edgeVector = Geo.Vector.ByTwoPoints(_edge.StartPoint, _edge.EndPoint);
            _lineDirectionA = _faceNormalA.Cross(edgeVector);
            _lineDirectionB = (_isNaked) ? null : _faceNormalB.Cross(edgeVector);
            _lineA          = Geo.Line.ByStartPointDirectionLength(_edge.PointAtParameter(_currentParameter), _lineDirectionA, 1);
            _lineB          = (_isNaked) ? null : Geo.Line.ByStartPointDirectionLength(_edge.PointAtParameter(_currentParameter), _lineDirectionB, 1);

            _isFlat = (_isNaked) ? false : _faceNormalA.Normalized().Dot(_faceNormalB.Normalized()) == 1;
        }
コード例 #9
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static PdfAnnotation ToPDFLine(this Autodesk.DesignScript.Geometry.Line line, string content, PdfWriter writer)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            var start = line.StartPoint.ToPDFCoords();
            var end   = line.EndPoint.ToPDFCoords();

            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(start.X, start.Y);

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateLine(writer, rect, content, start.X, start.Y, end.X, end.Y);

            return(anno);
        }
コード例 #10
0
ファイル: FamilyInstances.cs プロジェクト: jpahlow/archilab
        /// <summary>
        /// New Family Instance by Curve
        /// </summary>
        /// <param name="familyType">Family Type to be applied to new Family Instance.</param>
        /// <param name="line">Line to place Family Instance at.</param>
        /// <param name="level">Level to associate Family Instance with.</param>
        /// <returns>New Family Instance.</returns>
        public static Element ByLine(FamilyType familyType, Line line, Level level)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException(nameof(familyType));
            }

            var symbol       = familyType.InternalElement as Autodesk.Revit.DB.FamilySymbol;
            var locationLine = line.ToRevitType() as Autodesk.Revit.DB.Line;
            var hostLevel    = level.InternalElement as Autodesk.Revit.DB.Level;

            return(new FamilyInstances(symbol, locationLine, hostLevel));
        }
コード例 #11
0
        public void ByLengthOnCurveReference_ShouldPlaceReferencePointCorrectly()
        {
            var l          = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0));
            var modelCurve = ModelCurve.ByCurve(l);
            var rp         = ReferencePoint.ByLengthOnCurveReference(modelCurve.ElementCurveReference, 0.5);

            DocumentManager.Instance.CurrentDBDocument.Regenerate();

            var pt = Point.ByCoordinates(0.5, 0, 0);

            rp.Point.ShouldBeApproximately(pt);
            InternalPosition(rp).ShouldBeApproximately(pt.InHostUnits());
        }
コード例 #12
0
        /// <summary>
        /// Create a Revit Grid Element in a Project along a Line.
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static Grid ByLine(Autodesk.DesignScript.Geometry.Line line)
        {
            if (Document.IsFamilyDocument)
            {
                throw new Exception("A Grid Element can only be created in a Revit Project");
            }

            if (line == null)
            {
                throw new ArgumentNullException("line");
            }

            return(new Grid((Autodesk.Revit.DB.Line)line.ToRevitType()));
        }
コード例 #13
0
 internal hMember(hMember member)
 {
     _webAxis   = member._webAxis;
     _webNormal = member._webNormal;
     _name      = member._name;
     foreach (hConnection con in member.connections)
     {
         this.connections.Add(con);
     }
     foreach (hOperation op in member.operations)
     {
         this.operations.Add(op);
     }
 }
コード例 #14
0
 public List <Geo.Line> GetFlangeAxes()
 {
     Geo.Point  OP1         = _webAxis.StartPoint;
     Geo.Point  OP2         = _webAxis.EndPoint;
     Geo.Vector webAxisVec  = Geo.Vector.ByTwoPoints(OP1, OP2);
     Geo.Vector normal      = _webNormal.Normalized().Scale(0.75);;
     Geo.Vector lateral     = webAxisVec.Cross(normal).Normalized().Scale(1.75);
     Geo.Line   flangeLine1 = Geo.Line.ByStartPointEndPoint(OP1.Add(normal.Add(lateral)), OP2.Add(normal.Add(lateral)));
     lateral = webAxisVec.Cross(normal).Normalized().Scale(-1.75);
     Geo.Line flangeLine2 = Geo.Line.ByStartPointEndPoint(OP1.Add(normal.Add(lateral)), OP2.Add(normal.Add(lateral)));
     return(new List <Geo.Line> {
         flangeLine1, flangeLine2
     });
 }
コード例 #15
0
        public void MinDistanceTest2()
        {
            Geo.Point p1 = Geo.Point.ByCoordinates(0, 0, 0);
            Geo.Point p2 = Geo.Point.ByCoordinates(1, 1, 1);
            Geo.Point p3 = Geo.Point.ByCoordinates(-1, 0, 0);
            Geo.Point p4 = Geo.Point.ByCoordinates(-2, -2, -2);

            Geo.Line l1 = Geo.Line.ByStartPointEndPoint(p1, p2);
            Geo.Line l2 = Geo.Line.ByStartPointEndPoint(p3, p4);

            double d = hStructure.MinDistanceBetweenLines(l1, l2);


            Assert.AreEqual(1, d);
        }
コード例 #16
0
        /// <summary>
        /// Extend member by changing web axis end point. Adjust operations accordingly.
        /// </summary>
        /// <param name="newEndPoint"></param>
        internal void SetWebAxisEndPoint(Geo.Point newEndPoint)
        {
            // Create new axis
            Geo.Line newAxis = Geo.Line.ByStartPointEndPoint(_webAxis.StartPoint, newEndPoint);

            // Compute new locations for operations relative to new axis
            foreach (hOperation op in operations)
            {
                Geo.Point opPoint = _webAxis.PointAtParameter(op._loc / _webAxis.Length);
                double    newLoc  = newAxis.ParameterAtPoint(opPoint) * newAxis.Length;
                op._loc = newLoc;
            }

            // Set new axis
            _webAxis = newAxis;
        }
コード例 #17
0
        internal bool IsLineCurve(Dyn.Curve c)
        {
            double lenC = c.Length;

            Dyn.Line ln   = Dyn.Line.ByStartPointEndPoint(c.StartPoint, c.EndPoint);
            double   lenL = ln.Length;

            ln.Dispose();
            if (Math.Abs(lenC - lenL) < 0.001)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #18
0
        /// <summary>
        /// Create an Advance Steel Bar Grating
        /// </summary>
        /// <param name="line"> Input Dynamo Line</param>
        /// <param name="planeDirection"> Input Dynamo Vector to set Normal of Grating</param>
        /// <param name="additionalGratingParameters"> Optional Input Grating Build Properties </param>
        /// <returns name="barGrating"> grating</returns>
        public static BarGrating ByLine(Autodesk.DesignScript.Geometry.Line line,
                                        Autodesk.DesignScript.Geometry.Vector planeDirection,
                                        [DefaultArgument("null")] List <Property> additionalGratingParameters)
        {
            var start     = Utils.ToAstPoint(line.StartPoint, true);
            var end       = Utils.ToAstPoint(line.EndPoint, true);
            var refPoint  = start + (end - start) * 0.5;
            var planeNorm = Utils.ToAstVector3d(planeDirection, true);

            if (!planeNorm.IsPerpendicularTo(Utils.ToAstVector3d(line.Direction, true)))
            {
                throw new System.Exception("Plan Direction must be perpendicular to line");
            }

            additionalGratingParameters = PreSetDefaults(additionalGratingParameters);
            return(new BarGrating(planeNorm, refPoint, Utils.ToInternalDistanceUnits(line.Length, true), additionalGratingParameters));
        }
コード例 #19
0
        public void CurvesAreSimilar_Lines()
        {
            var a = Point.ByCoordinates(0, 0);
            var b = Point.ByCoordinates(1, 1);
            var c = Point.ByCoordinates(2, 2);

            var line1 = Line.ByStartPointEndPoint(a, b);
            var line2 = Line.ByStartPointEndPoint(b, a);
            var line3 = Line.ByStartPointEndPoint(a, c);

            var revitLine1 = line1.ToRevitType();
            var revitLine2 = line2.ToRevitType();
            var revitLine3 = line3.ToRevitType();

            Assert.True(CurveUtils.CurvesAreSimilar(revitLine1, revitLine1));
            Assert.False(CurveUtils.CurvesAreSimilar(revitLine1, revitLine2));
            Assert.False(CurveUtils.CurvesAreSimilar(revitLine1, revitLine3));
        }
コード例 #20
0
ファイル: FamilyInstance.cs プロジェクト: ziter05/DynamoRevit
        /// <summary>
        /// Place a Revit family instance of the given the FamilyType (also known as the FamilySymbol in the Revit API)
        /// on a surface derived from a backing Revit face as reference and a line as reference for its position.
        ///
        /// Note: The FamilyPlacementType must be CurveBased and the input surface must be created from a Revit Face
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="face">Surface geometry derived from a Revit face as reference element</param>
        /// <param name="line">A line on the face defining where the symbol is to be placed</param>
        /// <returns>FamilyInstance</returns>
        public static FamilyInstance ByFace(FamilyType familyType, Surface face, Autodesk.DesignScript.Geometry.Line line)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }
            if (face == null)
            {
                throw new ArgumentNullException("face");
            }
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }
            var reference = ElementFaceReference.TryGetFaceReference(face);

            return(new FamilyInstance(familyType.InternalFamilySymbol, reference.InternalReference, (Autodesk.Revit.DB.Line)line.ToRevitType()));
        }
コード例 #21
0
 /// <summary>
 /// Convert curve to PDF
 /// </summary>
 /// <param name="curve"></param>
 /// <param name="cb"></param>
 private void CurveToPDF(Dyn.Curve curve, PdfContentByte cb)
 {
     if (curve.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.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
     {
         cb.MoveTo(curve.StartPoint.X, curve.StartPoint.Y);
         cb.LineTo(curve.EndPoint.X, curve.EndPoint.Y);
     }
 }
コード例 #22
0
        internal sCurve TosCurve(Dyn.Curve dc)
        {
            sCurve sc = null;

            Dyn.Line dl = dc as Dyn.Line;
            if (dl != null)
            {
                sc           = TosLine(dl);
                sc.curveType = eCurveType.LINE;
                dl.Dispose();
            }
            Dyn.PolyCurve pc = dc as Dyn.PolyCurve;
            if (pc != null)
            {
                if (pc.NumberOfCurves == 1)
                {
                    ////
                    //what if this segement is nurbsCurve??????
                    //PolyCurve can be joined nurbsCurve!!!!!!!!!

                    ///
                    Dyn.Line dtl = Dyn.Line.ByStartPointEndPoint(pc.StartPoint, pc.EndPoint);
                    sc           = TosLine(dtl);
                    sc.curveType = eCurveType.LINE;
                    dtl.Dispose();
                }
                else
                {
                    sc           = TosPolyLine(pc);
                    sc.curveType = eCurveType.POLYLINE;
                }
                pc.Dispose();
            }
            // Dyn.NurbsCurve nc = dc as Dyn.NurbsCurve;
            // if(nc != null)
            // {
            //
            // }

            return(sc);
        }
コード例 #23
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // 【利用Dynamo库创建弧线】
            DyGeometry.Point point1 = DyGeometry.Point.ByCoordinates(0, 0, 0);
            DyGeometry.Point point2 = DyGeometry.Point.ByCoordinates(0, 5, 3);
            DyGeometry.Point point3 = DyGeometry.Point.ByCoordinates(0, 10, 0);
            DyGeometry.Arc   arc1   = DyGeometry.Arc.ByThreePoints(point1, point2, point3);
            // 【利用Dynamo创建直线】
            DyGeometry.Point point4 = DyGeometry.Point.ByCoordinates(10, 10, 0);
            DyGeometry.Point point5 = DyGeometry.Point.ByCoordinates(10, 0, 0);
            DyGeometry.Line  line1  = DyGeometry.Line.ByStartPointEndPoint(point4, point5);
            // 【利用Dynamo在直线和弧线之间创建连接线】
            DyGeometry.Curve curve1 = DyGeometry.Curve.ByBlendBetweenCurves(arc1, line1);
            // 【利用Dynamo获取生成的连接线上的某个点】
            DyGeometry.Point outPoint = curve1.PointAtSegmentLength(3);
            // 【转化为Revit的坐标点】
            XYZ result = new XYZ(outPoint.X / 0.3048, outPoint.Y / 0.3048, outPoint.Z / 0.3048);

            // 【输出生成的结果】
            TaskDialog.Show("Result", $"X:{result.X.ToString("0.00")}-Y:{result.Y.ToString("0.00")}-Z:{result.Z.ToString("0.00")}");
            return(Result.Succeeded);
        }
コード例 #24
0
ファイル: Surface.cs プロジェクト: samuto/designscript
 /// <summary>
 /// Construct a Surface by revolving curve about a line axis. Assuming 
 /// sweep angle = 360 and start angle = 0.
 /// </summary>
 /// <param name="profile">Profile Curve for revolve surface.</param>
 /// <param name="axis">Line to define axis of revolution.</param>
 /// <returns>SRevolvedSurface</returns>
 public static RevolvedSurface Revolve(Curve profile, Line axis)
 {
     return RevolvedSurface.ByProfileAxis(profile, axis);
 }
コード例 #25
0
        internal void SplitSegmentizesBeamSet(ref List <sFrameSet> beamset, double intTol, double segTol, List <object> pointEle = null)
        {
            List <Dyn.Geometry> disposeGeo = new List <Dyn.Geometry>();
            List <Dyn.Curve>    allCrvs    = new List <Dyn.Curve>();

            foreach (sFrameSet bs in beamset)
            {
                bs.frames.Clear();
                Dyn.Curve c = ToDynamoCurve(bs.parentCrv);
                allCrvs.Add(c);
                disposeGeo.Add(c);
            }

            List <Dyn.Point> pts = new List <Dyn.Point>();

            if (pointEle != null)
            {
                foreach (object eb in pointEle)
                {
                    sPointLoad pl = eb as sPointLoad;
                    if (pl != null)
                    {
                        Dyn.Point p = ToDynamoPoint(pl.location);
                        pts.Add(p);
                        disposeGeo.Add(p);
                    }
                    sPointSupport ps = eb as sPointSupport;
                    if (ps != null)
                    {
                        Dyn.Point p = ToDynamoPoint(ps.location);
                        pts.Add(p);
                        disposeGeo.Add(p);
                    }
                }
            }
            if (pts.Count == 0)
            {
                pts = null;
            }

            foreach (sFrameSet bs in beamset)
            {
                Dyn.Curve            dc = ToDynamoCurve(bs.parentCrv);
                int                  id = 0;
                List <Dyn.PolyCurve> segCrvs;
                List <Dyn.Point>     assPts;
                List <Dyn.PolyCurve> segPlns = SplitSegmentizeCurveByCurves(dc, allCrvs, intTol, segTol, out segCrvs, out assPts, pts);

                if (segPlns.Count > 0)
                {
                    for (int i = 0; i < segPlns.Count; ++i)
                    {
                        if (segCrvs.Count > 1)
                        {
                            bs.parentSegments.Add(TosCurve(segCrvs[i]));
                            disposeGeo.Add(segCrvs[i]);
                        }

                        Dyn.Curve [] segs = segPlns[i].Curves();
                        for (int j = 0; j < segs.Length; ++j)
                        {
                            if (segs[j].Length > 0.005)
                            {
                                Dyn.Line dl = Dyn.Line.ByStartPointEndPoint(segs[j].StartPoint, segs[j].EndPoint);
                                bs.AddBeamElement(TosLine(dl), sXYZ.Zaxis(), id);
                                id++;
                                disposeGeo.Add(dl);
                            }
                            disposeGeo.Add(segs[j]);
                        }
                        disposeGeo.Add(segPlns[i]);
                    }
                    if (assPts != null)
                    {
                        bs.associatedLocations = new List <sXYZ>();
                        foreach (Dyn.Point ap in assPts)
                        {
                            bs.associatedLocations.Add(TosXYZ(ap));
                            disposeGeo.Add(ap);
                        }
                    }
                }
                else
                {
                    Dyn.Line dl = Dyn.Line.ByStartPointEndPoint(dc.StartPoint, dc.EndPoint);
                    if (dl.Length > 0.005)
                    {
                        bs.AddBeamElement(TosLine(dl), sXYZ.Zaxis(), id);
                        bs.EnsureBeamElement();
                        id++;
                    }
                    disposeGeo.Add(dl);
                }

                bs.AwareElementsFixitiesByParentFixity(intTol);

                disposeGeo.Add(dc);
            }

            this.DisposeGeometries(disposeGeo);
        }
コード例 #26
0
 internal sLine TosLine(Dyn.Line dyln)
 {
     return(new sLine(TosXYZ(dyln.StartPoint), TosXYZ(dyln.EndPoint)));
 }
コード例 #27
0
 public static HM.Line DSLineToHMLine(Geo.Line l)
 {
     return(new HM.Line(PointToTriple(l.StartPoint), PointToTriple(l.EndPoint)));
 }
コード例 #28
0
ファイル: Curve.cs プロジェクト: samuto/designscript
        /// <summary>
        /// def RevolveAsSurface : Surface (axis : Line, startAngle : double, sweepAngle : double)
        /// 
        /// Returns a Surface by revolving this curve about a line axis. 
        /// startAngle determines where the curve starts to revolve, sweepAngle
        /// determines the revolving angle.
        /// </summary>
        /// <param name="axis">Line curve as axis of revolution</param>
        /// <param name="startAngle">Start angle in degrees</param>
        /// <param name="sweepAngle">Sweep angle for rotation in degrees</param>
        /// <returns>Revolved Surface</returns>
        public Surface RevolveAsSurface(Line axis, double startAngle, double sweepAngle)
        {
            if (axis == null)
                throw new System.ArgumentNullException("axis");
            else if (axis.Length.EqualsTo(0.0))
                throw new System.ArgumentException(Properties.Resources.IsZeroLength, "axis");
            else if (sweepAngle.EqualsTo(0.0))
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroAngle, "sweep"), "sweepAngle");

            return Surface.Revolve(this, axis, startAngle, sweepAngle);
        }
コード例 #29
0
 internal hMember(Geo.Line webAxis, Geo.Vector webNormal, string name = "0")
 {
     _webAxis   = webAxis;
     _webNormal = webNormal;
     _name      = name;
 }
コード例 #30
0
ファイル: Cone.cs プロジェクト: samuto/designscript
 protected Cone(Line centerLine, double startRadius, double endRadius, bool persist)
     : base(ByCenterLineRadiusCore(centerLine, startRadius, endRadius), persist)
 {
     InitializeGuaranteedProperties();
     CenterLine = centerLine;
 }
コード例 #31
0
ファイル: Cone.cs プロジェクト: samuto/designscript
        private static IConeEntity ByCenterLineRadiusCore(Line centerLine, double startRadius, double endRadius)
        {
            if (null == centerLine)
                throw new System.ArgumentNullException("centerLine");

            IConeEntity entity = ByStartPointEndPointRadiusCore(centerLine.StartPoint, centerLine.EndPoint, startRadius, endRadius);
            return entity;
        }
コード例 #32
0
ファイル: Curve.cs プロジェクト: samuto/designscript
 /// <summary>
 /// def RevolveAsSolid : Solid (axis : Line)
 /// 
 /// Returns a Solid by revolving the closed curve about a given axis 
 /// line by 360 revolution.
 /// </summary>
 /// <param name="axis">Line curve as axis of revolution</param>
 /// <returns>Revolved Solid</returns>
 public Solid RevolveAsSolid(Line axis)
 {
     return RevolveAsSolid(axis, 0.0, 360.0);
 }
コード例 #33
0
 /// <summary>
 /// Construct a Surface by revolving  curve about a line axis. startAngle 
 /// determines where the curve starts to revolve, sweepAngle determines 
 /// the revolving angle.
 /// </summary>
 /// <param name="profile">Profile Curve for revolve surface.</param>
 /// <param name="axis">Line to define axis of revolution.</param>
 /// <param name="startAngle">Start Angle in degreee at which curve starts to revolve.</param>
 /// <param name="sweepAngle">Sweep Angle in degree to define the extent of revolve.</param>
 /// <returns>RevolvedSurface</returns>
 public static RevolvedSurface ByProfileAxisAngle(Curve profile, Line axis, double startAngle, double sweepAngle)
 {
     return new RevolvedSurface(profile, axis, startAngle, sweepAngle, true);
 }
コード例 #34
0
ファイル: DtoN.cs プロジェクト: lulzzz/Nucleus
 /// <summary>
 /// Convert a DesignScript line to a Nucleus line
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public static Line Convert(DS.Line line)
 {
     return(new Line(Convert(line.StartPoint), Convert(line.EndPoint)));
 }
コード例 #35
0
 private static ISurfaceEntity ByProfileAxisAngleCore(Curve profile, Line axis, double startAngle, double sweepAngle)
 {
     if (null == axis)
         throw new System.ArgumentNullException("axis");
     ISurfaceEntity surf = ByProfileAxisOriginDirectionAngleCore(profile, axis.StartPoint, axis.Direction, startAngle, sweepAngle);
     if (null == surf)
         throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "RevolvedSurface.ByProfileAxisAngle"));
     return surf;
 }
コード例 #36
0
ファイル: Curve.cs プロジェクト: samuto/designscript
        /// <summary>
        /// def RevolveAsSurface : Surface (axis : Line)
        /// 
        /// Returns a Surface by revolving this curve about a line axis. 
        /// Assuming sweep angle = 360 and start angle = 0.
        /// </summary>
        /// <param name="axis">Line curve as axis of revolution</param>
        /// <returns>Revolved Surface</returns>
        public Surface RevolveAsSurface(Line axis)
        {
            if (axis == null)
                throw new System.ArgumentNullException("axis");
            else if (axis.Length.EqualsTo(0.0))
                throw new System.ArgumentException(Properties.Resources.IsZeroLength, "axis");

            return Surface.Revolve(this, axis);
        }
コード例 #37
0
 /// <summary>
 /// Construct a Surface by revolving curve about a line axis. Assuming 
 /// sweep angle = 360 and start angle = 0.
 /// </summary>
 /// <param name="profile">Profile Curve for revolve surface.</param>
 /// <param name="axis">Line to define axis of revolution.</param>
 /// <returns>Surface of revolution.</returns>
 public static RevolvedSurface ByProfileAxis(Curve profile, Line axis)
 {
     return new RevolvedSurface(profile, axis, 0, 360, true);
 }
コード例 #38
0
 private static Autodesk.Revit.DB.Line Convert(Autodesk.DesignScript.Geometry.Line line)
 {
     return(Autodesk.Revit.DB.Line.CreateBound(line.StartPoint.ToXyz(false), line.EndPoint.ToXyz(false)));
 }
コード例 #39
0
 internal void SetLines()
 {
     _lineA = Geo.Line.ByStartPointDirectionLength(_edge.PointAtParameter(_currentParameter), _lineDirectionA, 1);
     _lineB = (_isNaked) ? null : Geo.Line.ByStartPointDirectionLength(_edge.PointAtParameter(_currentParameter), _lineDirectionB, 1);
 }
コード例 #40
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();
                }
            }
        }
コード例 #41
0
ファイル: Cone.cs プロジェクト: samuto/designscript
 /// <summary>
 /// Constructs a solid cone defined by a line the start and end radii of its base and top respectively.
 /// </summary>
 /// <param name="centerLine">The center line of the cone</param>
 /// <param name="startRadius">The radius of the base of the cone</param>
 /// <param name="endRadius">The radius of the top of the cone</param>
 /// <returns></returns>
 public static Cone ByCenterLineRadius(Line centerLine, double startRadius, double endRadius)
 {
     return new Cone(centerLine, startRadius, endRadius, true);
 }
コード例 #42
0
ファイル: Curve.cs プロジェクト: samuto/designscript
        /// <summary>
        /// def RevolveAsSolid : Solid (axis : Line, startAngle : double, sweepAngle : double)
        /// 
        /// Returns a Solid by revolving the closed curve about a given axis 
        /// line. startAngle determines where the curve starts to revolve, 
        /// sweepAngle determines the revolving angle.
        /// </summary>
        /// <param name="axis">Line curve as axis of revolution</param>
        /// <param name="startAngle">Start angle in degrees</param>
        /// <param name="sweepAngle">Sweep angle for rotation in degrees</param>
        /// <returns>Revolved Solid</returns>
        public Solid RevolveAsSolid(Line axis, double startAngle, double sweepAngle)
        {
            if (!IsClosed)
                throw new System.InvalidOperationException(Properties.Resources.CurveNotClosed);
            else if (!IsPlanar)
                throw new System.InvalidOperationException(Properties.Resources.CurveNotPlanar);
            else if (axis == null)
                throw new System.ArgumentNullException("axis");
            else if (axis.Length.EqualsTo(0.0))
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroLength, "axis length"), "axis");

            return Solid.Revolve(this, axis, startAngle, sweepAngle);
        }