Example #1
0
        public void ImportFromKinect()
        {
            Document doc =
                Autodesk.AutoCAD.ApplicationServices.
                Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            Transaction tr =
                doc.TransactionManager.StartTransaction();

            // Pass in a default radius of 5cm and a segment length
            // of 10 times that

            KinectSegmentedSolidsJig kj =
                new KinectSegmentedSolidsJig(doc, tr, 0.05, 10);

            kj.InitializeSpeech();

            if (!kj.StartSensor())
            {
                ed.WriteMessage(
                    "\nUnable to start Kinect sensor - " +
                    "are you sure it's plugged in?"
                    );
                tr.Dispose();
                return;
            }

            PromptResult pr = ed.Drag(kj);

            if (pr.Status != PromptStatus.OK && !kj.Finished)
            {
                kj.StopSensor();
                kj.Cleanup();
                tr.Dispose();
                return;
            }

            // Generate a final point cloud with color before stopping
            // the sensor

            kj.UpdatePointCloud();
            kj.StopSensor();

            kj.AddSolidOrPath();
            tr.Commit();

            // Manually dispose to avoid scoping issues with
            // other variables

            tr.Dispose();

            kj.WriteAndImportPointCloud(doc, kj.Vectors);
        }
    public void ImportFromKinect()
    {
      Document doc =
        Autodesk.AutoCAD.ApplicationServices.
          Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;

      Transaction tr =
        doc.TransactionManager.StartTransaction();

      // Pass in a default radius of 5cm and a segment length
      // of 10 times that

      KinectSegmentedSolidsJig kj =
        new KinectSegmentedSolidsJig(doc, tr, 0.05, 10);
      
      kj.InitializeSpeech();

      if (!kj.StartSensor())
      {
        ed.WriteMessage(
          "\nUnable to start Kinect sensor - " +
          "are you sure it's plugged in?"
        );
        tr.Dispose();
        return;
      }

      PromptResult pr = ed.Drag(kj);

      if (pr.Status != PromptStatus.OK && !kj.Finished)
      {
        kj.StopSensor();
        kj.Cleanup();
        tr.Dispose();
        return;
      }

      // Generate a final point cloud with color before stopping
      // the sensor

      kj.UpdatePointCloud();
      kj.StopSensor();

      kj.AddSolidOrPath();
      tr.Commit();

      // Manually dispose to avoid scoping issues with
      // other variables

      tr.Dispose();

      kj.WriteAndImportPointCloud(doc, kj.Vectors);
    }
        public void ImportFromKinect()
        {
            var doc =
                Autodesk.AutoCAD.ApplicationServices.
                Application.DocumentManager.MdiActiveDocument;
            var ed = doc.Editor;

            using (var tr = doc.TransactionManager.StartTransaction())
            {
                // Pass in a default radius of 5cm and a segment length
                // of 10 times that

                var kj = new KinectSegmentedSolidsJig(doc, tr, 0.05, 10);

                // The Body data from KfW 2 gives fals positives, saying
                // the hands are close to one another. Set a timer to stop
                // the code from checking during an initial, 3 second
                // callibrating phase

                var tm = new Timer();
                tm.Interval = 3000;
                tm.Elapsed +=
                    (s, e) =>
                {
                    kj.Callibrating = false;
                    tm.Stop();
                };
                tm.Start();

                kj.InitializeSpeech();

                if (!kj.StartSensor())
                {
                    ed.WriteMessage(
                        "\nUnable to start Kinect sensor - " +
                        "are you sure it's plugged in?"
                        );
                    return;
                }

                var pr = ed.Drag(kj);

                if (pr.Status != PromptStatus.OK && !kj.Finished)
                {
                    kj.StopSensor();
                    kj.Cleanup();
                    return;
                }

                // Generate a final point cloud with color before stopping
                // the sensor

                kj.UpdatePointCloud();
                kj.StopSensor();

                kj.AddSolidOrPath();
                tr.Commit();

                kj.WriteAndImportPointCloud(doc, kj.Vectors);
            }
        }