Sets the PointNumber for a single CogoPoint.

Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.4.2516.0

Syntax

C#
public ObjectId SetPointNumber(
	ObjectId pointId,
	uint pointNumber
)
Visual Basic
Public Function SetPointNumber ( _
	pointId As ObjectId, _
	pointNumber As UInteger _
) As ObjectId
Visual C++
public:
ObjectId SetPointNumber(
	ObjectId pointId, 
	unsigned int pointNumber
)

Parameters

pointId
Type: ObjectId
The ObjectId of the point you want to set the PointNumber for.
pointNumber
Type: System..::..UInt32
The new PointNumber value.

Return Value

If the method succeeds, it returns the same ObjectId pointId passed in. If the method fails, it returns ObjectId.Null.

Examples

CopyC#
 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");
 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"
CopyVB.NET
 1' We create some random points and we use the returned
 2' ObjectIdCollection to access the first two points.
 3'
 4Dim pts As Point3dCollection = getRandomPoints()
 5Dim addedPointsIds As ObjectIdCollection = _civildoc.CogoPoints.Add(pts, "Example Point")
 6
 7Dim firstCogoPointId As ObjectId = addedPointsIds(0)
 8Dim secondCogoPointId As ObjectId = addedPointsIds(1)
 9Dim firstPoint As CogoPoint = TryCast(firstCogoPointId.GetObject(OpenMode.ForWrite), CogoPoint)
10Dim secondPoint As CogoPoint = TryCast(secondCogoPointId.GetObject(OpenMode.ForWrite), CogoPoint)
11
12_editor.WriteMessage(vbLf & "Initial point number values:")
13_editor.WriteMessage(vbLf & "- First COGO Point = {0}", firstPoint.PointNumber)
14_editor.WriteMessage(vbLf & "- 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  firstPoint.PointNumber = secondPoint.PointNumber
21Catch ex As ArgumentException
22  Dim msg As String = [String].Format(vbLf & "{0}", ex.Message)
23  _editor.WriteMessage(msg)
24End Try
25_editor.WriteMessage(vbLf & "After trying to set the PointNumber property (with collision):")
26_editor.WriteMessage(vbLf & "- First COGO Point = {0}", firstPoint.PointNumber)
27_editor.WriteMessage(vbLf & "- Second COGO Point = {0}", secondPoint.PointNumber)
28
29' This will work, because it will resolve the collision using the CreatePoints command settings
30' for resolving duplicate PointNumbers.  The default is to display a dialog and let the user choose a
31' resolution.
32'
33firstPoint.Renumber(secondPoint.PointNumber)
34_editor.WriteMessage(vbLf & "After using the Renumber() method:")
35_editor.WriteMessage(vbLf & "- First COGO Point = {0}", firstPoint.PointNumber)
36_editor.WriteMessage(vbLf & "- Second COGO Point = {0}", secondPoint.PointNumber)
37
38' This will also work, and uses the command settings to resolve.  However, it returns
39' an ObjectId.Null because of the duplicate number.
40'
41If _civildoc.CogoPoints.SetPointNumber(firstCogoPointId, secondPoint.PointNumber) = ObjectId.Null Then
42  _editor.WriteMessage(vbLf & "SetPointNumber() duplicate number.")
43End If
44
45_editor.WriteMessage(vbLf & "After using SetPointNumber() in CogoPointCollection:")
46_editor.WriteMessage(vbLf & "- First COGO Point = {0}", firstPoint.PointNumber)
47_editor.WriteMessage(vbLf & "- Second COGO Point = {0}", secondPoint.PointNumber)
48
49' You can check how point number collisions will be handled by looking at this setting:
50' _civildoc.Settings.GetSettings<SettingsCmdCreatePoints>().PointIdentity.ResolveDuplicatePointNumbersOption;
51' The default is "Notify"

Examples

CopyC#
 1// _civildoc is the active CivilDocument instance.
 2// 
 3CogoPointCollection cogoPoints = _civildoc.CogoPoints;
 4ObjectId pointId = cogoPoints.Add(new Point3d(100, 100, 50));
 5uint newPointNumber = 100;
 6
 7// set for single point
 8if (cogoPoints.SetPointNumber(pointId, newPointNumber) == ObjectId.Null)
 9    write("SetPointNumber failed.\n");
10
11Point3dCollection points = new Point3dCollection();
12points.Add(new Point3d(50, 50, 25));
13points.Add(new Point3d(200, 200, 15));
14ObjectIdCollection pointIds = cogoPoints.Add(points);
15List<ObjectId> pointIdList = GetListFromCollection(pointIds);
16
17// set multiple points to multiple values
18int offsetValue = 10;
19ObjectIdCollection success = cogoPoints.SetPointNumber(pointIdList, offsetValue);
20write(String.Format("SetPointNumber success for {0} of {1} points.\n",
21    success.Count, pointIdList.Count));
CopyVB.NET
 1' _civildoc is the active CivilDocument instance.
 2'
 3Dim cogoPoints As CogoPointCollection = _civildoc.CogoPoints
 4Dim pointId As ObjectId = cogoPoints.Add(New Point3d(100, 100, 50))
 5Dim newPointNumber As UInteger = 100
 6
 7' set for single point
 8If cogoPoints.SetPointNumber(pointId, newPointNumber) = ObjectId.Null Then
 9    write("SetPointNumber failed." & vbLf)
10End If
11
12Dim points As New Point3dCollection()
13points.Add(New Point3d(50, 50, 25))
14points.Add(New Point3d(200, 200, 15))
15Dim pointIds As ObjectIdCollection = cogoPoints.Add(points)
16Dim pointIdList As List(Of ObjectId) = GetListFromCollection(pointIds)
17
18' set multiple points to multiple values
19Dim offsetValue As Integer = 10
20Dim success As ObjectIdCollection = cogoPoints.SetPointNumber(pointIdList, offsetValue)
21write([String].Format("SetPointNumber success for {0} of {1} points." & vbLf, success.Count, pointIdList.Count))

See Also