Hi.
I´m trying to get a CogoPoint object from CogoPointCollection but I can do it.
ObjectId Id = civDoc.CogoPoints.GetPointByPointNumber(PointNumber[k]);
method "GetPointByPointNumber" returns ObjectId from NumberPoint.
I thought that that method returned CogoPoint.
I can do this:
CogoPointCollection CPcoll = civDoc.CogoPoints; //colección de puntos COGO en el dibujo
but then I have to do a loop (foreach or for..) to find CogoPoint with the same NumberPoint.
Are there any ways better?
Solved! Go to Solution.
Solved by joantopo. Go to Solution.
Hi;
You got CogoPoint Id by GetPointByPointNumber method, and then convert id to CogoPoint object
inside of transaction.
If I understand the question...
public class CogoTest
{
#region Fields
/// <summary>
/// The Acad document.
/// </summary>
private readonly Document acadDocument;
/// <summary>
/// The Civil document.
/// </summary>
private readonly CivilDocument civilDocument;
#endregion
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="CogoTest" /> class.
/// </summary>
public CogoTest()
{
this.acadDocument = Application.DocumentManager.MdiActiveDocument;
this.civilDocument = CivilApplication.ActiveDocument;
}
#endregion
#region Public Methods and Operators
/// <summary>
/// The Execute.
/// </summary>
public void Execute()
{
var pointId = this.civilDocument.CogoPoints.GetPointByPointNumber(5);
using (
var tr = this.acadDocument.TransactionManager.StartTransaction())
{
var point = tr.GetObject(pointId, OpenMode.ForWrite) as CogoPoint;
if (point != null)
{
point.RawDescription = "Test";
}
tr.Commit();
}
}
#endregion
}
Yes, there are samples in API documentation:
CogoPointCollection cogoPoints=civDoc.CogoPoints; ObjectId pointId=cogoPoints.GetPointByNumber(PointNumber); CogoPoint CP=pointId.GetObject(openMode.ForRead) as CogoPoint; double elevation=CP.Elevation; ......
I didn´t know that:
CogoPointCollection cogoPoints=civDoc.CogoPoints;
is the same than:
CogoPointCollection cogoPoints=cogoPointCollection.GetCogoPoints(civDoc.CogoPoints);
And;
CogoPoint CP=pointId.GetOObject(openMode.ForRead)as CogoPoint;
is the same than:
var tr = this.acadDocument.TransactionManager.StartTransaction()) { var CP= tr.GetObject(pointId, OpenMode.ForRead) as CogoPoint;
thank you very much Robert.