CogoPointPointNumber Property

Gets or sets the point number.

Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.292
Syntax
public uint PointNumber { get; set; }

Property Value

UInt32
Exceptions
ExceptionCondition
InvalidOperationException Thrown when the CogoPoint is a ProjectPoint and is not checked out, and the "Allow Checked-In Points to be Modified" setting is false.
ArgumentException Thrown when another CogoPoint has the same PointNumber.
Remarks
Use the Renumber(UInt32, PointNumberResolveType) method as a safer way to assign a PointNumber to a point.
Example
 1// We create some random points and we use the returned
 2// ObjectIdCollection to access the first two points.
 3// 
 4Point3dCollection pts = getRandomPoints();
 5ObjectIdCollection addedPointsIds = _civildoc.CogoPoints.Add(pts, "Example Point", false);
 6
 7ObjectId firstCogoPointId = addedPointsIds[0];
 8ObjectId secondCogoPointId = addedPointsIds[1];
 9CogoPoint firstPoint = firstCogoPointId.GetObject(OpenMode.ForWrite) as CogoPoint;
10CogoPoint secondPoint = secondCogoPointId.GetObject(OpenMode.ForWrite) as CogoPoint;
11
12_editor.WriteMessage("\nInitial point number values:");
13_editor.WriteMessage("\n- First COGO Point = {0}", firstPoint.PointNumber);
14_editor.WriteMessage("\n- Second COGO Point = {0}", secondPoint.PointNumber);
15
16// This will fail and throw a System.ArgumentException because of the PointNumber collision.
17// Points are not renumbered.
18// 
19try
20{
21    firstPoint.PointNumber = secondPoint.PointNumber;
22}
23catch (ArgumentException ex)
24{
25    string msg = String.Format("\n{0}", ex.Message);
26    _editor.WriteMessage(msg);
27}
28_editor.WriteMessage("\nAfter trying to set the PointNumber property (with collision):");
29_editor.WriteMessage("\n- First COGO Point = {0}", firstPoint.PointNumber);
30_editor.WriteMessage("\n- Second COGO Point = {0}", secondPoint.PointNumber);
31
32// This will work, because it will resolve the collision using the CreatePoints command settings
33// for resolving duplicate PointNumbers.  The default is to display a dialog and let the user choose a
34// resolution.
35// 
36firstPoint.Renumber(secondPoint.PointNumber);
37_editor.WriteMessage("\nAfter using the Renumber() method:");
38_editor.WriteMessage("\n- First COGO Point = {0}", firstPoint.PointNumber);
39_editor.WriteMessage("\n- Second COGO Point = {0}", secondPoint.PointNumber);
40
41// This will also work, and uses the command settings to resolve.  However, it returns
42// an ObjectId.Null because of the duplicate number.
43// 
44if (_civildoc.CogoPoints.SetPointNumber(firstCogoPointId, secondPoint.PointNumber) == ObjectId.Null)
45    _editor.WriteMessage("\nSetPointNumber() duplicate number.");
46
47_editor.WriteMessage("\nAfter using SetPointNumber() in CogoPointCollection:");
48_editor.WriteMessage("\n- First COGO Point = {0}", firstPoint.PointNumber);
49_editor.WriteMessage("\n- Second COGO Point = {0}", secondPoint.PointNumber);
50
51// You can check how point number collisions will be handled by looking at this setting:
52// _civildoc.Settings.GetSettings<SettingsCmdCreatePoints>().PointIdentity.ResolveDuplicatePointNumbersOption;
53// The default is "Notify"
See Also