Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can I get CogoPoint from NumberPoint or IdObject?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
joantopo
428 Views, 2 Replies

Can I get CogoPoint from NumberPoint or IdObject?

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?

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
2 REPLIES 2
Message 2 of 3
zrobert
in reply to: joantopo

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
    }

Message 3 of 3
joantopo
in reply to: zrobert

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.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report