コード例 #1
0
        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));
        }
コード例 #2
0
        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");
        }
コード例 #3
0
 public AbmachSimModel2D(AbmachSurface modelSurf, ModelPath path, AbMachParameters parms)
 {
     this.surf         = modelSurf;
     this.path         = path;
     this.abmachParams = parms;
     this.runInfo      = parms.RunInfo;
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: LoanField.cs プロジェクト: jwwicks/Encompass.Rest
#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;
        }
コード例 #6
0
        // 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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
    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;
        }
    }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: T.SaveDetach.cs プロジェクト: khanhcegvn/TVDCEG
        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);
            }
        }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: Commands.cs プロジェクト: TDdJones/inventor2Revit
        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);
        }
コード例 #15
0
        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());
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: E_LoadForm.cs プロジェクト: karthi1015/RevitTool
        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;
            }
        }
コード例 #18
0
        // 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());
        }
コード例 #19
0
        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);
        }
コード例 #20
0
ファイル: Updater.cs プロジェクト: Vitaclick/Revit.Updater
        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);
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        /// <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)
            {
            }
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        /// <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);
        }
コード例 #25
0
        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);
        }
コード例 #26
0
            /// <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) + "}");
                    }
                }
            }
コード例 #27
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: Form1.cs プロジェクト: 1907931256/MasterProject
 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;
     }
 }
コード例 #29
0
        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);
        }
コード例 #30
0
        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 }
            });
        }