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 KinectTorusJig kj = new KinectTorusJig(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); }