Ejemplo n.º 1
0
        /// <summary>
        /// Create Edge (Line or Arc2) from Dynamo Line or Arc.
        /// Used for bar definition.
        /// </summary>
        public static Geometry.Edge FromDynamoLineOrArc2(Autodesk.DesignScript.Geometry.Curve obj)
        {
            // if polyline or similar.
            Autodesk.DesignScript.Geometry.Geometry[] items = obj.Explode();
            if (items.Length != 1)
            {
                throw new System.ArgumentException("Exploded Curve should only have one item.");
            }
            Autodesk.DesignScript.Geometry.Geometry item = items[0];

            // if Arc
            if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.Arc))
            {
                return(Edge.FromDynamoArc2((Autodesk.DesignScript.Geometry.Arc)item));
            }

            // if Line
            else if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.Line))
            {
                return(Edge.FromDynamoLine((Autodesk.DesignScript.Geometry.Line)item));
            }

            else
            {
                throw new System.ArgumentException($"Curve type: {obj.GetType()}, is not Line or Arc.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert a Dynamo Curve to Edge.
        /// </summary>
        /// <param name="obj"></param>
        public static Geometry.Edge FromDynamo(Autodesk.DesignScript.Geometry.Curve obj)
        {
            // if polyline or similar.
            Autodesk.DesignScript.Geometry.Geometry[] items = obj.Explode();
            if (items.Length != 1)
            {
                throw new System.ArgumentException("Exploded Curve should only have one item.");
            }
            Autodesk.DesignScript.Geometry.Geometry item = items[0];

            // if Arc
            if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.Arc))
            {
                // output is a general purpose Edge
                return(Edge.FromDynamoArc1((Autodesk.DesignScript.Geometry.Arc)item));
            }

            // if Circle
            else if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.Circle))
            {
                return(Edge.FromDynamoCircle((Autodesk.DesignScript.Geometry.Circle)item));
            }

            // if Line
            else if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.Line))
            {
                return(Edge.FromDynamoLine((Autodesk.DesignScript.Geometry.Line)item));
            }

            // if NurbsCurve
            else if (item.GetType() == typeof(Autodesk.DesignScript.Geometry.NurbsCurve))
            {
                return(Edge.FromDynamoNurbsCurve((Autodesk.DesignScript.Geometry.NurbsCurve)item));
            }

            // else
            else
            {
                throw new System.ArgumentException($"Curve type: {obj.GetType()}, is not supported for conversion to an Edge.");
            }
        }