Exemple #1
0
        updateBrkLines()
        {
            bool     exists     = false;
            ObjectId idDictHist = ObjectId.Null;

            try
            {
                idDictHist = Dict.getNamedDictionary("HISTORY", out exists);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} UBL.cs: line: 23", ex.Message));
            }
            if (!exists)
            {
                MessageBox.Show("Dictionary HISTORY not present - drawing not compatible with this command. Exiting....");
                return;
            }

            ResultBuffer rb = Dict.getXRec(idDictHist, "lastEnt");

            if (rb == null)
            {
                return;
            }

            TypedValue[] tvs         = rb.AsArray();
            string       handleLast0 = tvs[0].Value.ToString();

            tvs[0] = new TypedValue((int)DxfCode.Start, "POLYLINE");

            SelectionSet   ss    = Select.buildSSetBase(tvs, true);
            SelectedObject ssObj = ss[ss.Count - 1];

            if (ssObj.GetType() == typeof(Polyline3d))
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        Polyline3d poly3d      = (Polyline3d)tr.GetObject(ssObj.ObjectId, OpenMode.ForRead);
                        string     handleLastX = poly3d.Handle.ToString();

                        if (Int32.Parse(handleLastX, System.Globalization.NumberStyles.HexNumber) > Int32.Parse(handleLast0, System.Globalization.NumberStyles.HexNumber))
                        {
                            tvs[0] = new TypedValue(1005, poly3d.Handle);
                            Dict.addXRec(idDictHist, "lastENT", tvs);

                            var response = MessageBox.Show("Transfer new Breaklines to TOPO and CONT dwgs?", "trANSFER BREAKLINES?", MessageBoxButtons.YesNo);
                            if (response == DialogResult.Yes)
                            {
                                List <ObjectId> idPolys3d = new List <ObjectId>();
                                foreach (SelectedObject sObj in ss)
                                {
                                    if (sObj.GetType() == typeof(Polyline3d))
                                    {
                                        idPolys3d.Add(sObj.ObjectId);
                                    }
                                }

                                TransferObjs.transferObjects(idPolys3d, TemplateCONT, "CONT");
                                TransferObjs.transferObjects(idPolys3d, TemplateTOPO, "TOPO");
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(string.Format("{0} UBL.cs: line: 69", ex.Message));
                }
            }
        }
Exemple #2
0
        doProcessFigures()
        {
            bool     exists     = false;
            ObjectId idDictHist = Dict.getNamedDictionary("HISTORY", out exists);

            if (exists)
            {
                bool         def    = true;
                bool         answer = false;
                PromptStatus ps     = UserInput.getUserInputYesNo("Command PF has been executed on this drawing - Continue?", def, out answer);
                if (ps == PromptStatus.OK)
                {
                    if (answer == false)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (BaseObjs._acadDocs.Count > 4)
            {
                bool         def    = false;
                bool         answer = false;
                PromptStatus ps     = UserInput.getUserInputYesNo(string.Format("There are {0} drawings open on this machine.  Do you wish to continue?", BaseObjs._acadDocs.Count.ToString()), def, out answer);
                if (ps == PromptStatus.OK)
                {
                    if (answer == false)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            string       JN          = string.Empty;
            string       TOP         = string.Empty;
            string       nameFile    = string.Empty;
            string       nameFileMod = string.Empty;
            ResultBuffer rb          = null;

            ObjectId idDictPPF2 = Dict.getNamedDictionary("PPF2", out exists);

            if (!exists)
            {
                Application.ShowAlertDialog("Dictionary PPF2 is missing - Breaklines will be named \'TEMP\'");

                string nameFull = BaseObjs.docFullName;
                JN  = BaseObjs.docName.Substring(0, 4);
                TOP = "TEMP";
            }
            else
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    rb = Dict.getXRec(idDictPPF2, "strTOP");
                }

                TypedValue[] tvs = rb.AsArray();

                if (tvs.Length > 0)
                {
                    JN          = tvs[0].Value.ToString();
                    TOP         = tvs[1].Value.ToString();
                    nameFile    = tvs[2].Value.ToString();
                    nameFileMod = tvs[3].Value.ToString();
                }
            }

            AeccSurveyDocument survDoc   = BaseObjsCom.aeccSurvDoc;
            AeccSurveyProjects survProjs = survDoc.Projects;
            AeccSurveyProject  survProj  = null;

            try
            {
                foreach (AeccSurveyProject sProj in survProjs)
                {
                    if (sProj.Name == JN)
                    {
                        survProj = sProj;
                        survProj.Open();
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 146");
                BaseObjs.writeDebug(ex.Message + " PF.cs: line: 146");
            }

            AeccSurveyFigures survFigures = survProj.Figures;
            List <ObjectId>   idPolys3d   = new List <ObjectId>();
            List <Node3d>     nodes3d     = new List <Node3d>();

            foreach (AeccSurveyFigure figure in survFigures)
            {
                AeccSurveyFigureNodes nodes = figure.FigureNodes;

                foreach (AeccSurveyFigureNode node in nodes)
                {
                    Node3d node3d = new Node3d(node.X, node.Y, node.Z, node.Bulge);
                    nodes3d.Add(node3d);
                }

                ObjectId idPoly3d = buildPoly3dFromNodes(nodes3d);
                Layer.setLayer(idPoly3d, figure.Layer);
                idPolys3d.Add(idPoly3d);
            }

            survProj.Close();

            TransferObjs.transferObjects(idPolys3d, TemplateCONT, nameFileMod);
            TransferObjs.transferObjects(idPolys3d, TemplateTOPO, nameFile);

            string handleLastEnt = string.Empty;

            try
            {
                handleLastEnt = idPolys3d[idPolys3d.Count - 1].getHandle().ToString();
            }
            catch (System.Exception ex)
            {
                //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 176");
                BaseObjs.writeDebug(ex.Message + " PF.cs: line: 176");
            }

            CgPnt_Group.deletePntGroup(Path.GetFileName(nameFileMod));

            rb = new ResultBuffer(new TypedValue(1005, handleLastEnt));

            Dict.addXRec(idDictHist, "lastENT", rb);
        }