Пример #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string id = null;

            DA.GetData(0, ref id);

            Rhino.DocObjects.ObjRef geoRef = new ObjRef(new Guid(id));
            var geoObj = geoRef.Object();

            string name = null;

            DA.GetData(1, ref name);

            geoObj.Attributes.Name = name;
            geoObj.CommitChanges();

            string geoID = geoRef.ObjectId.ToString();

            DA.SetData(0, geoRef.Geometry());
            DA.SetData(1, geoID);

            //Confirmation routine.
            ObjRef confRef = new ObjRef(new Guid(geoID));

            string confName    = confRef.Object().Name;
            string confGeoType = confRef.Geometry().ObjectType.ToString();

            string confString = confGeoType + " > " + confName + " [" + geoID.ToString() + "]";

            DA.SetData(2, confString);
        }
Пример #2
0
        /// <summary>
        /// Convert a Rhino object reference to Nucleus geometry with attached
        /// attributes.
        /// </summary>
        /// <param name="objRef"></param>
        /// <returns></returns>
        public static VertexGeometry Convert(ObjRef objRef)
        {
            VertexGeometry result = Convert(objRef.Geometry());

            if (result != null)
            {
                GeometryAttributes attributes = new GeometryAttributes();
                int layerIndex = objRef.Object().Attributes.LayerIndex;
                attributes.LayerName = RhinoDoc.ActiveDoc.Layers[layerIndex].Name;
                attributes.SourceID  = objRef.ObjectId.ToString();
                result.Attributes    = attributes;
            }
            return(result);
        }
Пример #3
0
        internal static GetObject g_active_go; // = null; [runtime default]

        private static bool CustomGeometryFilter(IntPtr rhObject, IntPtr ptrGeometry, ComponentIndex componentIndex)
        {
            bool rc = true;

            if (g_active_go != null)
            {
                try
                {
                    RhinoObject rh_object = RhinoObject.CreateRhinoObjectHelper(rhObject);
                    using (var or = new ObjRef(rh_object, ptrGeometry))
                    {
                        GeometryBase geom = or.Geometry();
                        rc = g_active_go.CustomGeometryFilter(rh_object, geom, componentIndex);
                    }
                }
                catch (Exception ex)
                {
                    Runtime.HostUtils.ExceptionReport(ex);
                }
            }
            return(rc);
        }
Пример #4
0
 public static FaceEntity TryGetOrphanedFaceEntity(this ObjRef roomHostRef) => FaceEntity.TryGetFrom(roomHostRef.Geometry());
Пример #5
0
 public static ShadeEntity TryGetShadeEntity(this ObjRef rhinoRef) => ShadeEntity.TryGetFrom(rhinoRef.Geometry());
Пример #6
0
 public static DoorEntity TryGetDoorEntity(this ObjRef rhinoRef) => DoorEntity.TryGetFrom(rhinoRef.Geometry());
Пример #7
0
 public static ApertureEntity TryGetApertureEntity(this ObjRef rhinoRef) => ApertureEntity.TryGetFrom(rhinoRef.Geometry());
Пример #8
0
 public static RoomEntity TryGetRoomEntity(this ObjRef rhinoRef) => RoomEntity.TryGetFrom(rhinoRef.Geometry());
Пример #9
0
 public static bool IsDoor(this ObjRef rhinoRef) => rhinoRef.Geometry().IsDoor();
Пример #10
0
 public static bool IsAperture(this ObjRef rhinoRef) => rhinoRef.Geometry().IsAperture();
Пример #11
0
 public static bool IsRoom(this ObjRef rhinoRef) => rhinoRef.Geometry().IsRoom();
Пример #12
0
        private static void ExportToJson(List <string> guids)
        {
            var doc = Rhino.RhinoDoc.ActiveDoc;
            ObjectEnumeratorSettings settings = new ObjectEnumeratorSettings();

            settings.ActiveObjects = true;
            List <Guid> ids     = new List <Guid>();
            var         objrefs = doc.Objects.GetObjectList(settings);


            List <Element> allElements = new List <Element>();


            foreach (var rhinoobj in objrefs)
            {
                var  obj            = new ObjRef(rhinoobj.Id);
                var  material       = rhinoobj.GetMaterial(true);
                var  mesh           = new va3c_Mesh();
                Mesh finalMesh      = new Mesh();
                var  parameterNames = new List <string> {
                    "objectId"
                };
                var parameterValues = new List <string> {
                    obj.ObjectId.ToString()
                };
                RCva3c.Material mat;
                if (material != null)
                {
                    mat = new va3c_MeshPhongMaterial().GeneratePhongMaterial(material.Id, material.DiffuseColor, material.AmbientColor, material.EmissionColor, material.SpecularColor, material.Shine, 1 - material.Transparency);
                }
                else
                {
                    mat = new va3c_MeshBasicMaterial().GenerateMaterial(System.Drawing.Color.White, 1);
                }

                switch (obj.Geometry().ObjectType)
                {
                case ObjectType.None:
                    break;

                case ObjectType.Point:
                    break;

                case ObjectType.PointSet:
                    break;

                case ObjectType.Curve:
                    break;

                case ObjectType.Surface:
                    var srf     = obj.Surface();
                    var meshSrf = Mesh.CreateFromBrep(srf.ToBrep());
                    if (meshSrf?.Length > 0)
                    {
                        foreach (var m in meshSrf)
                        {
                            finalMesh.Append(m);
                        }
                    }
                    allElements.Add(mesh.GenerateMeshElement(finalMesh, mat, obj.ObjectId, parameterNames, parameterValues));
                    break;

                case ObjectType.Brep:
                    var brep     = obj.Brep();
                    var meshBrep = Mesh.CreateFromBrep(brep);
                    if (meshBrep?.Length > 0)
                    {
                        foreach (var m in meshBrep)
                        {
                            finalMesh.Append(m);
                        }
                    }
                    allElements.Add(mesh.GenerateMeshElement(finalMesh, mat, obj.ObjectId, parameterNames, parameterValues));
                    break;

                case ObjectType.Mesh:
                    var msh = obj.Mesh();
                    allElements.Add(mesh.GenerateMeshElement(msh, mat, obj.ObjectId, parameterNames, parameterValues));
                    break;

                case ObjectType.Light:
                    break;

                case ObjectType.Annotation:
                    break;

                case ObjectType.InstanceDefinition:
                    break;

                case ObjectType.InstanceReference:
                    break;

                case ObjectType.TextDot:
                    break;

                case ObjectType.Grip:
                    break;

                case ObjectType.Detail:
                    break;

                case ObjectType.Hatch:
                    break;

                case ObjectType.MorphControl:
                    break;

                case ObjectType.BrepLoop:
                    break;

                case ObjectType.PolysrfFilter:
                    break;

                case ObjectType.EdgeFilter:
                    break;

                case ObjectType.PolyedgeFilter:
                    break;

                case ObjectType.MeshVertex:
                    break;

                case ObjectType.MeshEdge:
                    break;

                case ObjectType.MeshFace:
                    break;

                case ObjectType.Cage:
                    break;

                case ObjectType.Phantom:
                    break;

                case ObjectType.ClipPlane:
                    break;

                case ObjectType.Extrusion:

                    var extruction     = obj.Brep();
                    var meshExtruction = Mesh.CreateFromBrep(extruction);
                    if (meshExtruction?.Length > 0)
                    {
                        foreach (var m in meshExtruction)
                        {
                            finalMesh.Append(m);
                        }
                    }
                    allElements.Add(mesh.GenerateMeshElement(finalMesh, mat, obj.ObjectId, parameterNames, parameterValues));
                    break;

                case ObjectType.AnyObject:
                    break;

                default:
                    break;
                }
            }


            var         scenecompiler = new va3c_SceneCompiler();
            string      resultatas    = scenecompiler.GenerateSceneJson(doc.Name.Replace(".3dm", ""), allElements);
            FileManager writer        = new FileManager();

            writer.SaveFileTo(new List <string> {
                resultatas
            });
        }