Esempio n. 1
0
        //The code sample below obtains the current project, if the active drawing is part of the project.
        public static Project PnPActiveProject()
        {
            Database    oDatabase = AcadApp.DocumentManager.MdiActiveDocument.Database;
            PnIdProject oPrj      = (PnIdProject)PlantApplication.CurrentProject.ProjectParts["PnId"];

            if (oPrj == null)
            {
                return(null);              //No P&ID Project loaded
            }
            List <PnPProjectDrawing> oDwgList = oPrj.GetPnPDrawingFiles();

            foreach (PnPProjectDrawing oDwg in oDwgList)
            {
                if (String.Equals(oDatabase.Filename, oDwg.ResolvedFilePath, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oPrj);
                }
            }
            return(null);    //ActiveDocument is not in the CurrentProject
        }
Esempio n. 2
0
        public static void Project_Settings()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            // 1.18 Declare a variable as a PlantProject. Instantiate it using
            // the CurrentProject of PlantApplication. (PlantApplication is a singleton)
            PlantProject currentProj = PlantApplication.CurrentProject;

            try
            {
                // 1.19 Declare a variable as a PnIdProject. Instantiate it using the
                // ProjectParts property of the CurrentProject of the PlantProject from step 1.18.
                // Use square brackets [] to specify a string identifier. For the string
                // property use "PnID". Need to cast it using (PnIdProject)
                // Note: Need to add a reference to PnIdProjectPartsMgd.dll this is dll is Missing
                // from the PlantSDK. Reference it from the ACAD.EXE folder instead.
                PnIdProject PnIdProj = (PnIdProject)currentProj.ProjectParts["PnID"];



                // 1.20 Use the WriteMessage function of the editor created above (ed).
                // Print out the GapWidth property of the PnIdProject from step 1.19.
                // Use a string similar to this: "\nGap Width = " + use ToString()
                ed.WriteMessage("\nGap Width = " + PnIdProj.GapWidth.ToString());


                // 1.21 Change the GapWidth property to .125
                PnIdProj.GapWidth = .125;

                // 1.22 Use the WriteMessage function of the editor created above (ed).
                // Print out the value of the GapLoop property of the PnIdProject from step 1.19.
                // Use a string similar to this: "\nGapLoop  = " + use ToString().
                // (this value is a bool)
                ed.WriteMessage("\nGapLoop  = " + PnIdProj.GapLoop().ToString());


                // 1.23 Declare a variable as a PipingProject. Instantiate it using the
                // ProjectParts property of the CurrentProject of the PlantProject from step 1.18.
                // Use square brackets [] to specify a string identifier. For the string
                // property use "Piping". Need to cast it using (PipingProject)
                // Note: Need to add a reference to PnP3dProjectPartsMgd.dll for PipingProject
                PipingProject pipeProj = (PipingProject)currentProj.ProjectParts["Piping"];

                // 1.24 Use the WriteMessage function of the editor created above (ed).
                // Print out the Minimum Pipe Length property of the PipingProject from step 1.23.
                // Use a string similar to this: "\nMinimum Pipe Length = " + use ToString()
                ed.WriteMessage("\nMinimum Pipe Length = " + pipeProj.MinimumPipeLength.ToString());

                // 1.25 Change the MinimumPipeLength property of the PipingProject from step 1.23.
                // to 10
                pipeProj.MinimumPipeLength = 10;

                // 1.26 Change the WeldGapSize property of the PipingProject from step 1.23.
                // to .125
                pipeProj.WeldGapSize = .125;

                // 1.27 Use the WriteMessage function of the editor created above (ed).
                // Print out the value of UseWeldGaps of the PipingProject from step 1.23.
                // Use a string similar to this: "\nUse Weld Gaps = " + use ToString()
                ed.WriteMessage("\nUse Weld Gaps = " + pipeProj.UseWeldGaps.ToString());

                // 1.28 Change the UseWeldGaps of the PipingProject to true
                pipeProj.UseWeldGaps = true;
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.ToString());
            }
        }