Exemplo n.º 1
0
 public static XYZ ToXYZ(this Grevit.Types.Point p, CoordinatesOverride coordoverride)
 {
     if (coordoverride != null)
     {
         return(coordoverride.ApplyOverride(p));
     }
     else
     {
         return(new XYZ(p.x * GrevitBuildModel.Scale, p.y * GrevitBuildModel.Scale, p.z * GrevitBuildModel.Scale));
     }
 }
Exemplo n.º 2
0
        public XYZ ApplyOverride(Grevit.Types.Point point)
        {
            switch (Coordinate)
            {
            case Revit.Coordinate.X:
                return(new XYZ(Value, point.y, point.z));

            case Revit.Coordinate.Y:
                return(new XYZ(point.x, Value, point.z));

            case Revit.Coordinate.Z:
                return(new XYZ(point.x, point.y, Value));

            default:
                return(new XYZ(point.x, point.y, point.z));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get Grevit Points
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static Tuple <Grevit.Types.Point, Grevit.Types.Point> ToGrevitPoints(this GH_Line curve)
        {
            Grevit.Types.Point p1 = new Grevit.Types.Point()
            {
                x  = curve.Value.From.X,
                y  = curve.Value.From.Y,
                z  = curve.Value.From.Z,
                id = curve.ReferenceID.ToString()
            };

            Grevit.Types.Point p2 = new Grevit.Types.Point()
            {
                x  = curve.Value.To.X,
                y  = curve.Value.To.Y,
                z  = curve.Value.To.Z,
                id = curve.ReferenceID.ToString()
            };

            return(new Tuple <Grevit.Types.Point, Grevit.Types.Point>(p1, p2));
        }
Exemplo n.º 4
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);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get Grevit Points
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static Tuple<Grevit.Types.Point, Grevit.Types.Point> ToGrevitPoints(this GH_Line curve)
        {
            Grevit.Types.Point p1 = new Grevit.Types.Point()
            {
                x = curve.Value.From.X,
                y = curve.Value.From.Y,
                z = curve.Value.From.Z,
                id = curve.ReferenceID.ToString()
            };

            Grevit.Types.Point p2 = new Grevit.Types.Point()
            {
                x = curve.Value.To.X,
                y = curve.Value.To.Y,
                z = curve.Value.To.Z,
                id = curve.ReferenceID.ToString()
            };

            return new Tuple<Grevit.Types.Point, Grevit.Types.Point>(p1, p2);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Get Grevit Point
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 public static Grevit.Types.Point ToGrevitPoint(this GH_Point point)
 {
     Grevit.Types.Point grevitPoint = new Grevit.Types.Point(point.Value.X, point.Value.Y, point.Value.Z);
     grevitPoint.id = point.ReferenceID.ToString();
     return grevitPoint;
 }
Exemplo n.º 7
0
        public static ComponentCollection Translate(string filename)
        {
            SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
            if (skp.LoadModel(filename))
            {
                Grevit.Types.ComponentCollection components = new ComponentCollection()
                {
                    Items = new List <Component>()
                };
                components.scale  = 3.28084;
                components.update = true;
                components.delete = false;

                foreach (SketchUpNET.Instance instance in skp.Instances)
                {
                    SketchUpNET.Transform transform = instance.Transformation;
                    transform.Data[12] /= 39.3701;
                    transform.Data[13] /= 39.3701;
                    transform.Data[14] /= 39.3701;

                    string elementType = instance.Parent.Name.ToLower();
                    string family      = instance.Parent.Name;
                    string type        = instance.Parent.Name;

                    if (instance.Parent.Description.Contains(";"))
                    {
                        string[] data = instance.Parent.Description.Split(';');
                        family = data[0];
                        type   = data[1];
                    }

                    if (elementType.Contains("wall"))
                    {
                        foreach (SketchUpNET.Surface surface in instance.Parent.Surfaces)
                        {
                            components.Items.Add(new WallProfileBased(family, type, new List <Types.Parameter>(), surface.ToGrevitOutline(transform), "")
                            {
                                GID = instance.Guid
                            });
                        }
                    }
                    else if (elementType.Contains("grid"))
                    {
                        foreach (SketchUpNET.Edge edge in instance.Parent.Edges)
                        {
                            components.Items.Add(new Grid(new List <Types.Parameter>(), edge.Start.ToGrevitPoint(transform), edge.End.ToGrevitPoint(transform), instance.Parent.Name)
                            {
                                GID = instance.Guid
                            });
                        }
                    }
                    else if (elementType.Contains("line"))
                    {
                        foreach (SketchUpNET.Edge edge in instance.Parent.Edges)
                        {
                            components.Items.Add(new RevitLine()
                            {
                                curve = edge.ToGrevitLine(transform), isModelCurve = true, isDetailCurve = false, isRoomBounding = false, parameters = new List <Parameter>(), GID = instance.Guid, FamilyOrStyle = family, TypeOrLayer = type
                            });
                        }
                    }
                    else if (elementType.Contains("floor"))
                    {
                        foreach (SketchUpNET.Surface surface in instance.Parent.Surfaces)
                        {
                            Types.Point bottom = transform.GetTransformed(surface.Vertices[0]).ToGrevitPoint();
                            int         ctr    = surface.Vertices.Count / 2;
                            Types.Point top    = transform.GetTransformed(surface.Vertices[ctr]).ToGrevitPoint();



                            components.Items.Add(new Slab()
                            {
                                FamilyOrStyle = family,
                                TypeOrLayer   = type,
                                parameters    = new List <Types.Parameter>(),
                                structural    = true,
                                height        = 1,
                                surface       =
                                    surface.ToGrevitProfile(transform),
                                bottom      = bottom,
                                top         = top,
                                slope       = top.z - bottom.z,
                                GID         = instance.Guid,
                                levelbottom = "",
                            });
                        }
                    }
                    else if (elementType.Contains("column"))
                    {
                        Grevit.Types.Profile profile = null;
                        Grevit.Types.Point   top     = null;
                        SketchUpNET.Vertex   v       = new SketchUpNET.Vertex(0, 0, 0);
                        Grevit.Types.Point   btm     = v.ToGrevitPoint(transform);

                        foreach (SketchUpNET.Surface surface in instance.Parent.Surfaces)
                        {
                            if (surface.Normal.Z == 1)
                            {
                                top = new Types.Point(v.ToGrevitPoint(transform).x, v.ToGrevitPoint(transform).y,
                                                      surface.Vertices[0].ToGrevitPoint(transform).z);
                            }
                        }

                        components.Items.Add(new Grevit.Types.Column(family, type, new List <Types.Parameter>(), btm, top, "", true)
                        {
                            GID = instance.Guid
                        });
                    }
                }

                return(components);
            }
            return(null);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Returns a new Revit XYZ Point
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static XYZ ToXYZ(this Grevit.Types.Point p)
 {
     return(new XYZ(p.x * GrevitBuildModel.Scale, p.y * GrevitBuildModel.Scale, p.z * GrevitBuildModel.Scale));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Get Grevit Point
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 public static Grevit.Types.Point ToGrevitPoint(this GH_Point point)
 {
     Grevit.Types.Point grevitPoint = new Grevit.Types.Point(point.Value.X, point.Value.Y, point.Value.Z);
     grevitPoint.id = point.ReferenceID.ToString();
     return(grevitPoint);
 }