private async Task <IActionResult> ValidateLogin() { Couple couple = await Database.GetCoupleAsAdminAsync(Id.Value, AdminCode); if (couple == null) { ModelState.AddModelError("CustomError", "Incorrect Id / Password "); return(Page()); } HttpContext.Session.SetInt32("Id", Id.Value); HttpContext.Session.SetString("AdminCode", AdminCode); RedirectUrl = HttpUtility.UrlDecode(RedirectUrl); if (string.IsNullOrEmpty(RedirectUrl)) { if (couple.IsAdmin) { RedirectUrl = ModelPath.Get <Management.EditDinnerModel>(); } else { RedirectUrl = ModelPath.Get <Couples.EditCoupleModel>(); } } return(RedirectToPage(RedirectUrl)); }
public void ModelPathBuilder_NCfileToolpathIsGood_ReturnsModelPath() { string inputFile = "STRAIGHT-TEST-8-3-15.nc"; double increment = .01; ToolPath5Axis toolpath = CNCFileParser.CreatePath(inputFile); Assert.AreEqual(1, toolpath[1].Position.X, "Xtp0"); Assert.AreEqual(1, toolpath[1].Position.Y, "Xtp0"); Assert.AreEqual(2, toolpath[1].Position.Z, "Xtp0"); ConstantDistancePathBuilder mpb = new ConstantDistancePathBuilder(); ModelPath mp = mpb.Build(toolpath, increment); int i = 0; while (!mp[i].JetOn) { i++; } Assert.AreEqual(1, mp[i].Position.X, "Xentity0"); Assert.AreEqual(1, mp[i].Position.Y, "Yentity0"); Assert.AreEqual(0, mp[i].Position.Z, "Zentity0"); Assert.AreEqual(1.0089, Math.Round(mp[i + 1].Position.X, 4), "Xentity1"); Assert.AreEqual(1.0045, Math.Round(mp[i + 1].Position.Y, 4), "Yentity1"); Assert.AreEqual(0, Math.Round(mp[i + 1].Position.Z, 4), "Zentity1"); Assert.AreEqual(10, mp[i + 1].Feedrate.Value, "Fentity1"); Assert.IsFalse(mp[0].JetOn, "Jentity0"); }
public AbmachSimModel2D(AbmachSurface modelSurf, ModelPath path, AbMachParameters parms) { this.surf = modelSurf; this.path = path; this.abmachParams = parms; this.runInfo = parms.RunInfo; }
/// <summary> /// This node will open the given file in the background. /// </summary> /// <param name="filePath">The file to obtain document from.</param> /// <param name="audit">Choose whether or not to audit the file upon opening. (Will run slower with this)</param> /// <param name="detachFromCentral">Choose whether or not to detach from central upon opening. Only for RVT files. </param> /// <returns name="document">The document object. Primarily for use with other Rhythm nodes.</returns> /// <search> /// Application.OpenDocumentFile, rhythm /// </search> public static string OpenDocumentFile(string filePath, bool audit = false, bool detachFromCentral = false) { var uiapp = DocumentManager.Instance.CurrentUIApplication; var app = uiapp.Application; Document doc; string docTitle = string.Empty; //instantiate open options for user to pick to audit or not OpenOptions openOpts = new OpenOptions(); openOpts.Audit = audit; TransmittedModelOptions tOpt = TransmittedModelOptions.SaveAsNewCentral; if (detachFromCentral == false) { openOpts.DetachFromCentralOption = DetachFromCentralOption.DoNotDetach; } else { openOpts.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets; } //convert string to model path for open ModelPath modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath); try { docTitle = DocumentUtils.OpenDocument(modelPath, openOpts); } catch (Exception) { //nothing } return(docTitle); }
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member internal LoanField(FieldDescriptor descriptor, Loan loan, ModelPath modelPath = null, int?borrowerPairIndex = null) { Descriptor = descriptor; Loan = loan; BorrowerPairIndex = borrowerPairIndex; _modelPath = modelPath ?? descriptor._modelPath; }
// In the example below, a document is opened with two worksets specified to be opened. // Note that the WorksharingUtils.GetUserWorksetInfo() method can be used to access workset // information from a closed Revit document. Document OpenDocumentWithWorksets(ModelPath projectPath) { Document doc = null; try { // Get info on all the user worksets in the project prior to opening IList <WorksetPreview> worksets = WorksharingUtils.GetUserWorksetInfo(projectPath); IList <WorksetId> worksetIds = new List <WorksetId>(); // Find two predetermined worksets foreach (WorksetPreview worksetPrev in worksets) { if (worksetPrev.Name.CompareTo("Workset1") == 0 || worksetPrev.Name.CompareTo("Workset2") == 0) { worksetIds.Add(worksetPrev.Id); } } OpenOptions openOptions = new OpenOptions(); // Setup config to close all worksets by default WorksetConfiguration openConfig = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets); // Set list of worksets for opening openConfig.Open(worksetIds); openOptions.SetOpenWorksetsConfiguration(openConfig); doc = _app.OpenDocumentFile(projectPath, openOptions); } catch (Exception e) { TaskDialog.Show("Open File Failed", e.Message); } return(doc); }
public static string saveCentralProd( UIApplication uiapp, string temp_file_path, string final_hashed_base_name) { Application app = uiapp.Application; FileInfo filePath = new FileInfo(temp_file_path); ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath( filePath.FullName); OpenOptions opt = new OpenOptions(); opt.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets; opt.AllowOpeningLocalByWrongUser = true; string new_path = FileManager.model_path + final_hashed_base_name + ".rvt"; if (!File.Exists(new_path)) { Document doc = app.OpenDocumentFile(mp, opt); SaveAsOptions options = new SaveAsOptions(); options.OverwriteExistingFile = true; ModelPath modelPathout = ModelPathUtils.ConvertUserVisiblePathToModelPath(new_path); doc.SaveAs(new_path, options); UIDocument uidoc2 = uiapp.OpenAndActivateDocument(FileManager.init_path); doc.Close(true); } return(new_path); }
public void LoadModel() { if (Model != null) { DestroyImmediate(Model); Model = null; } GameObject asset = AssetDatabase.LoadAssetAtPath <GameObject>(ModelPath); Model = Instantiate(asset); Gender = ModelPath.Contains("female") ? GenderEnum.Female : GenderEnum.Male; string gender = Gender == GenderEnum.Female ? "f_" : "m_"; BlendShapeLoader loader = BlendShapeLoader.GetComponent <BlendShapeLoader>(); loader.SetBlendShapesModel(gender + "blendsShapes"); if (Model != null) { SkinnedMeshRenderer renderer = Model.GetComponentInChildren <SkinnedMeshRenderer>(); if (renderer != null) { renderer.material = m_defaultMaterial; } Model.transform.position = Vector3.zero; Model.transform.SetParent(transform); //added for visualisation. ViewSkeleton skelVisual = Model.AddComponent <ViewSkeleton>(); skelVisual.rootNode = Model.transform; } }
private void ExtractInfo(DesignAutomationData _data) { var doc = _data.RevitDoc; LogTrace("Rvt File opened..."); var inputParameters = JsonConvert.DeserializeObject <InputParams>(File.ReadAllText("params.json")); LogTrace($"HubId: {inputParameters.HubId}"); LogTrace($"ProjectId: {inputParameters.ProjectId}"); LogTrace($"Filename: {inputParameters.Filename}"); GoodPracticeDocument data; using (Transaction trans = new Transaction(doc)) { trans.Start("Extract Good practices info"); data = new GoodPracticeDocument(inputParameters.HubId, inputParameters.ProjectId, inputParameters.Filename, inputParameters.Version, doc); LogTrace("Data get ok..."); trans.RollBack(); } //Save the updated file by overwriting the existing file ModelPath ProjectModelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(OUTPUT_FILE); var _path = ModelPathUtils.ConvertModelPathToUserVisiblePath(ProjectModelPath); //Save the project file with updated window's parameters LogTrace("Saving file..."); var json = JsonConvert.SerializeObject(data); File.WriteAllText(_path, json); }
public void SaveDetachworksets() { string mpath = ""; string mpathOnlyFilename = ""; FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); folderBrowserDialog1.Description = "Select Folder Where Revit Projects to be Saved in Local"; folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { mpath = folderBrowserDialog1.SelectedPath; FileInfo filePath = new FileInfo(projectPath); ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName); OpenOptions opt = new OpenOptions(); opt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets; mpathOnlyFilename = filePath.Name; Document openedDoc = app.OpenDocumentFile(mp, opt); SaveAsOptions options = new SaveAsOptions(); WorksharingSaveAsOptions wokrshar = new WorksharingSaveAsOptions(); wokrshar.SaveAsCentral = true; options.SetWorksharingOptions(wokrshar); ModelPath modelPathout = ModelPathUtils.ConvertUserVisiblePathToModelPath(mpath + "\\" + "Detached" + "_" + datetimesave + "_" + mpathOnlyFilename); openedDoc.SaveAs(modelPathout, options); openedDoc.Close(true); } }
private void ML_cmb_model_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (!this.IsLoaded) { return; } GB_ML_operation.IsEnabled = false; MLCore.MLModelSelected = (MLModel)ML_cmb_model.SelectedIndex; if (MLCore.MLModelSelected == MLModel.Yolo) { ML_cmb_dataset.Visibility = Visibility.Collapsed; Panel_ML_LabelJobType.Visibility = Visibility.Collapsed; TB_ML_modelName.Text = ModelPath.GetWeightFile(GV.ML_Folders[(int)MLFolders.ML_YOLO_model]); Exp_FileDirectory.Visibility = Visibility.Collapsed; Exp_ImgResizing.Visibility = Visibility.Collapsed; Exp_MeanCalculation.Visibility = Visibility.Collapsed; } else { ML_cmb_dataset.Visibility = Visibility.Visible; Panel_ML_LabelJobType.Visibility = Visibility.Visible; Exp_FileDirectory.Visibility = Visibility.Visible; Exp_ImgResizing.Visibility = Visibility.Visible; Exp_MeanCalculation.Visibility = Visibility.Visible; } }
private bool FindMasterPath() { bool found = false; string masterFilePath = ""; if (m_doc.IsWorkshared) { ModelPath modelPath = m_doc.GetWorksharingCentralModelPath(); masterFilePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelPath); if (string.IsNullOrEmpty(masterFilePath)) { masterFilePath = m_doc.PathName; } } else { masterFilePath = m_doc.PathName; } if (!string.IsNullOrEmpty(masterFilePath)) { found = true; } else { MessageBox.Show("Please save the current Revit project before running the tool.", "File Not Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); found = false; } return(found); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { View view = commandData.View; if (null == view) { message = "Please run this command in an active document."; return(Result.Failed); } else { Document doc = view.Document; ModelPath modelPath = ModelPathUtils .ConvertUserVisiblePathToModelPath( doc.PathName); ListLinks(modelPath); return(Result.Succeeded); } }
private void UpdateRFAinProject(Document doc) { //Load and update the family symbol instances present in the project //make changes to the documnet by modifying the family file //Open transaction using (Transaction updating_transaction = new Transaction(doc)) { //Start the transaction updating_transaction.Start("UPDATE THE PROJECT"); //FailureHandlingOptions will collect those warnings which occurs while importing the family file into the project and deletes those warning FailureHandlingOptions FH_options = updating_transaction.GetFailureHandlingOptions(); FH_options.SetFailuresPreprocessor(new Warning_Swallower()); updating_transaction.SetFailureHandlingOptions(FH_options); //Loads the new familysymbol FamilyLoadOptions FLO = new FamilyLoadOptions(); FamilySymbol new_FS = null; doc.LoadFamilySymbol(RFA_TEMP, "Chair", FLO, out new_FS); //project gets updated after loading the family file //Commit the transaction to save the changes updating_transaction.Commit(); } //save the project file in the same path after updating the project file //If the project file(.rvt) with same name already exists in the project path ,overwrite the already existing project file ModelPath Project_model_path = ModelPathUtils.ConvertUserVisiblePathToModelPath(RVT_OUTPUT); SaveAsOptions SAO = new SaveAsOptions(); SAO.OverwriteExistingFile = true; //Save the project file doc.SaveAs(Project_model_path, SAO); }
public async Task <IActionResult> OnGetAsync() { Couple = await GetAuthorizedCouple(); if (Couple == null) { return(NotFound()); } if (!Couple.Dinner.HasPrice) { return(Redirect(ModelPath.Get <Couples.EditCoupleModel>())); } var status = await Couple.UpdatePaymentStatus(); if (status.Changed) { await Database.SaveChangesAsync(); } PaymentStatus = status.NewStatus; return(Page()); }
private string GetCentralPath() { string centralPath = ""; try { if (m_doc.IsWorkshared) { ModelPath modelPath = m_doc.GetWorksharingCentralModelPath(); centralPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelPath); if (!string.IsNullOrEmpty(centralPath)) { validCentral = true; } else { //detached validCentral = false; centralPath = m_doc.PathName; } } else { validCentral = false; centralPath = m_doc.PathName; } } catch (Exception ex) { string message = ex.Message; } return(centralPath); }
public void Load_Form(UIApplication uiapp, Document doc) { try { data_revit_link item = (data_revit_link)link_file.SelectedItem; doc.Delete(item.type.Id); ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath(path); RevitLinkOptions rlo = new RevitLinkOptions(false); var linkType = RevitLinkType.Create(doc, mp, rlo); var instance = RevitLinkInstance.Create(doc, linkType.ElementId); List <Document> docs = new List <Document>(); foreach (Document d in uiapp.Application.Documents) { docs.Add(d); } item.document = docs.First(y => y.Title + ".rvt" == item.name); item.type = doc.GetElement(linkType.ElementId) as RevitLinkType; link_file.Items.Refresh(); MessageBox.Show(item.document.PathName); } catch (Exception ex) { MessageBox.Show(ex.Message); link_file.SelectedItem = null; } }
// bug683 fix: functie toegevoegd zodat IFC exporter selectief kan rapporteren welke files missen /// <summary> /// Geef alle gelinkte files die niet langer gevonden kunnen worden /// </summary> /// <param name="app"></param> /// <param name="addProj"></param> /// <returns></returns> // ReSharper disable once UnusedMember.Global public static List <string> GetMissingLinkedFiles(UIApplication app, bool addProj) { List <string> linkedProjects = new List <string>(); if (linkedProjects.Count == 0) { // er zijn waarschijnlijk worksets gebruikt ModelPath mdlPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(app.ActiveUIDocument.Document.PathName); TransmissionData transData = TransmissionData.ReadTransmissionData(mdlPath); if (transData != null) { ICollection <ElementId> externalReferences = transData.GetAllExternalFileReferenceIds(); foreach (ElementId refId in externalReferences) { ExternalFileReference curRef = transData.GetLastSavedReferenceData(refId); string refType = curRef.ExternalFileReferenceType.ToString(); string refPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(curRef.GetAbsolutePath()); if (refType == "RevitLink") { linkedProjects.Add(refPath); } } } } if (addProj) { linkedProjects.Add(app.ActiveUIDocument.Document.PathName); } //laatste check om te kijken of de links ook gevonden worden return(linkedProjects.Where(p => (false == File.Exists(p))).ToList()); }
private string GetFilePath() { string filePath = ""; try { if (m_doc.IsWorkshared) { ModelPath modelPath = m_doc.GetWorksharingCentralModelPath(); string centralPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelPath); if (!string.IsNullOrEmpty(centralPath)) { filePath = centralPath; } else { filePath = m_doc.PathName; } } else { filePath = m_doc.PathName; } } catch (Exception ex) { MessageBox.Show("Failed to get file path.\n" + ex.Message, "Get File Path", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(filePath); }
private void CloseModelLinks(ModelPath modelPath) { // Access transmission data in the given file TransmissionData trans = TransmissionData.ReadTransmissionData(modelPath); if (trans != null) { // collect all external references var externalReferences = trans.GetAllExternalFileReferenceIds(); foreach (ElementId extRefId in externalReferences) { var extRef = trans.GetLastSavedReferenceData(extRefId); if (extRef.ExternalFileReferenceType == ExternalFileReferenceType.RevitLink) { // var p = ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetPath()); //set data trans.SetDesiredReferenceData(extRefId, extRef.GetPath(), extRef.PathType, false); Debug.Write($"{extRef.GetPath().CentralServerPath} " + $"{extRef.GetPath().ServerPath}"); } } // make sure the IsTransmitted property is set trans.IsTransmitted = true; // modified transmissoin data must be saved back to the model TransmissionData.WriteTransmissionData(modelPath, trans); } }
public static string saveNewCentral( Application app, string source_path, string temp_file_path) { FileInfo filePath = new FileInfo(temp_file_path); ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath( filePath.FullName); OpenOptions opt = new OpenOptions(); opt.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets; opt.AllowOpeningLocalByWrongUser = true; string new_path = newpathName(source_path, temp_file_path); if (!File.Exists(new_path)) { Document doc = app.OpenDocumentFile(mp, opt); SaveAsOptions options = new SaveAsOptions(); options.OverwriteExistingFile = true; ModelPath modelPathout = ModelPathUtils.ConvertUserVisiblePathToModelPath(new_path); doc.SaveAs(new_path, options); doc.Close(true); } return(new_path); }
/// <summary> /// Loads a specified Revit link external resource. /// </summary> /// <param name="resourceReference">An ExternalResourceReference identifying which particular resource to load.</param> /// <param name="loadContent">An ExternalResourceLoadContent object that will be populated with load data by the /// server. There are different subclasses of ExternalResourceLoadContent for different ExternalResourceTypes.</param> private void LoadRevitLink(ExternalResourceReference resourceReference, ExternalResourceLoadContent loadContent) { LinkLoadContent linkLoadContent = (LinkLoadContent)loadContent; if (linkLoadContent == null) { throw new ArgumentException("Wrong type of ExternalResourceLoadContent (expecting a LinkLoadContent) for Revit links.", "loadContent"); } try { // Copy the file from the path under the server "root" folder to a secret "cache" folder on the users machine String fullCachedPath = GetFullLinkCachedFilePath(resourceReference); String cacheFolder = System.IO.Path.GetDirectoryName(fullCachedPath); if (!System.IO.Directory.Exists(cacheFolder)) { System.IO.Directory.CreateDirectory(cacheFolder); } String serverLinkPath = GetFullServerLinkFilePath(resourceReference); System.IO.File.Copy(serverLinkPath, fullCachedPath, true); // Overwrite ModelPath linksPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(fullCachedPath); linkLoadContent.SetLinkDataPath(linksPath); loadContent.LoadStatus = ExternalResourceLoadStatus.Success; } catch (System.Exception) { } }
public static string GetCentralFilePath(Document doc) { string centralPath = ""; try { if (!doc.IsWorkshared) { centralPath = doc.PathName; return(centralPath); } ModelPath centralModelPath = doc.GetWorksharingCentralModelPath(); if (null != centralModelPath) { string userVisiblePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(centralModelPath); if (!string.IsNullOrEmpty(userVisiblePath)) { centralPath = userVisiblePath; } else { centralPath = doc.PathName; } } } catch (Exception ex) { string message = ex.Message; } return(centralPath); }
/// <summary> /// Verifies whether the file is flagged as Transmitted or not. /// </summary> /// <param name="FilePath">Path to the file.</param> /// <returns name="bool">Returns true if file is marked as Transmitted. False if is not transmitted.</returns> public static bool IsTransmitted(string FilePath) { ModelPath mPath = Autodesk.Revit.DB.ModelPathUtils.ConvertUserVisiblePathToModelPath(FilePath); tData td = tData.ReadTransmissionData(mPath); return(td.IsTransmitted); }
public static object OpenDocumentFile(string filePath, bool audit = false, bool detachFromCentral = false, bool preserveWorksets = true, bool closeAllWorksets = false) { var uiapp = DocumentManager.Instance.CurrentUIApplication; var app = uiapp.Application; //instantiate open options for user to pick to audit or not OpenOptions openOpts = new OpenOptions { Audit = audit, DetachFromCentralOption = detachFromCentral == false ? DetachFromCentralOption.DoNotDetach : preserveWorksets == true ? DetachFromCentralOption.DetachAndPreserveWorksets : DetachFromCentralOption.DetachAndDiscardWorksets }; //TransmittedModelOptions tOpt = TransmittedModelOptions.SaveAsNewCentral; //option to close all worksets WorksetConfiguration worksetConfiguration = new WorksetConfiguration(WorksetConfigurationOption.OpenAllWorksets); if (closeAllWorksets) { worksetConfiguration = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets); } openOpts.SetOpenWorksetsConfiguration(worksetConfiguration); //convert string to model path for open ModelPath modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath); var document = app.OpenDocumentFile(modelPath, openOpts); return(document); }
/// <summary> /// Prepares the query by parsing instance and static paths to determine /// what information is being requested by the query. /// </summary> /// <param name="response"></param> internal void Prepare(ServiceResponse response) { if (Include != null && Include.Length > 0) { string paths = "{"; foreach (var p in Include) { var path = p.Replace(" ", ""); if (path.StartsWith("this.")) { path = path.Substring(5); } else if (path.StartsWith("this{")) { path = path.Substring(4); } ModelPath instancePath; if (From.TryGetPath(path, out instancePath)) { paths += path + ","; } else { PrepareStaticPath(path, response); } } if (paths.Length > 1) { Path = From.GetPath(paths.Substring(0, paths.Length - 1) + "}"); } } }
void GetKeynotesAssemblyCodesSharedParamAndLinks(IList <Document> targetDocumentsList, IList <string> targetList, Document activeDoc) { foreach (Document currentDoc in targetDocumentsList) { ModelPath targetLocation = ModelPathUtils.ConvertUserVisiblePathToModelPath(currentDoc.PathName); TransmissionData targetData = TransmissionData.ReadTransmissionData(targetLocation); if (targetData != null) { ICollection <ElementId> externalReferences = targetData.GetAllExternalFileReferenceIds(); foreach (ElementId currentFileId in externalReferences) { if (currentFileId != ElementId.InvalidElementId) { ExternalFileReference extRef = targetData.GetLastSavedReferenceData(currentFileId); //TODO CORRECT PROBLEMATIC IF STATEMENT HERE!!!!!!!!!!!!!!!!!! if (extRef.GetLinkedFileStatus() != LinkedFileStatus.Invalid) { ModelPath currenFileLink = extRef.GetAbsolutePath(); if (!currenFileLink.Empty) { string currentFileLinkString = ModelPathUtils.ConvertModelPathToUserVisiblePath(currenFileLink); CheckStringAValidLinkPathCorrectItAndAddToList(currentFileLinkString, targetList, activeDoc); } } } } } } }
void buildSurfaceFromToolpath(ModelPath path, double toolDiameter, double meshSize) { try { double xMin = path.JetOnBoundingBox.Min.X - toolDiameter; double yMin = path.JetOnBoundingBox.Min.Y - toolDiameter; double xMax = path.JetOnBoundingBox.Max.X + toolDiameter; double yMax = path.JetOnBoundingBox.Max.Y + toolDiameter; double zMin = path.JetOnBoundingBox.Min.Z - toolDiameter; double zMax = path.JetOnBoundingBox.Max.Z + toolDiameter; List <Vector3> pathAsVectors = new List <Vector3>(); foreach (ModelPathEntity mpe in path) { pathAsVectors.Add(mpe.PositionAsVector3); } BoundingBox boundingBox = new BoundingBox(xMin, yMin, path.JetOnBoundingBox.Min.Z, xMax, yMax, path.JetOnBoundingBox.Max.Z); if (model2dMode) { surface2D = new Abmach2DSurface(boundingBox, meshSize, toolDiameter); //surface2D = Surface2DBuilder<AbmachPoint>.Build(boundingBox, meshSize); //targetSurface2D = Surface2DBuilder<AbmachPoint>.Build(boundingBox, meshSize); } else { // surface3D = OctreeBuilder<AbmachPoint>.Build(pathAsVectors, meshSize); } } catch (Exception) { throw; } }
public string GetFilenameHint(Document doc) { string filename = ""; string folder = String.Empty; if (String.IsNullOrEmpty(doc.PathName) == false) { filename = Path.GetFileNameWithoutExtension(doc.PathName); if (doc.IsWorkshared) { folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); ModelPath mp = doc.GetWorksharingCentralModelPath(); if (mp is FilePath) { string modelPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(mp); folder = Path.GetDirectoryName(modelPath); if (Directory.Exists(Path.Combine(folder, "Snapshots"))) { folder = Path.Combine(folder, "Snapshots"); // encourage this. } filename = Path.GetFileNameWithoutExtension(modelPath); } } else { folder = Path.GetDirectoryName(doc.PathName); filename = Path.GetFileNameWithoutExtension(doc.PathName); } filename = getLastFilename(folder, filename); } return(filename); }
public static Dictionary <string, object> openDocumentBackground(string filePath = null, OpenOptions openOption = null) { string message = ""; Document doc = DocumentManager.Instance.CurrentDBDocument; Document openedDoc = null; UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; UIDocument uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument; ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath); try { openedDoc = app.OpenDocumentFile(path, openOption); message = "Opened"; } catch (Exception ex) { message = ex.Message; } return(new Dictionary <string, object> { { "document", openedDoc }, { "message", message } }); }