// Rh Capture?
        public static Rhino.Geometry.Point ToNative(this SpecklePoint pt)
        {
            var myPoint = new Rhino.Geometry.Point(new Point3d(pt.Value[0], pt.Value[1], pt.Value[2]));

            myPoint.UserDictionary.ReplaceContentsWith(pt.Properties.ToNative());
            return(myPoint);
        }
示例#2
0
        public static void SetAxis(SpeckleVector xVector, SpeckleVector xyVector, SpecklePoint origin, int Index, out string gwaCommand, string name = "")
        {
            gwaCommand = "";

            var gwaCommands = new List <string>();

            var ls = new List <string>()
            {
                "SET",
                "AXIS.1",
                Index.ToString(),
                name ?? "",
                "CART",

                origin.Value[0].ToString(),
                origin.Value[1].ToString(),
                origin.Value[2].ToString(),

                xVector.Value[0].ToString(),
                xVector.Value[1].ToString(),
                xVector.Value[2].ToString(),

                xyVector.Value[0].ToString(),
                xyVector.Value[1].ToString(),
                xyVector.Value[2].ToString(),
            };

            gwaCommand = (string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
示例#3
0
        public static void SetAxis(SpeckleVector xVector, SpeckleVector xyVector, SpecklePoint origin, out int index, out string gwaCommand, string name = "")
        {
            gwaCommand = "";
            index      = Initialiser.Cache.ResolveIndex("AXIS.1");

            var gwaCommands = new List <string>();

            var ls = new List <string>()
            {
                "SET",
                "AXIS.1",
                index.ToString(),
                name ?? "",
                "CART",

                origin.Value[0].ToString(),
                origin.Value[1].ToString(),
                origin.Value[2].ToString(),

                xVector.Value[0].ToString(),
                xVector.Value[1].ToString(),
                xVector.Value[2].ToString(),

                xyVector.Value[0].ToString(),
                xyVector.Value[1].ToString(),
                xyVector.Value[2].ToString(),
            };

            gwaCommand = (string.Join("\t", ls));
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public static SpeckleUnityPoint ToNative(this SpecklePoint point)
        {
            point.Scale(scaleFactor);

            Vector3 newPt = ToPoint(point.Value.ToArray());

            return(new SpeckleUnityPoint(point.Type, newPt));
        }
        public static BeamJoint FromSpeckle(SpecklePoint BasePt)
        {
            var bj = new BeamJoint();

            bj.IntersectionPoint = BasePt.ToRhino();
            bj.A = BeamBase.FromSpeckle((SpeckleBrep)BasePt.Properties["BeamA"]);
            bj.B = BeamBase.FromSpeckle((SpeckleBrep)BasePt.Properties["BeamB"]);
            return(bj);
        }
        public SpecklePoint ToSpeckle()
        {
            SpecklePoint basePt = IntersectionPoint.ToSpeckle();

            basePt.Properties[GlobalVar.discriminator] = "BeamJoint";
            basePt.Properties["BeamA"] = A.ToSpeckle();
            basePt.Properties["BeamB"] = B.ToSpeckle();

            return(basePt);
        }
示例#7
0
        public static SpecklePoint ToSpeckle(this BHG.Point bhomPoint)
        {
            if (bhomPoint == null)
            {
                return(default(SpecklePoint));
            }

            SpecklePoint specklePoint = new SpecklePoint(bhomPoint.X, bhomPoint.Y, bhomPoint.Z);

            return(specklePoint);
        }
示例#8
0
    public static GameObject ToNative(this SpecklePoint pt)
    {
        GameObject go = BaseObejct();

        go.GetComponent <UnitySpeckleObjectData>().Id = pt._id;
        //go.GetComponent<UnitySpeckleObjectData>().LayerName = (string)pt.Properties["LayerName"];

        go.GetComponent <MeshFilter>().mesh = CreatePrimitiveMesh(PrimitiveType.Sphere);
        go.transform.localScale             = new Vector3(0.02f, 0.02f, 0.02f);

        go.transform.position = ToPoint(pt.Value[0], pt.Value[1], pt.Value[2]);
        return(go);
    }
        public static string ToNative(this SpecklePoint inputObject)
        {
            var convertedObject = new StructuralNode();

            foreach (var p in convertedObject.GetType().GetProperties().Where(p => p.CanWrite))
            {
                var inputProperty = inputObject.GetType().GetProperty(p.Name);
                if (inputProperty != null)
                {
                    p.SetValue(convertedObject, inputProperty.GetValue(inputObject));
                }
            }

            return(convertedObject.ToNative());
        }
示例#10
0
    public static string ToNative(this SpecklePoint inputObject)
    {
      return SchemaConversion.Helper.ToNativeTryCatch(inputObject, () =>
      {
        var convertedObject = new StructuralNode();

        foreach (var p in convertedObject.GetType().GetProperties().Where(p => p.CanWrite))
        {
          var inputProperty = inputObject.GetType().GetProperty(p.Name);
          if (inputProperty != null)
            p.SetValue(convertedObject, inputProperty.GetValue(inputObject));
        }

        return convertedObject.ToNative();
      });
    }
    public static GameObject ToNative(this SpecklePoint pt)
    {        
        GameObject go = BasePointObject();
        
        go.GetComponent<UnitySpeckleObjectData>().Id = pt._id;
        go.GetComponent<UnitySpeckleObjectData>().speckleObject = pt;

        

        Vector3 newPoint = ToPoint(pt.Value[0], pt.Value[1], pt.Value[2]);
        Vector3[] pts = new Vector3[] { newPoint, newPoint };

        go.GetComponent<LineRenderer>().positionCount = 2;
        go.GetComponent<LineRenderer>().SetPositions(pts);
        
        go.name = "Speckle Point";
        
        return go;
    }
示例#12
0
        /// <summary>
        /// Speckle Point to DS Point
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public static Point ToNative(this SpecklePoint pt)
        {
            var myPoint = Point.ByCoordinates(pt.Value[0], pt.Value[1], pt.Value[2]);

            return(myPoint);
        }
    //unity functions

    public static Vector3 ToVector3(this SpecklePoint p)
    {
        return(new Vector3((float)p.Value[0], (float)p.Value[2], (float)p.Value[1]));
    }
示例#14
0
        static async Task TestObjects(SpeckleApiClient myClient)
        {
            var myPoint = new SpecklePoint()
            {
                Value = new List <double>()
                {
                    1, 2, 3
                }
            };
            var mySecondPoint = new SpecklePoint()
            {
                Value = new List <double>()
                {
                    23, 33, 12
                }
            };
            var myCircle = new SpeckleCircle()
            {
                Radius = 21
            };
            var myPlane = new SpecklePlane()
            {
                Origin = new SpecklePoint()
                {
                    Value = new List <double>()
                    {
                        12, 12, 12
                    }
                }
            };
            var myArc = new SpeckleArc()
            {
                Radius = 2, AngleRadians = 2.1, EndAngle = 1, StartAngle = 0
            };

            myCircle.Properties = new Dictionary <string, object>();
            myCircle.Properties.Add("a  property", "Hello!");
            myCircle.Properties.Add("point", myPoint);


            List <SpeckleObject> myList = new List <SpeckleObject>();

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating some objects.");
                var Response = await myClient.ObjectCreateAsync(new List <SpeckleObject>() { myPoint, myCircle, myArc, myPlane });

                Console.WriteLine("OK: Saved " + Response.Resources.Count + " objects");
                myList = Response.Resources;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Updating an object");
                var Response = await myClient.ObjectUpdateAsync(myList[1]._id, new SpeckleCircle()
                {
                    Radius = 42
                });

                Console.WriteLine("OK: Saved " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Updating an object's properties");
                var Response = await myClient.ObjectUpdatePropertiesAsync(myList[1]._id, new { hello = "World", max = 3.14 });

                Console.WriteLine("OK: Saved " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting an object");
                var Response = await myClient.ObjectGetAsync(myList[1]._id);

                Console.WriteLine("OK: Got " + Response.Resource.ToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting objects in bulk");
                var Response = await myClient.ObjectGetBulkAsync(new string[] { myList[1]._id, myList[0]._id, myList[2]._id }, "fields=properties,radius");

                Console.WriteLine("OK: Got " + Response.Resources.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Deleting an object");
                var Response = await myClient.ObjectDeleteAsync(myList[0]._id);

                Console.WriteLine("OK: Got " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#15
0
        static async Task TestStreams(SpeckleApiClient myClient)
        {
            string streamId       = "lol";
            string secondStreamId = "hai";

            var myPoint = new SpecklePoint()
            {
                Value = new List <double>()
                {
                    1, 2, 3
                }
            };
            var mySecondPoint = new SpecklePoint()
            {
                Value = new List <double>()
                {
                    23, 33, 12
                }
            };
            var myCircle = new SpeckleCircle()
            {
                Radius = 21
            };


            myPoint.Properties = new Dictionary <string, object>();
            myPoint.Properties.Add("Really", mySecondPoint);

            myCircle.Properties = new Dictionary <string, object>();
            myCircle.Properties.Add("a property", "Hello!");
            myCircle.Properties.Add("point", myPoint);

            SpeckleStream myStream = new SpeckleStream()
            {
                Name    = "Hello World My Little Stream",
                Objects = new List <SpeckleObject>()
                {
                    myCircle, myPoint
                }
            };

            SpeckleStream secondStream = new SpeckleStream()
            {
                Name    = "Second Little Stream",
                Objects = new List <SpeckleObject>()
                {
                    myCircle, mySecondPoint
                }
            };

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating a stream.");
                var Response = await myClient.StreamCreateAsync(myStream);

                Console.WriteLine("OK: " + Response.Resource.ToJson());

                streamId = Response.Resource.StreamId;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating a second stream.");
                var Response = await myClient.StreamCreateAsync(secondStream);

                Console.WriteLine("OK: " + Response.Resource.ToJson());

                secondStreamId = Response.Resource.StreamId;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine();
            try
            {
                Console.WriteLine("Diffing two streams!");
                var Response = await myClient.StreamDiffAsync(streamId, secondStreamId);

                Console.WriteLine("OK: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting a stream.");
                var Response = await myClient.StreamGetAsync(streamId, null);

                Console.WriteLine("OK: " + Response.Resource.ToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting a stream's objects.");
                var Response = await myClient.StreamGetObjectsAsync(streamId, null);

                Console.WriteLine("OK: " + Response.Resources.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Updating a stream.");
                var Response = await myClient.StreamUpdateAsync(streamId, new SpeckleStream()
                {
                    Name = "I hate api testing", ViewerLayers = new List <object>()
                    {
                        new { test = "test" }
                    }
                });

                Console.WriteLine("OK: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting a stream field.");
                var Response = await myClient.StreamGetAsync(streamId, "fields=viewerLayers,name,owner");

                Console.WriteLine("OK: " + Response.Resource.ToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting all users's streams.");
                var Response = await myClient.StreamsGetAllAsync();

                Console.WriteLine("OK: " + Response.Resources.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine();
            try
            {
                Console.WriteLine("Cloning a stream.");
                var Response = await myClient.StreamCloneAsync(streamId);

                Console.WriteLine("OK: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Deleting a stream: " + streamId);
                var Response = await myClient.StreamDeleteAsync(streamId);

                Console.WriteLine("OK: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#16
0
        /// <summary>
        /// Speckle Point to DS Point
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public static Point ToNative(this SpecklePoint pt)
        {
            var point = Point.ByCoordinates(pt.Value[0], pt.Value[1], pt.Value[2]);

            return(point.SetSpeckleProperties <Point>(pt.Properties));
        }
示例#17
0
 public StructuralAssembly(double[] value, string[] elementRefs, SpeckleLine baseLine, SpecklePoint orientationPoint, int numPoints = 0, double width = 0, string applicationId = null, Dictionary <string, object> properties = null)
 {
     if (properties != null)
     {
         this.Properties = properties;
     }
     this.ApplicationId    = applicationId;
     this.ElementRefs      = elementRefs.ToList();
     this.Value            = value.ToList();
     this.OrientationPoint = orientationPoint;
     this.NumPoints        = numPoints;
     this.Width            = width;
     this.BaseLine         = baseLine;
     GenerateHash();
 }
 private static bool Valid(SpecklePoint p)
 {
     return(p != null && p.Value != null);
 }