Exemplo n.º 1
0
        public void TestSaveAs()
        {
            SketchUpNET.SketchUp skp = new SketchUp();
            string dir = System.IO.Path.GetDirectoryName(TestFile);

            skp.SaveAs(TestFile, SKPVersion.V2016, dir + "/NewFile.skp");
            Assert.IsTrue(System.IO.File.Exists(dir + "/NewFile.skp"));
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public void DoNotGetMesh()
 {
     SketchUpNET.SketchUp skp = new SketchUp();
     skp.LoadModel(TestFile, false);
     foreach (var srf in skp.Surfaces)
     {
         Assert.IsNull(srf.FaceMesh);
     }
 }
Exemplo n.º 4
0
 public void GetMesh()
 {
     SketchUpNET.SketchUp skp = new SketchUp();
     skp.LoadModel(TestFile, true);
     foreach (var srf in skp.Surfaces)
     {
         Assert.IsNotNull(srf.FaceMesh);
         Assert.IsTrue(srf.FaceMesh.Faces.Count > 0);
         Assert.IsTrue(srf.FaceMesh.Vertices.Count > 0);
     }
 }
Exemplo n.º 5
0
        public void TestSaveAsUTF8()
        {
            SketchUpNET.SketchUp skp = new SketchUp();
            string dir = System.IO.Path.GetDirectoryName(TestFile);

            skp.SaveAs(TestFile, SKPVersion.V2016, dir + "/Überß.skp");

            Assert.IsTrue(System.IO.File.Exists(dir + "/Überß.skp"));
            bool res = skp.LoadModel(dir + "/Überß.skp");

            Assert.IsTrue(res);
        }
Exemplo n.º 6
0
        public void GetMaterial()
        {
            SketchUpNET.SketchUp skp = new SketchUp();
            skp.LoadModel(TestFile, false);

            bool found = false;

            foreach (var srf in skp.Surfaces)
            {
                Assert.IsNotNull(srf.BackMaterial);
                Assert.IsNotNull(srf.FrontMaterial);
                Assert.IsNotNull(srf.BackMaterial.Colour);
                Assert.IsNotNull(srf.FrontMaterial.Colour);
                if (srf.BackMaterial.Name == "MyMat" || srf.FrontMaterial.Name == "MyMat")
                {
                    found = true;
                }
            }

            Assert.IsTrue(found);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }