예제 #1
0
        public static string getPanelNameAndVal(IGH_Param param)
        {
            Grasshopper.Kernel.Special.GH_Panel myParam = param as Grasshopper.Kernel.Special.GH_Panel;
            if (myParam != null)
            {
                string panelVal = "";

                foreach (Object myObj in myParam.VolatileData.AllData(true))
                {
                    GH_String temporary = myObj as GH_String;
                    string    myString  = temporary.Value;
                    double    mydbl     = 0;
                    try
                    {
                        mydbl = Double.Parse(myString);
                    }
                    catch
                    {
                    }

                    panelVal += mydbl;
                }

                return(myParam.NickName + "," + panelVal);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public static GH_Structure <GH_String> DataTreeNaming(string name, GH_Structure <IGH_Goo> data)
        {
            // Output
            GH_Structure <GH_String> names = new GH_Structure <GH_String>();

            // Paths
            var paths = data.Paths;

            // Make the output datatree with names
            for (int i = 0; i < data.Branches.Count; i++)
            {
                var     branches   = data.Branches[i];
                GH_Path iPath      = paths[i];
                string  pathString = iPath.ToString();
                string  newPath    = pathString.Replace("{", "").Replace(";", "_").Replace("}", "");

                for (int j = 0; j < branches.Count; j++)
                {
                    string    myName    = name + "_" + newPath + "_" + j;
                    GH_String converted = new GH_String(myName);
                    names.Append(converted, iPath);
                }
            }

            return(names);
        }
예제 #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve         baseline = new GH_Curve();
            GH_String        layer    = new GH_String("");
            GH_Number        height   = new GH_Number();
            GH_String        style    = new GH_String("");
            List <Parameter> param    = new List <Parameter>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }

            //DA.GetData<GH_String>("Family", ref family);
            DA.GetData <GH_String>("Layer", ref layer);
            DA.GetData <GH_String>("Style", ref style);
            DA.GetData <GH_Number>("Height", ref height);
            DA.GetData <GH_Curve>("Baseline", ref baseline);


            Wall w = new Wall(style.Value, layer.Value, param, baseline.ToGrevitCurve(), "", height.Value, true, false);

            SetGID(w);
            Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, new Rhino.Geometry.Vector3d(0, 0, height.Value));
            SetPreview(w.GID, srf.ToBrep());
            DA.SetData("GrevitComponent", w);
        }
예제 #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Instance i = null;

            DA.GetData <Instance>(0, ref i);

            GH_Point  p      = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z));
            GH_Number scale  = new GH_Number(i.Transformation.Scale);
            GH_String name   = new GH_String(i.Name);
            GH_String parent = new GH_String(i.Parent.Name);

            List <GH_Brep> surfaces = new List <GH_Brep>();
            List <GH_Brep> inner    = new List <GH_Brep>();


            foreach (Surface srf in i.Parent.Surfaces)
            {
                surfaces.Add(new GH_Brep(srf.ToRhinoGeo(i.Transformation)));
            }



            DA.SetData(0, p);
            DA.SetData(1, name);
            DA.SetData(2, scale);
            DA.SetDataList(3, surfaces);
            DA.SetData(4, parent);
            DA.SetDataList(5, inner);
        }
예제 #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String        style = new GH_String("");
            GH_String        layer = new GH_String("");
            GH_Point         stop  = new GH_Point();
            GH_Point         sbtm  = new GH_Point();
            List <Parameter> param = new List <Parameter>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }

            DA.GetData <GH_String>("Style", ref style);
            DA.GetData <GH_String>("Layer", ref layer);

            DA.GetData <GH_Point>("PointTop", ref stop);
            DA.GetData <GH_Point>("PointBottom", ref sbtm);

            Column s = new Column(style.Value, layer.Value, param, sbtm.ToGrevitPoint(), stop.ToGrevitPoint(), "", true);

            SetGID(s);

            Rhino.Geometry.Circle  c   = new Rhino.Geometry.Circle(sbtm.Value, 0.5);
            Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(stop.Value.X - sbtm.Value.X, stop.Value.Y - sbtm.Value.Y, stop.Value.Z - sbtm.Value.Z)));
            SetPreview(s.GID, srf.ToBrep());
            DA.SetData("GrevitComponent", s);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaSection sect = new GsaSection();

            //profile
            GH_String gh_profile = new GH_String();

            if (DA.GetData(0, ref gh_profile))
            {
                if (GH_Convert.ToString(gh_profile, out string profile, GH_Conversion.Both))
                {
                    sect.Section.Profile = profile;

                    // 1 material
                    // to be implemented

                    // 2 pool
                    GH_Integer gh_pool = new GH_Integer();
                    if (DA.GetData(2, ref gh_pool))
                    {
                        if (GH_Convert.ToInt32(gh_pool, out int pool, GH_Conversion.Both))
                        {
                            sect.Section.Pool = pool;
                        }
                    }

                    // 3 ID
                    GH_Integer gh_id = new GH_Integer();
                    if (DA.GetData(3, ref gh_id))
                    {
                        if (GH_Convert.ToInt32(gh_id, out int idd, GH_Conversion.Both))
                        {
                            sect.ID = idd;
                        }
                    }

                    // 4 name
                    GH_String gh_n = new GH_String();
                    if (DA.GetData(4, ref gh_n))
                    {
                        if (GH_Convert.ToString(gh_n, out string name, GH_Conversion.Both))
                        {
                            sect.Section.Name = name;
                        }
                    }

                    // 5 colour
                    GH_Colour gh_Colour = new GH_Colour();
                    if (DA.GetData(5, ref gh_Colour))
                    {
                        if (GH_Convert.ToColor(gh_Colour, out System.Drawing.Color colour, GH_Conversion.Both))
                        {
                            sect.Section.Colour = colour;
                        }
                    }
                }
                DA.SetData(0, new GsaSectionGoo(sect));
            }
        }
예제 #7
0
파일: Remote.cs 프로젝트: jf---/Robots
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Program program = null;
            GH_String  ip      = null;

            if (!DA.GetData(0, ref program))
            {
                return;
            }

            var robotCellUR = program.Value.RobotSystem as RobotCellUR;

            if (DA.GetData(1, ref ip) && ip != null)
            {
                robotCellUR.Remote.IP = ip.Value;
            }

            bool connect = false, upload = false, play = false, pause = false;

            if (!DA.GetData("Connect", ref connect))
            {
                return;
            }
            if (!DA.GetData("Upload", ref upload))
            {
                return;
            }
            if (!DA.GetData("Play", ref play))
            {
                return;
            }
            if (!DA.GetData("Pause", ref pause))
            {
                return;
            }

            if (connect && !connected)
            {
                robotCellUR.Remote.Connect(); connected = true;
            }
            if (!connect && connected)
            {
                robotCellUR.Remote.Disconnect(); connected = false;
            }
            if (upload && connected)
            {
                robotCellUR.Remote.UploadProgram(program.Value);
            }
            if (play && connected)
            {
                robotCellUR.Remote.Play();
            }
            if (pause && connected)
            {
                robotCellUR.Remote.Pause();
            }

            DA.SetDataList(0, robotCellUR.Remote.Log);
        }
예제 #8
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool connect = false;

            DA.GetData("Connect", ref connect);

            if (!connect && Connected)
            {
                Dispose();
            }

            if (Connected)
            {
                GH_Program program = null;
                if (!DA.GetData(0, ref program))
                {
                    return;
                }
                SendJoints(program.Value);
            }

            if (connect && !Connected)
            {
                GH_Number port = new GH_Number();
                GH_String ip   = new GH_String();
                if (!DA.GetData("PO", ref port))
                {
                    _log.Add("No Port found"); return;
                }
                if (!DA.GetData("IP", ref ip))
                {
                    _log.Add("No IP found"); return;
                }

                _port = (int)port.Value;
                _ip   = ip.ToString();

                _log.Clear();
                ConnectToUnreal();

                // if (_task == null || _task.Status != TaskStatus.Running)
                //  {


                //_task = Task.Run(async () => await ConnectToUnreal())
                // .ContinueWith(task =>
                //  {
                //       this.ExpireSolution(true);
                //   }, TaskScheduler.FromCurrentSynchronizationContext());
                // }
                //else
                // {
                //      _log.Add("Trying to connect to Unreal");
                // }
            }

            DA.SetDataList("Log", _log);
        }
예제 #9
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String path = new GH_String();

            DA.GetData <GH_String>(0, ref path);

            GH_Boolean mesh = new GH_Boolean(true);

            if (!DA.GetData <GH_Boolean>(1, ref mesh))
            {
                mesh = new GH_Boolean(true);
            }

            List <GH_Brep>   surfaces  = new List <GH_Brep>();
            List <GH_String> layers    = new List <GH_String>();
            List <Instance>  Instances = new List <Instance>();
            List <GH_Curve>  curves    = new List <GH_Curve>();
            List <GH_Mesh>   meshes    = new List <GH_Mesh>();

            SketchUp skp = new SketchUp();

            if (skp.LoadModel(path.Value, mesh.Value))
            {
                foreach (Surface srf in skp.Surfaces)
                {
                    foreach (var brep in srf.ToRhinoGeo())
                    {
                        surfaces.Add(new GH_Brep(brep));
                    }

                    if (srf.FaceMesh != null)
                    {
                        meshes.Add(new GH_Mesh(srf.FaceMesh.ToRhinoGeo()));
                    }
                }

                foreach (Layer l in skp.Layers)
                {
                    layers.Add(new GH_String(l.Name));
                }

                foreach (Instance i in skp.Instances)
                {
                    Instances.Add(i);
                }

                foreach (Edge c in skp.Edges)
                {
                    curves.Add(new GH_Curve(c.ToRhinoGeo().ToNurbsCurve()));
                }
            }

            DA.SetDataList(0, surfaces);
            DA.SetDataList(1, layers);
            DA.SetDataList(2, Instances);
            DA.SetDataList(3, curves);
            DA.SetDataList(4, meshes);
        }
예제 #10
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface    = new GH_Surface();
            GH_String  lvlbtm     = new GH_String("");
            GH_String  style      = new GH_String("");
            GH_String  layer      = new GH_String("");
            GH_Number  taperAng   = new GH_Number(0);
            GH_Number  height     = new GH_Number();
            GH_Point   stop       = new GH_Point();
            GH_Point   sbtm       = new GH_Point();
            GH_Boolean structural = new GH_Boolean(true);

            List <Parameter> param = new List <Parameter>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }
            DA.GetData <GH_Surface>("Surface", ref surface);

            DA.GetData <GH_String>("Layer", ref layer);
            //DA.GetData<GH_String>("Style", ref style);
            DA.GetData <GH_Number>("taperAngle", ref taperAng);
            DA.GetData <GH_Number>("height", ref height);

            Slab s = new Slab();

            s.FamilyOrStyle   = style.Value;
            s.TypeOrLayer     = layer.Value;
            s.levelbottom     = lvlbtm.Value;
            s.structural      = structural.Value;
            s.surface         = new Profile();
            s.surface.profile = new List <Loop>();
            Loop loop = new Loop()
            {
                outline = new List <Component>()
            };

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }
            s.surface.profile.Add(loop);


            s.height     = height.Value;
            s.parameters = param;
            //s.top = ComponentUtilities.GHPoint2Point(stop);
            //s.bottom = ComponentUtilities.GHPoint2Point(sbtm);
            s.slope = taperAng.Value;
            s.GID   = this.InstanceGuid.ToString();


            //SetPreview(s.GID, surface.Value);
            DA.SetData("GrevitComponent", s);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaGravityLoad gravityLoad = new GsaGravityLoad();

            //Load case
            int        lc    = 1;
            GH_Integer gh_lc = new GH_Integer();

            if (DA.GetData(0, ref gh_lc))
            {
                GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both);
            }
            gravityLoad.GravityLoad.Case = lc;

            //element/beam list
            string    beamList = "all";
            GH_String gh_bl    = new GH_String();

            if (DA.GetData(1, ref gh_bl))
            {
                GH_Convert.ToString(gh_bl, out beamList, GH_Conversion.Both);
            }
            gravityLoad.GravityLoad.Elements = beamList;

            // 2 Name
            string    name    = "";
            GH_String gh_name = new GH_String();

            if (DA.GetData(2, ref gh_name))
            {
                if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both))
                {
                    gravityLoad.GravityLoad.Name = name;
                }
            }

            //factor
            Vector3   factor    = new Vector3();
            Vector3d  vect      = new Vector3d(0, 0, -1);
            GH_Vector gh_factor = new GH_Vector();

            if (DA.GetData(3, ref gh_factor))
            {
                GH_Convert.ToVector3d(gh_factor, ref vect, GH_Conversion.Both);
            }
            factor.X = vect.X; factor.Y = vect.Y; factor.Z = vect.Z;
            gravityLoad.GravityLoad.Factor = factor;

            GsaLoad gsaLoad = new GsaLoad(gravityLoad);

            DA.SetData(0, new GsaLoadGoo(gsaLoad));
        }
예제 #12
0
        /*******************************************/

        public static bool CastToGoo(object value, ref IGH_QuickCast target)
        {
            try
            {
                if (value is bool)
                {
                    target = new GH_Boolean((bool)value);
                }
                else if (value is Color)
                {
                    target = new GH_Colour((Color)value);
                }
                else if (value is Complex)
                {
                    target = new GH_ComplexNumber((Complex)value);
                }
                else if (value is int)
                {
                    target = new GH_Integer((int)value);
                }
                else if (value is Interval)
                {
                    target = new GH_Interval((Interval)value);
                }
                else if (value is Matrix)
                {
                    target = new GH_Matrix((Matrix)value);
                }
                else if (value is double || value is float)
                {
                    target = new GH_Number((double)value);
                }
                else if (value is Point3d)
                {
                    target = new GH_Point((Point3d)value);
                }
                else if (value is string)
                {
                    target = new GH_String(value.ToString());
                }
                else if (value is Vector3d)
                {
                    target = new GH_Vector((Vector3d)value);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #13
0
파일: Remote.cs 프로젝트: zimhe/Robots
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Program program = null;
            GH_String  ip      = null;

            if (!DA.GetData(0, ref program))
            {
                return;
            }

            var remote = program.Value.RobotSystem.Remote;

            if (remote == null)
            {
                throw new Exception("No remote functionality for this robot.");
            }
            if (DA.GetData(1, ref ip) && ip != null)
            {
                remote.IP = ip.Value;
            }

            bool upload = false, play = false, pause = false;

            if (!DA.GetData("Upload", ref upload))
            {
                return;
            }
            if (!DA.GetData("Play", ref play))
            {
                return;
            }
            if (!DA.GetData("Pause", ref pause))
            {
                return;
            }

            if (upload)
            {
                remote.Upload(program.Value);
            }
            if (play)
            {
                remote.Play();
            }
            if (pause)
            {
                remote.Pause();
            }

            DA.SetDataList(0, remote.Log);
        }
예제 #14
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Instance i = null;

            DA.GetData <Instance>(0, ref i);

            GH_Point  location = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z));
            GH_Number scale    = new GH_Number(i.Transformation.Scale);
            GH_String name     = new GH_String(i.Name);

            List <GH_Brep>  surfaces = new List <GH_Brep>();
            List <GH_Brep>  inner    = new List <GH_Brep>();
            List <GH_Curve> curves   = new List <GH_Curve>();
            List <GH_Mesh>  meshes   = new List <GH_Mesh>();

            GH_String parentName = new GH_String("");

            SketchUpNET.Component parentComponent = i.Parent as Component;
            if (parentComponent != null)
            {
                parentName = new GH_String(parentComponent.Name);
                foreach (Surface srf in parentComponent.Surfaces)
                {
                    foreach (var brep in srf.ToRhinoGeo(i.Transformation))
                    {
                        surfaces.Add(new GH_Brep(brep));
                    }

                    if (srf.FaceMesh != null)
                    {
                        meshes.Add(new GH_Mesh(srf.FaceMesh.ToRhinoGeo()));
                    }
                }

                foreach (Edge c in parentComponent.Edges)
                {
                    curves.Add(new GH_Curve(c.ToRhinoGeo().ToNurbsCurve()));
                }
            }

            DA.SetData(0, location);
            DA.SetData(1, name);
            DA.SetData(2, scale);
            DA.SetDataList(3, surfaces);
            DA.SetData(4, parentName);
            DA.SetDataList(5, inner);
            DA.SetDataList(6, curves);
            DA.SetDataList(7, meshes);
        }
예제 #15
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve curve = new GH_Curve();

            DA.GetData <GH_Curve>("Curve", ref curve);
            GH_String layer = new GH_String(string.Empty);

            DA.GetData <GH_String>("Layer", ref layer);

            Component c = curve.Value.ToNurbsCurve().ToGrevitCurve();

            c.TypeOrLayer = layer.ToString();
            SetGID(c);
            DA.SetData("GrevitComponent", c);
        }
예제 #16
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String path = new GH_String();

            DA.GetData <GH_String>(0, ref path);

            List <GH_Surface> surfaces = new List <GH_Surface>();

            DA.GetDataList <GH_Surface>(1, surfaces);
            List <GH_Curve> curves = new List <GH_Curve>();

            DA.GetDataList <GH_Curve>(2, curves);

            Geometry.WriteModel(path.Value, surfaces, curves, false);
        }
예제 #17
0
        public override Boolean Equals(Object that)
        {
            if (that == null)
            {
                return(false);
            }
            if (that.GetType() != this.GetType())
            {
                return(false);
            }

            //FIXME: use a reflection to get the Value property of the GH_Goo
            //if a value property is missing, it seems that we could not compare Goos (or different method should be used)

            // GH_Goo.Equals(GH_Goo) compare the GUIDs which are different in the common case
            // that's why we need to compare GH_Goo inner values
            // unfortunately the Value property is not generic for GH_Goo
            // only some GH_Goo have value assigned
            GH_CellState thatState = (GH_CellState)that;

            if (value.GetType() == GH_TypeLib.t_gh_colour)
            {
                GH_Colour thisGH_Colour = (GH_Colour)value;
                GH_Colour thatGH_Colour = (GH_Colour)thatState.value;

                return(thisGH_Colour.Value.Equals(thatGH_Colour.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_bool)
            {
                GH_Boolean thisGH_Boolean = (GH_Boolean)this.value;
                GH_Boolean thatGH_Boolean = (GH_Boolean)thatState.value;
                return(thisGH_Boolean.Value.Equals(thatGH_Boolean.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_int)
            {
                GH_Integer thisGH_Integer = (GH_Integer)this.value;
                GH_Integer thatGH_Integer = (GH_Integer)thatState.value;
                return(thisGH_Integer.Value.Equals(thatGH_Integer.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_string)
            {
                GH_String thisGH_String = (GH_String)this.value;
                GH_String thatGH_String = (GH_String)thatState.value;
                return(thisGH_String.Value.Equals(thatGH_String.Value));
            }

            throw new NotSupportedException("Could not compare GH_Goo type: " + value.GetType());
        }
예제 #18
0
        public override bool CastTo <Q>(ref Q target)
        {
            if (typeof(Q).IsAssignableFrom(typeof(int)))
            {
                object _Index = this.Value.Index;
                target = (Q)_Index;
                return(true);
            }

            if (typeof(Q).IsAssignableFrom(typeof(GH_Integer)))
            {
                object _Index = new GH_Integer(this.Value.Index);
                target = (Q)_Index;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Guid)))
            {
                object _Id = this.Value.Id;
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_Guid)))
            {
                object _Id = new GH_Guid(this.Value.Id);
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_String)))
            {
                object _Path = new GH_String(this.Value.FullPath);
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(string)))
            {
                object _Path = this.Value.FullPath;
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Layer)))
            {
                LayerTable LT     = Rhino.RhinoDoc.ActiveDoc.Layers;
                object     _layer = LT.FindIndex(this.Value.Index);
                target = (Q)_layer;
                return(true);
            }
            return(false);
        }
예제 #19
0
 public bool CastTo <T>(out T target)
 {
     if (typeof(T) == typeof(string))
     {
         target = (T)Name.Clone();
         return(true);
     }
     if (typeof(T) == typeof(GH_String))
     {
         var ghString = new GH_String(Name);
         target = (T)ghString.Duplicate();
         return(true);
     }
     target = default;
     return(false);
 }
예제 #20
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <GH_ObjectWrapper> lines = new List <GH_ObjectWrapper>();
            List <GH_Guid>          cakes = new List <GH_Guid>();
            GH_String  layername          = new GH_String("");
            GH_Boolean bake = new GH_Boolean(false);

            DA.GetData <GH_String>("layer", ref layername);
            DA.GetData <GH_Boolean>("bake", ref bake);



            if (!DA.GetDataList <GH_ObjectWrapper>("dough", lines))
            {
                lines = new List <GH_ObjectWrapper>();
            }


            if (lines.Count > 0 && bake.Value)
            {
                foreach (GH_ObjectWrapper line in lines)
                {
                    int layerindex = 0;
                    Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();



                    foreach (Rhino.DocObjects.Layer layer in Rhino.RhinoDoc.ActiveDoc.Layers)
                    {
                        if (layer.Name == layername.Value)
                        {
                            layerindex = layer.LayerIndex;
                        }
                    }
                    att.LayerIndex = layerindex;

                    Guid g = Guid.Empty;
                    line.BakeGeometry(Rhino.RhinoDoc.ActiveDoc, att, ref g);
                    if (g != Guid.Empty)
                    {
                        cakes.Add(new GH_Guid(g));
                    }
                }

                DA.SetDataList("cake", cakes);
            }
        }
예제 #21
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point point = new GH_Point();

            Grevit.Types.Wall wall = null;


            GH_String layer = new GH_String("");
            GH_String style = new GH_String("");

            List <Parameter> param = new List <Parameter>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }

            DA.GetData <GH_Point>("Point", ref point);
            DA.GetData <GH_String>("Layer", ref layer);
            DA.GetData <GH_String>("Style", ref style);
            DA.GetData <Wall>("wall", ref wall);


            Door d = new Door();

            SetGID(d);
            d.stalledForReference = true;
            d.TypeOrLayer         = layer.Value;
            d.FamilyOrStyle       = style.Value;
            d.locationPoint       = point.ToGrevitPoint();
            d.parameters          = param;
            SetGID(d);



            Rhino.Geometry.Circle  c   = new Rhino.Geometry.Circle(point.Value, 0.5);
            Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0, 0, 2));



            SetPreview(d.GID, srf.ToBrep());


            GH_Surface ghb = new GH_Surface(srf);

            DA.SetData("GrevitComponent", d);
        }
예제 #22
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point curve = new GH_Point();

            DA.GetData <GH_Point>("Point", ref curve);
            GH_String layer = new GH_String(string.Empty);

            DA.GetData <GH_String>("Layer", ref layer);


            DrawingPoint arc = new DrawingPoint();

            arc.point       = curve.ToGrevitPoint();
            arc.TypeOrLayer = layer.Value;
            arc.GID         = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", arc);
        }
예제 #23
0
        private GH_Structure <IGH_Goo> SingleDataStructrue(object value)
        {
            if (value is string path)
            {
                if (File.Exists(path) && Path.GetExtension(path) == ".noahdata")
                {
                    byte[] array;
                    try
                    {
                        array = File.ReadAllBytes(path);
                    }
                    catch
                    {
                        return(null);
                    }

                    return(IO.DeserializeGrasshopperData(array));
                }
            }

            GH_Structure <IGH_Goo> m_data = new GH_Structure <IGH_Goo>();

            GH_Number castNumber = null;
            GH_String castString = null;
            GH_Curve  castCurve  = null;

            if (GH_Convert.ToGHCurve(value, GH_Conversion.Both, ref castCurve))
            {
                m_data.Append(new GH_ObjectWrapper(castCurve));
            }
            else if (GH_Convert.ToGHNumber(value, GH_Conversion.Both, ref castNumber))
            {
                m_data.Append(new GH_ObjectWrapper(castNumber));
            }
            else if (GH_Convert.ToGHString(value, GH_Conversion.Both, ref castString))
            {
                m_data.Append(new GH_ObjectWrapper(castString));
            }
            else
            {
                m_data.Append((IGH_Goo)value);
            }

            return(m_data);
        }
        private GH_Structure <GH_String> MakeTreeFromListofLists(List <List <List <string> > > tagsByGeometryPath)
        {
            var tagsAsTree = new GH_Structure <GH_String>();

            for (var i = 0; i < tagsByGeometryPath.Count; i++)
            {
                for (var j = 0; j < tagsByGeometryPath[i].Count; j++)
                {
                    var path = new GH_Path(i, j);
                    for (var k = 0; k < tagsByGeometryPath[i][j].Count; k++)
                    {
                        var tagReadout = new GH_String(tagsByGeometryPath[i][j][k]);
                        tagsAsTree.Append(tagReadout, path);
                    }
                }
            }
            return(tagsAsTree);
        }
예제 #25
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Boolean       assoc  = new GH_Boolean(false);
            GH_String        name   = new GH_String();
            GH_String        layer  = new GH_String("");
            GH_String        style  = new GH_String("");
            GH_String        number = new GH_String();
            List <Parameter> param  = new List <Parameter>();
            List <GH_Point>  points = new List <GH_Point>();

            if (!DA.GetDataList <Parameter>("Parameters", param))
            {
                param = new List <Parameter>();
            }

            if (!DA.GetDataList <GH_Point>("Points", points))
            {
                points = new List <GH_Point>();
            }

            DA.GetData <GH_String>("Name", ref name);
            DA.GetData <GH_Boolean>("Assoc", ref assoc);
            DA.GetData <GH_String>("Number", ref number);
            DA.GetData <GH_String>("Style", ref style);
            DA.GetData <GH_String>("Layer", ref layer);


            Room ac = new Room(name.Value, number.Value, "", param);

            IEnumerable <GH_Point> nodups = points.Distinct(new GH_PointComparer());

            ac.points = new List <Grevit.Types.Point>();
            foreach (var p in nodups)
            {
                ac.points.Add(p.ToGrevitPoint());
            }

            ac.associative   = assoc.Value;
            ac.FamilyOrStyle = style.Value;
            ac.TypeOrLayer   = layer.Value;
            ac.GID           = this.InstanceGuid.ToString();

            DA.SetData("GrevitComponent", ac);
        }
예제 #26
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaSection gsaSection = new GsaSection();

            //profile
            GH_String gh_profile = new GH_String();

            if (DA.GetData(0, ref gh_profile))
            {
                if (GH_Convert.ToString(gh_profile, out string profile, GH_Conversion.Both))
                {
                    gsaSection.Section         = new Section();
                    gsaSection.Section.Profile = profile;


                    // 3 Material
                    GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                    if (DA.GetData(1, ref gh_typ))
                    {
                        GsaMaterial material = new GsaMaterial();
                        if (gh_typ.Value is GsaMaterialGoo)
                        {
                            gh_typ.CastTo(ref material);
                            gsaSection.Material = material;
                        }
                        else
                        {
                            if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                            {
                                gsaSection.Material = new GsaMaterial(idd);
                            }
                            else
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer");
                                return;
                            }
                        }
                    }
                    else
                    {
                        gsaSection.Material = new GsaMaterial(7);
                    }
                }
예제 #27
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (DA.Iteration > 0)
            {
                return;
            }
            bool CloudMode = true;

            try
            {
                MarkdownDocument md = null;
                if (!DA.GetData(0, ref md))
                {
                    return;
                }
                if (!Utils.IsRunningOnWindowsServer)
                {
                    GH_String fpath = new GH_String();
                    if (DA.GetData(1, ref fpath))
                    {
                        if (fpath.Value != null && fpath.Value != string.Empty)
                        {
                            CloudMode = false;
                            md.WriteDocumentToFile(fpath.Value, true);
                        }
                    }
                }
                DA.SetData(0, md);
                if (CloudMode)
                {
                    this.Message = "Cloud Mode";
                }
                else
                {
                    this.Message = string.Empty;
                }
            }
            catch (Exception ex)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Exception Caught: " + ex.Message);
            }
        }
예제 #28
0
 public bool CastTo <T>(out T target)
 {
     if (typeof(T) == typeof(int))
     {
         target = (T)Convert.ChangeType(Index, typeof(int));
         return(true);
     }
     if (typeof(T) == typeof(double))
     {
         target = (T)Convert.ChangeType(Index, typeof(double));
         return(true);
     }
     if (typeof(T) == typeof(string))
     {
         var s = Index.ToString();
         target = (T)s.Clone();
         return(true);
     }
     if (typeof(T) == typeof(GH_Integer))
     {
         var index   = (int)Index;
         var gHIndex = new GH_Integer(index);
         target = (T)gHIndex.Duplicate();
         return(true);
     }
     if (typeof(T) == typeof(GH_Number))
     {
         var index   = (double)Index;
         var gHIndex = new GH_Number(index);
         target = (T)gHIndex.Duplicate();
         return(true);
     }
     if (typeof(T) == typeof(GH_String))
     {
         var s        = Index.ToString();
         var ghString = new GH_String(s);
         target = (T)ghString.Duplicate();
         return(true);
     }
     target = default;
     return(false);
 }
예제 #29
0
        public static List <List <string> > TreeToList2(GH_Structure <GH_String> tree)
        {
            IList <GH_Path>         paths       = tree.Paths;
            List <List <string> >   list        = new List <List <string> >();
            IEnumerable <GH_String> this_branch = new List <GH_String>();

            for (int i = 0; i < paths.Count; i++)
            {
                list.Add(new List <string>());
                this_branch = tree.get_Branch(paths[i]).Cast <GH_String>();
                List <GH_String> this_list = this_branch.ToList();
                for (int j = 0; j < this_list.Count(); j++)
                {
                    GH_String raw_item = this_list[j];
                    raw_item.CastTo(out string item);
                    list[i].Add(item);
                }
            }
            return(list);
        }
예제 #30
0
        public static Object ConvertGhObject(GH_String ghString)
        {
            // Try converting in this order: Int, Double, String
            Int64 intResult = 0;
            bool  isInt     = Int64.TryParse(ghString.Value, out intResult);

            if (isInt)
            {
                return(intResult);
            }

            double doubleResult = 0.0;
            bool   isDouble     = Double.TryParse(ghString.Value, out doubleResult);

            if (isDouble)
            {
                return(doubleResult);
            }

            return(ghString.Value);
        }
예제 #31
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve baseline = new GH_Curve();
            GH_String layer = new GH_String("");
            GH_Number height = new GH_Number();
            GH_String style = new GH_String("");
            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            //DA.GetData<GH_String>("Family", ref family);
            DA.GetData<GH_String>("Layer", ref layer);
            DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_Number>("Height", ref height);
            DA.GetData<GH_Curve>("Baseline", ref baseline);


            Wall w = new Wall(style.Value,layer.Value,param, baseline.ToGrevitCurve(),"",height.Value,true,false);

            SetGID(w);
            Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, new Rhino.Geometry.Vector3d(0, 0, height.Value));
            SetPreview(w.GID, srf.ToBrep());
            DA.SetData("GrevitComponent",w);
        }
예제 #32
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Instance i = null;
            DA.GetData<Instance>(0, ref i);

            GH_Point p = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z));
            GH_Number scale = new GH_Number(i.Transformation.Scale);
            GH_String name = new GH_String(i.Name);
            GH_String parent = new GH_String(i.Parent.Name);

            List<GH_Brep> surfaces = new List<GH_Brep>();
            List<GH_Brep> inner = new List<GH_Brep>();

                foreach (Surface srf in i.Parent.Surfaces)
                    surfaces.Add(new GH_Brep(srf.ToRhinoGeo(i.Transformation)));

            DA.SetData(0, p);
            DA.SetData(1, name);
            DA.SetData(2, scale);
            DA.SetDataList(3, surfaces);
            DA.SetData(4, parent);
            DA.SetDataList(5, inner);
        }
예제 #33
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool write = false;
            string myFilePath = null;
            List<Element> inElements = new List<Element>();

            //get user inputs
            //user should be able to create a scene contianing only lines, or only meshes, or both.  All geo and material inputs will be optional, and we'll run some defense.
            if (!DA.GetData(0, ref write)) return;
            if (!DA.GetData(1, ref myFilePath)) return;
            DA.GetDataList(2, inElements);

            #region Input management

            //if we are not told to run, return
            if (!write)
            {
                string err = "Set the 'W?' input to true to write the JSON file to disk";
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, err);
                DA.SetData(0, err);
                return;
            }

            List<GH_String> inMeshGeometry = new List<GH_String>();
            List<GH_String> inLineGeometry = new List<GH_String>();
            List<GH_String> inViews = new List<GH_String>();

            List<GH_String> inMeshMaterial = new List<GH_String>();
            List<GH_String> inLineMaterial = new List<GH_String>();

            List<GH_String> inMeshLayer = new List<GH_String>();
            List<GH_String> inLineLayer = new List<GH_String>();

            Dictionary<string, List<Element>> definitionLayers = new Dictionary<string, List<Element>>();

            foreach (Element e in inElements)
            {
                if (e == null) continue;
                GH_String g = new GH_String();
                g.Value = e.GeometryJson;

                if (e.Type != va3cElementType.Camera)
                {
                    GH_String m = new GH_String();
                    m.Value = e.Material.MaterialJson;

                    string layerName = "";
                    if (e.Layer == null) layerName = "Default";
                    else layerName = e.Layer.Name;

                    GH_String l = new GH_String();
                    l.Value = layerName;

                    if (e.Type == va3cElementType.Mesh)
                    {
                        inMeshGeometry.Add(g);
                        inMeshMaterial.Add(m);
                        inMeshLayer.Add(l);
                    }

                    if (e.Type == va3cElementType.Line)
                    {
                        inLineGeometry.Add(g);
                        inLineMaterial.Add(m);
                        inLineLayer.Add(l);
                    }

                    if (!definitionLayers.Keys.Contains(layerName))
                    {
                        List<Element> layerElements = new List<Element>();
                        definitionLayers.Add(layerName, layerElements);
                    }

                    definitionLayers[layerName].Add(e);

                }
                else
                {
                    inViews.Add(g);
                }
            }

            #endregion

            #region file path defense

            //check to see if the file path has any invalid characters
            try
            {
                //FIRST check to see if there is more than one semicolon in the path
                //or if there is a semiColon anywhere in there
                string[] colonFrags = myFilePath.Split(':');
                if (colonFrags.Length > 2 || myFilePath.Contains(";"))
                {
                    throw new Exception();
                }

                //SECOND test the file name for invalid characters using regular expressions
                //this method comes from the C# 4.0 in a nutshell book, p991
                string inputFileName = Path.GetFileName(myFilePath);
                char[] inValidChars = Path.GetInvalidFileNameChars();
                string inValidString = Regex.Escape(new string(inValidChars));
                string myNewValidFileName = Regex.Replace(inputFileName, "[" + inValidString + "]", "");

                //if the replace worked, throw an error at the user.
                if (inputFileName != myNewValidFileName)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                //warn the user
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                    "Your file name is invalid - check your input and try again.");
                return;
            }

            //if neither the file or directory exist, throw a warning
            if (!File.Exists(myFilePath) && !Directory.Exists(Path.GetDirectoryName(myFilePath)))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                    "The directory you specified does not exist. Please double check your input. No file path will be set.");
                return;
            }

            //if the directory exists but the file type is not .xlsx, throw a warning and set pathString = noFIle
            if (Directory.Exists(Path.GetDirectoryName(myFilePath)) && !isJSONfile(Path.GetExtension(myFilePath)))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                    "Please provide a file of type .js or .json.  Something like: 'myExampleFile.json'.");
                return;
            }
            #endregion

            //compile geometry + materials into one JSON object with metadata etc.
            //https://raw.githubusercontent.com/mrdoob/three.js/master/examples/obj/blenderscene/scene.js

            try
            {
                //create json from lists of json:
                string outJSON = sceneJSON(inMeshGeometry, inMeshMaterial, inMeshLayer, inLineGeometry, inLineMaterial, inLineLayer, inViews, definitionLayers);
                outJSON = outJSON.Replace("OOO", "object");

                //write the file to disk
                File.WriteAllText(myFilePath, outJSON);

                //report success
                DA.SetData(0, "JSON file written successfully!");
            }
            catch (Exception e)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                    "Something went wrong while trying to write the file to disk.  Here's the error:\n\n"
                    + e.ToString());
                return;
            }
        }
예제 #34
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface = new GH_Surface();
            GH_String lvlbtm = new GH_String("");
            GH_String style = new GH_String("");
            GH_String layer = new GH_String("");
            GH_Number taperAng = new GH_Number(0);
            GH_Number height = new GH_Number();
            GH_Point stop = new GH_Point();
            GH_Point sbtm = new GH_Point();
            GH_Boolean structural = new GH_Boolean(true);

            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();
            DA.GetData<GH_Surface>("Surface", ref surface);

            DA.GetData<GH_String>("Layer", ref layer);
            //DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_Number>("taperAngle", ref taperAng);
            DA.GetData<GH_Number>("height", ref height);

            Slab s = new Slab();
            s.FamilyOrStyle = style.Value;
            s.TypeOrLayer = layer.Value;
            s.levelbottom = lvlbtm.Value;
            s.structural = structural.Value;
            s.surface = new Surface();
            s.surface.outline = new List<Component>();

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                s.surface.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }

            s.height = height.Value;
            s.parameters = param;
            //s.top = ComponentUtilities.GHPoint2Point(stop);
            //s.bottom = ComponentUtilities.GHPoint2Point(sbtm);
            s.slope = taperAng.Value;
            s.GID = this.InstanceGuid.ToString();

            //SetPreview(s.GID, surface.Value);
            DA.SetData("GrevitComponent", s);
        }
예제 #35
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point curve = new GH_Point();
            DA.GetData<GH_Point>("Point", ref curve);
            GH_String layer = new GH_String(string.Empty);
            DA.GetData<GH_String>("Layer", ref layer);

            DrawingPoint arc = new DrawingPoint();
            arc.point = curve.ToGrevitPoint();
                    arc.TypeOrLayer = layer.Value;
                    arc.GID = this.InstanceGuid.ToString();
                    DA.SetData("GrevitComponent", arc);
        }
예제 #36
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String();
            DA.GetData<GH_String>("Name", ref name);
            GH_String view = new GH_String();
            DA.GetData<GH_String>("View", ref view);
            GH_Surface srf = new GH_Surface();
            DA.GetData<GH_Surface>("Plane", ref srf);
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            Rhino.Geometry.Point3d[] pkts = srf.Value.GetBoundingBox(true).GetCorners();

            Grevit.Types.ReferencePlane referencePlane = new ReferencePlane();
            referencePlane.Name = name.Value;
            referencePlane.EndA = pkts[0].ToGrevitPoint();
            referencePlane.EndB = pkts[1].ToGrevitPoint();
            referencePlane.cutVector = srf.Value.GetBoundingBox(true).Center.ToGrevitPoint();
            referencePlane.View = view.Value;
            SetGID(referencePlane);

            DA.SetData("GrevitComponent", referencePlane);
        }
예제 #37
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String();
            object value = null;

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<object>("Value", ref value);

            Parameter p = new Parameter(name.Value);

            if (value.GetType() == typeof(GH_Number))
            {
                GH_Number n = (GH_Number)value;
                p.value = n.Value;
            }
            else if (value.GetType() == typeof(GH_Integer))
            {
                GH_Integer n = (GH_Integer)value;
                p.value = n.Value;
            }
            else if (value.GetType() == typeof(GH_String))
            {
                GH_String n = (GH_String)value;
                p.value = n.Value;
            }
            else if (value.GetType() == typeof(GH_ObjectWrapper))
            {
                GH_ObjectWrapper obj = (GH_ObjectWrapper)value;

                if (obj.Value.GetType() == typeof(ElementID)) { p.value = obj.Value; }
                if (obj.Value.GetType() == typeof(SearchElementID)) { p.value = obj.Value; }
            }
            else
            {
                p.value = value.ToString();
            }


            DA.SetData("Parameter", p);
        }
예제 #38
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String level = new GH_String("none");
            GH_String family = new GH_String("none");
            GH_String type = new GH_String("none");
            GH_Point topPoint = new GH_Point();
            GH_Point bottomPoint = new GH_Point();
            GH_String gid = new GH_String("");
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();



            DA.GetData<GH_String>("Family", ref family);
            DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Level", ref level);
            DA.GetData<GH_Point>("PointTop", ref topPoint);
            DA.GetData<GH_Point>("PointBottom", ref bottomPoint);
            DA.GetData<GH_String>("GID", ref gid);

            Column column = new Column(family.Value,type.Value,parameters, topPoint.ToGrevitPoint(), bottomPoint.ToGrevitPoint(),level.Value,true);


            SetGID(column);

            Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(bottomPoint.Value,0.5);
  
            Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(circle.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(topPoint.Value.X-bottomPoint.Value.X,topPoint.Value.Y-bottomPoint.Value.Y,topPoint.Value.Z-bottomPoint.Value.Z)));

            SetPreview(column.GID, srf.ToBrep());

            DA.SetData("GrevitComponent", column);
        }
예제 #39
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Line line = new GH_Line();

            DA.GetData<GH_Line>("Gridline", ref line);
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            GH_String name = new GH_String();
            DA.GetData<GH_String>("Name", ref name);

            Tuple<Grevit.Types.Point, Grevit.Types.Point> points = line.ToGrevitPoints();
            Grid gridLine = new Grid(parameters, points.Item1, points.Item2,name.Value);

            gridLine.GID = line.ReferenceID.ToString();
            DA.SetData("GrevitComponent", gridLine);
        }
예제 #40
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String();
            GH_Number elevation = new GH_Number();
            GH_Boolean view = new GH_Boolean();

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_Boolean>("View", ref view);
            DA.GetData<GH_Number>("Elevation", ref elevation);

            Level level = new Level(name.Value, elevation.Value, view.Value);
            level.GID = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", level);
        }
예제 #41
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String panelname = new GH_String("");
            GH_Integer id = new GH_Integer(0);
            DA.GetData<GH_Integer>("PanelID",ref id);
            DA.GetData<GH_String>("PanelType",ref panelname);
            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            Grevit.Types.SetCurtainPanel scp = new SetCurtainPanel();
            scp.panelID = id.Value;
            scp.panelType = panelname.Value;
            scp.parameters = param;
            //scp.GID = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", scp);
        }
예제 #42
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<GH_Point> points = new List<GH_Point>();
            GH_String pattern = new GH_String("");
            GH_String view = new GH_String("");

            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();
            if (!DA.GetDataList<GH_Point>("Points", points)) points = new List<GH_Point>();

            DA.GetData<GH_String>("View", ref view);
            DA.GetData<GH_String>("Pattern", ref pattern);



            List<Grevit.Types.Point> outline = new List<Grevit.Types.Point>();
            IEnumerable<GH_Point> outlineWithoutDuplicates = points.Distinct(new GH_PointComparer());
            foreach (var point in outlineWithoutDuplicates)  outline.Add(point.ToGrevitPoint());
            
            Hatch hatch = new Hatch(parameters, outline,view.Value, pattern.Value);

            hatch.GID = this.InstanceGuid.ToString();


            DA.SetData("GrevitComponent", hatch);
        }
예제 #43
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve baseline = new GH_Curve();
            GH_Vector vector = new GH_Vector();
            GH_String family = new GH_String("");
            GH_String type = new GH_String("");
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            
            DA.GetData<GH_Vector>("Vector", ref vector);
            DA.GetData<GH_Curve>("Outline", ref baseline);

            if (baseline.Value.IsPolyline() && baseline.Value.IsClosed)
            {
                


                Rhino.Geometry.Polyline pline;
                if (baseline.Value.TryGetPolyline(out pline))
                {
                    PLine plineToExtrude = new PLine();
                    plineToExtrude.points = new List<Grevit.Types.Point>();
                    foreach (Rhino.Geometry.Point3d pkt in pline)
                    {
                        plineToExtrude.points.Add(pkt.ToGrevitPoint());
                    }
                    plineToExtrude.closed = pline.IsClosed;
                    plineToExtrude.GID = baseline.ReferenceID.ToString();


                    Grevit.Types.Point extrusionVector = new Grevit.Types.Point()
                    {
                        x = vector.Value.X,
                        y = vector.Value.Y,
                        z = vector.Value.Z
                    };

                    SimpleExtrusion extrusion = new SimpleExtrusion(family.Value, type.Value, parameters, plineToExtrude, extrusionVector);

                    Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, vector.Value);
                    
                    SetGID(extrusion);
                    SetPreview(extrusion.GID, srf.ToBrep());

                    

                    DA.SetData("GrevitComponent",extrusion);
                }
            }
        }
예제 #44
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String id = new GH_String();

            DA.GetData<GH_String>("Name", ref id);

            SearchElementID emid = new SearchElementID();
            emid.Name = id.Value;


            DA.SetData("ElementID", emid);
        }
예제 #45
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String style = new GH_String("");
            GH_String layer = new GH_String("");
            GH_Point stop = new GH_Point();
            GH_Point sbtm = new GH_Point();
            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_String>("Layer", ref layer);

            DA.GetData<GH_Point>("PointTop", ref stop);
            DA.GetData<GH_Point>("PointBottom", ref sbtm);

            Column s = new Column(style.Value,layer.Value,param,sbtm.ToGrevitPoint(),stop.ToGrevitPoint(),"",true );
            SetGID(s);

            Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(sbtm.Value, 0.5);
            Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(stop.Value.X - sbtm.Value.X, stop.Value.Y - sbtm.Value.Y, stop.Value.Z - sbtm.Value.Z)));
            SetPreview(s.GID, srf.ToBrep());
            DA.SetData("GrevitComponent", s);
        }
예제 #46
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<GH_Point> points = new List<GH_Point>();

            DA.GetDataList<GH_Point>("Points", points);
            GH_String family = new GH_String();
            GH_String type = new GH_String();
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();


            DA.GetData<GH_String>("Family", ref family);
            DA.GetData<GH_String>("Type", ref type);

            Adaptive adaptiveComponent = new Adaptive();
            adaptiveComponent.FamilyOrStyle = family.Value;
            adaptiveComponent.TypeOrLayer = type.Value;
            adaptiveComponent.points = new Dictionary<int,Grevit.Types.Point>();
            adaptiveComponent.parameters = parameters;
            SetGID(adaptiveComponent);

            for(int i = 0; i < points.Count;i++)
            {
                GH_Point p = points[i];
                Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateFromSphere(new Rhino.Geometry.Sphere(p.Value, 0.5));
                SetPreview(adaptiveComponent.GID, srf.ToBrep());
                adaptiveComponent.points.Add(i,p.ToGrevitPoint());
            }



            
            DA.SetData("GrevitComponent", adaptiveComponent);
        }
예제 #47
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Boolean assoc = new GH_Boolean(false);
            GH_String name = new GH_String();
            GH_String layer = new GH_String("");
            GH_String style = new GH_String("");
            GH_String number = new GH_String();
            List<Parameter> param = new List<Parameter>();
            List<GH_Point> points = new List<GH_Point>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            if (!DA.GetDataList<GH_Point>("Points", points)) points = new List<GH_Point>();

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_Boolean>("Assoc", ref assoc);
            DA.GetData<GH_String>("Number", ref number);
            DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_String>("Layer", ref layer);

            Room ac = new Room(name.Value,number.Value,"",param);

            IEnumerable<GH_Point> nodups = points.Distinct(new GH_PointComparer());
            ac.points = new List<Grevit.Types.Point>();
            foreach (var p in nodups)
            {
                ac.points.Add(p.ToGrevitPoint());
            }

            ac.associative = assoc.Value;
            ac.FamilyOrStyle = style.Value;
            ac.TypeOrLayer = layer.Value;
            ac.GID = this.InstanceGuid.ToString();

            DA.SetData("GrevitComponent", ac);
        }
예제 #48
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grevit.Types.Component host = null;
            DA.GetData<Grevit.Types.Component>("Host", ref host);
            List<GH_Point> points = new List<GH_Point>();
            DA.GetDataList<GH_Point>("Points", points);
            GH_String view = new GH_String();
            GH_String level = new GH_String();
            DA.GetData<GH_String>("level", ref level);
            DA.GetData<GH_String>("View", ref view);
            GH_String family = new GH_String();
            GH_String type = new GH_String();

            Grevit.Types.StructuralType stype = StructuralType.NonStructural;
            DA.GetData<StructuralType>("StructuralType", ref stype);

            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_String>("Family", ref family);
            DA.GetData<GH_String>("Type", ref type);

            Familyinstance faimlyInstance = new Familyinstance();
            faimlyInstance.FamilyOrStyle = family.Value;
            faimlyInstance.TypeOrLayer = type.Value;
            faimlyInstance.structuralType = stype;
            faimlyInstance.level = level.Value;
            faimlyInstance.points = new List<Grevit.Types.Point>();
            faimlyInstance.parameters = parameters;
            faimlyInstance.view = view.Value;
            if (host != null)
            {
                faimlyInstance.referenceGID = host.GID;
                faimlyInstance.stalledForReference = true;
            }


            SetGID(faimlyInstance);

            foreach (GH_Point p in points) faimlyInstance.points.Add(p.ToGrevitPoint());
           
            DA.SetData("GrevitComponent", faimlyInstance);
        }
예제 #49
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point point = new GH_Point();
            Grevit.Types.Wall wall = null;

            GH_String layer = new GH_String("");
            GH_String style = new GH_String("");

            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            DA.GetData<GH_Point>("Point", ref point);
            DA.GetData<GH_String>("Layer", ref layer);
            DA.GetData<GH_String>("Style", ref style);
            DA.GetData<Wall>("wall", ref wall);

            Door d = new Door();
            SetGID(d);
            d.stalledForReference = true;
            d.TypeOrLayer = layer.Value;
            d.FamilyOrStyle = style.Value;
            d.locationPoint = point.ToGrevitPoint();
            d.parameters = param;
            SetGID(d);

               Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(point.Value, 0.5);
               Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0,0, 2));

            SetPreview(d.GID, srf.ToBrep());

            GH_Surface ghb = new GH_Surface(srf);

            DA.SetData("GrevitComponent", d);
        }
예제 #50
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String();
            GH_String phase = new GH_String();
            GH_String number = new GH_String();
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_String>("Number", ref number);
            DA.GetData<GH_String>("Phase", ref phase);

            Room room = new Room(name.Value,number.Value,phase.Value,parameters);

            room.GID = this.InstanceGuid.ToString();
           
            DA.SetData("GrevitComponent", room);
        }
예제 #51
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve curve = new GH_Curve();
            DA.GetData<GH_Curve>("Curve", ref curve);
            GH_String layer = new GH_String(string.Empty);
            DA.GetData<GH_String>("Layer", ref layer);

            Component c = curve.Value.ToNurbsCurve().ToGrevitCurve();
            c.TypeOrLayer = layer.ToString();
            SetGID(c);
            DA.SetData("GrevitComponent", c);
        }
예제 #52
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String content = new GH_String();
            GH_Point location = new GH_Point();
            GH_String view = new GH_String();
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_Point>("Location", ref location);
            DA.GetData<GH_String>("Text", ref content);
            DA.GetData<GH_String>("View", ref view);

            TextNote textnote = new TextNote();
            textnote.text = content.Value;
            textnote.view = view.Value;
            textnote.location = location.ToGrevitPoint();
            textnote.parameters = parameters;
            textnote.GID = this.InstanceGuid.ToString();

            DA.SetData("GrevitComponent", textnote);
        }
예제 #53
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String("");
            DA.GetData<GH_String>("Name", ref name);

            List<Types.Profile> profiles = new List<Types.Profile>();
            DA.GetDataList<Types.Profile>("Profiles", profiles);

            List<Types.Profile> returnProfiles = new List<Types.Profile>();

            foreach (Types.Profile profile in profiles)
            {
                if (profile.Name.ToLower() == name.Value.ToLower()) returnProfiles.Add(profile);
            }

            DA.SetDataList("Profile", returnProfiles);
        }
예제 #54
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {

            GH_String levelName = new GH_String();
            GH_String family = new GH_String("");
            GH_String type = new GH_String();

            List<Parameter> parameters = new List<Parameter>();
            List<GH_Curve> curves = new List<GH_Curve>();
            if (!DA.GetDataList<GH_Curve>("Profile", curves)) curves = new List<GH_Curve>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Level", ref levelName);


            List<Component> curveList = new List<Component>();
            foreach (GH_Curve curve in curves) curveList.Add(curve.ToGrevitCurve());
            
            WallProfileBased wall = new WallProfileBased(family.Value, type.Value,parameters, curveList, levelName.Value );

            SetGID(wall);

            DA.SetData("GrevitComponent", wall);
        }
예제 #55
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string serializedData = this.GetValue("assembly", "");

            if (serializedData != "")
            {
                this.assembly = (Types.Assembly)Serialization.Utilities.Deserialize(serializedData, typeof(Types.Assembly));
            }

            GH_String path = new GH_String("");
            DA.GetData<GH_String>("Path", ref path);
            GH_Boolean percentual = new GH_Boolean(false);
            if (!DA.GetData<GH_Boolean>("Percentual", ref percentual)) percentual.Value = false;

            this.isPercentual = percentual.Value;
            this.alternativeDataSourcePath = path.Value;

            //if (assembly != null) this.SetValue("assembly", Serialization.Utilities.Serialize(this.assembly));

            DA.SetData("Material", assembly);
        }
예제 #56
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve baseline = new GH_Curve();
            GH_String level = new GH_String("none");
            GH_Number height = new GH_Number();
            GH_Number offset = new GH_Number();
            GH_Boolean join = new GH_Boolean(true);
            GH_Boolean flip = new GH_Boolean(false);
            GH_String family = new GH_String("");
            GH_String type = new GH_String("none");

            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_Boolean>("Join", ref join);
            DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Levelbottom", ref level);
            DA.GetData<GH_Number>("Height", ref height);
            DA.GetData<GH_Curve>("Baseline", ref baseline);
            DA.GetData<GH_Boolean>("Flip", ref flip);


            Wall wall = new Wall(family.Value, type.Value, parameters, baseline.ToGrevitCurve(), level.Value,height.Value,join.Value,flip.Value );
            
            Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, new Rhino.Geometry.Vector3d(0, 0, height.Value));

            SetGID(wall);
            SetPreview(wall.GID, srf.ToBrep());
            
            DA.SetData("GrevitComponent", wall);
        }
예제 #57
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String("");
            GH_String view = new GH_String("");
            List<Rule> rules = new List<Rule>();
            List<GH_String> cats = new List<GH_String>();
            List<string> categories = new List<string>();

            GH_Colour CutFillColor = null;
            GH_Colour CutLineColor = null;
            GH_Colour ProjectionFillColor = null;
            GH_Colour ProjectionLineColor = null;
            GH_Integer CutLineWeight = new GH_Integer(-1);
            GH_Integer ProjectionLineWeight = new GH_Integer(-1);
            GH_String CutFillPattern = null;
            GH_String CutLinePattern = null;
            GH_String ProjectionFillPattern = null;
            GH_String ProjectionLinePattern = null;

            DA.GetData<GH_Colour>("CutFillColor", ref CutFillColor);
            DA.GetData<GH_Colour>("CutLineColor", ref CutLineColor);
            DA.GetData<GH_Colour>("ProjectionFillColor", ref ProjectionFillColor);
            DA.GetData<GH_Colour>("ProjectionLineColor", ref ProjectionLineColor);
            DA.GetData<GH_Integer>("CutLineWeight", ref CutLineWeight);
            DA.GetData<GH_Integer>("ProjectionLineWeight", ref ProjectionLineWeight);
            DA.GetData<GH_String>("CutFillPattern", ref CutFillPattern);
            DA.GetData<GH_String>("CutLinePattern", ref CutLinePattern);
            DA.GetData<GH_String>("ProjectionFillPattern", ref ProjectionFillPattern);
            DA.GetData<GH_String>("ProjectionLinePattern", ref ProjectionLinePattern);

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_String>("View", ref view);
            DA.GetDataList<Rule>("Rules",rules);
            DA.GetDataList<GH_String>("Categories",cats);

            foreach (GH_String cat in cats) categories.Add(cat.Value);

            Grevit.Types.Filter filter = new Filter()
            {
                name = name.Value,
                view = view.Value,
                categories = categories,
                Rules = rules
            };
            

            if (CutFillColor != null) filter.CutFillColor = CutFillColor.ToGrevitColor();
            if (CutLineColor != null) filter.CutLineColor = CutLineColor.ToGrevitColor();
            if (ProjectionFillColor != null) filter.ProjectionFillColor = ProjectionFillColor.ToGrevitColor();
            if (ProjectionLineColor != null) filter.ProjectionLineColor = ProjectionLineColor.ToGrevitColor();

            filter.CutLineWeight = CutLineWeight.Value;
            filter.ProjectionLineWeight = ProjectionLineWeight.Value;

            if (CutFillPattern != null) filter.CutFillPattern = CutFillPattern.Value;
            if (CutLinePattern != null) filter.CutLinePattern = CutLinePattern.Value;
            if (ProjectionFillPattern != null) filter.ProjectionFillPattern = ProjectionFillPattern.Value;
            if (ProjectionLinePattern != null) filter.ProjectionLinePattern = ProjectionLinePattern.Value;

            

            DA.SetData("GrevitComponent", filter);
        }
예제 #58
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String("");
            GH_String value = new GH_String("");
            GH_String eq = new GH_String("=");

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_String>("Value", ref value);
            DA.GetData<GH_String>("Operator", ref eq);

            Grevit.Types.Rule rule = new Rule()
            {
                name = name.Value,
                value = value.Value,
                equalityComparer = eq.Value
            };

            DA.SetData("GrevitComponent", rule);
        }
예제 #59
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String path = new GH_String();
            DA.GetData<GH_String>(0, ref path);

            List<GH_Brep> surfaces = new List<GH_Brep>();
            List<GH_String> layers = new List<GH_String>();
            List<Instance> Instances = new List<Instance>();

            SketchUp skp = new SketchUp();
            if (skp.LoadModel(path.Value))
            {
                foreach (Surface srf in skp.Surfaces)
                    surfaces.Add(new GH_Brep(srf.ToRhinoGeo()));

                foreach (Layer l in skp.Layers)
                    layers.Add(new GH_String(l.Name));

                foreach (Instance i in skp.Instances)
                    Instances.Add(i);
            }

            DA.SetDataList(0, surfaces);
            DA.SetDataList(1, layers);
            DA.SetDataList(2, Instances);
        }
예제 #60
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface = new GH_Surface();
            GH_String level = new GH_String();
            GH_String family = new GH_String("");
            GH_String type = new GH_String("");

            GH_Boolean structural = new GH_Boolean(false); 
            GH_Number slope = new GH_Number(0.0);
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();
            DA.GetData<GH_Surface>("Surface", ref surface);

            GH_Point slopeTopPoint = new GH_Point(surface.Value.Edges[0].PointAtStart);
            GH_Point slopeBottomPoint = new GH_Point(surface.Value.Edges[0].PointAtEnd);

            //DA.GetData<GH_String>("Family", ref family);
            //DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Levelbottom", ref level);
            DA.GetData<GH_Boolean>("Structural", ref structural);
            DA.GetData<GH_Point>("SlopeTopPoint", ref slopeTopPoint);
            DA.GetData<GH_Point>("SlopeBottomPoint", ref slopeBottomPoint);
            DA.GetData<GH_Number>("Slope", ref slope);

            

            Slab slab = new Slab();
            slab.FamilyOrStyle = family.Value;
            slab.TypeOrLayer = type.Value;
            slab.levelbottom = level.Value;
            slab.structural = structural.Value;
            slab.surface = new Profile();
            slab.surface.profile = new List<Loop>();
            
            Loop loop = new Loop();
            loop.outline = new List<Component>();

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }

            slab.surface.profile.Add(loop);

            slab.parameters = parameters;
            slab.top = slopeTopPoint.ToGrevitPoint();
            slab.bottom = slopeBottomPoint.ToGrevitPoint();
            slab.slope = slope.Value;
            slab.GID = this.InstanceGuid.ToString();



            DA.SetData("GrevitComponent", slab);
        }