Author Topic: How can I get the number of first cogopoint's number on a drawing?  (Read 1926 times)

0 Members and 1 Guest are viewing this topic.

ekoneo

  • Newt
  • Posts: 66
I use a for cycle beginning from the first cogo points' number to last points' number.
I can calculate the last point's number adding the number of all points to first cogo point's number.
How can I get first cogopoint'number without any counting operations?

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: How can I get the number of first cogopoint's number on a drawing?
« Reply #1 on: April 19, 2014, 08:04:55 AM »
You need to look at the Command Settings. Example for next pointnumber:

Autodesk.Civil.ApplicationServices.CivilDocument CivilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
Autodesk.Civil.Settings.SettingsCmdCreatePoints CmdPointSettings = CivilDoc.Settings.GetSettings<Autodesk.Civil.Settings.SettingsCmdCreatePoints>();

int NextNumber = (int)CmdPointSettings.PointIdentity.NextPointNumber.Value;
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: How can I get the number of first cogopoint's number on a drawing?
« Reply #2 on: April 19, 2014, 11:41:25 AM »
If you get the "_All Points" PointGroup object and use the GetPointNumbers() method it returns a sequential array of all point numbers in the drawing.

ekoneo

  • Newt
  • Posts: 66
Re: How can I get the number of first cogopoint's number on a drawing?
« Reply #3 on: April 21, 2014, 07:22:24 AM »
Thanks Jeff_M and huiz.

Jeff_M you helped me in last week by this code about renumbering cogo points.
Code: [Select]
  public void renumpnts()

      {

          CivilDocument civdoc = CivilApplication.ActiveDocument;

          using (AcDb.Transaction tr = AcDb.HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())

           {

               for (uint i = 1; i < 11; i++)

              {

                   if (!civdoc.CogoPoints.Contains(i))

                      continue;

                  CogoPoint pt = (CogoPoint)civdoc.CogoPoints.GetPointByPointNumber(i).GetObject(AcDb.OpenMode.ForWrite);

                   pt.Renumber(i + 100, PointNumberResolveType.Overwrite);

              }

                tr.Commit();

           }           

      }



And I add a for cycle in your code. Becouse I want to renumber all points starting from first available point to end one.

I can use it only once.. when I try to run it second time I get "Retrive attribute failed" error message.
Interestingly when I try to run second time, if I delette first point manually, it works..

my last work is:

Code: [Select]
using System;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;

//////////////
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Settings;
using Autodesk.Civil.DatabaseServices.Styles;
using Autodesk.Civil.Runtime;
using Autodesk.Civil.Settings;
//////////


namespace SelectionCommands
{
    public class FilterSelect
    {
        [CommandMethod("FM")]

        public static void AddParenthesis()
        {
            CivilDocument civdoc = CivilApplication.ActiveDocument;
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            Autodesk.Civil.ApplicationServices.CivilDocument CivilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
            Autodesk.Civil.Settings.SettingsCmdCreatePoints CmdPointSettings = CivilDoc.Settings.GetSettings<Autodesk.Civil.Settings.SettingsCmdCreatePoints>();
            int NextNumber = (int)CmdPointSettings.PointIdentity.NextPointNumber.Value;
            uint pek = UInt32.Parse(NextNumber.ToString());

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
               
                for (uint i = 1, j = 1; i <pek; i++) // pek is the last point number
                {
                   
                    if (!civdoc.CogoPoints.Contains(i))
                    {

                        continue;

                        CogoPoint pt = (CogoPoint)civdoc.CogoPoints.GetPointByPointNumber(i).GetObject(AcDb.OpenMode.ForWrite);
                        pt.Renumber(j, PointNumberResolveType.Overwrite);
                        j++;
                    }
                   
                }


                tr.Commit();
            }
            doc.SendStringToExecute("._RE ", true, false, false);
            ed.WriteMessage("Renumbered All Points.. !!" + "\n");
        }
    }
}
« Last Edit: April 21, 2014, 07:25:56 AM by ekoneo »