private static Result OnFindCommand(UIDocument ui_doc, FS_FEATURE_TYPE feature_type, string command_name, string shape_name, Action <Document, FS_FEATURE_RESULT?> post_action) { uint index; XYZ ray_origin = XYZ.Zero, ray_direction = XYZ.Zero; try { GenerateRay(ui_doc, out ray_origin, out ray_direction); } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return(Result.Cancelled); } // cast ray to point cloud and get an index of the point hit. if (OutlierPointCloudEngine.Cast(ray_origin, ray_direction, 0.01f, out index) == false) { TaskDialog.Show(command_name, "There is no points picked."); return(Result.Failed); } // run FindSurface to find shape FS_FEATURE_RESULT?result = FindSurface.RunFindSurface(feature_type, index); if (result == null) { TaskDialog.Show(command_name, $"FindSurface failed to find a {shape_name}."); return(Result.Failed); } post_action(ui_doc.Document, result); return(Result.Succeeded); }
private static extern int findSurface(IntPtr context, FS_FEATURE_TYPE type, uint start_index, ref _FS_FEATURE_RESULT result);
public FS_FEATURE_RESULT?RunFindSurface(FS_FEATURE_TYPE type, uint start_index) { _FS_FEATURE_RESULT _tmp = new _FS_FEATURE_RESULT(); return((findSurface(context, type, start_index, ref _tmp) == 0) ? _GetResult(_tmp) : null); }