Example #1
0
 public ModelingCommands(IApplicationData data, IRModelingManager modeler)
 {
     _data    = data;
     _modeler = modeler;
 }
Example #2
0
        private void buttonCustomimportHandler()
        {
            try
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                openFileDialog1.Title = "Browse Custom Geometry File";

                openFileDialog1.CheckFileExists = true;
                openFileDialog1.CheckPathExists = true;

                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }



                XmlSerializer bf = new XmlSerializer(typeof(RevitData));

                FileStream fsout = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate);

                RevitData ddata = null;

                using (fsout)
                {
                    ddata = (RevitData)bf.Deserialize(fsout);
                }

                if (ddata == null)
                {
                    MessageBox.Show("invalid format or deser failed.");
                    return;
                }

                IRModelingManager modelingManager = GetModelingManager();

                //foreach (var def in ddata.Definitions)
                //{
                //    var v = new List<double>();
                //    var i = new List<int>();
                //    def.Faces.ForEach((f) =>
                //    {
                //        f.Mesh.Vertices.ForEach((vi) =>
                //        {
                //            v.Add(vi.x);
                //            v.Add(vi.y);
                //            v.Add(vi.z);
                //        });

                //        f.Mesh.Facets.ForEach((fc) =>
                //        {
                //            int vstride = 0;
                //            if (v.Count != 0)
                //            {
                //                if ((v.Count % 3) != 0)
                //                    throw new Exception("Vertex parse error");
                //                else
                //                    vstride = v.Count / 3;
                //            }

                //            i.Add(vstride + fc.V1);
                //            i.Add(vstride + fc.V2);
                //            i.Add(vstride + fc.V3);

                //        });

                //    });



                //    foreach (var inst in def.Instances)
                //    {

                //    }
                //}

                modelingManager.CreateCustomData(openFileDialog1.FileName, ddata as object);


                string cc = modelingManager.GetNumberOfDrawables();

                Data.Eventaggregator.GetEvent <Viewer.Infrastructure.StatusBarMessageEvent>().Publish("Drawables Count " + cc);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Import Failed " + ex.ToString());
            }
        }