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: 

.net - .PointLocation

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
brianchapmandesign
565 Views, 4 Replies

.net - .PointLocation

This works fine if my alignment starts at 0+00.. but throws an error when I change the alignments start station to 1+00 or anything else. Any idea why, and hhow I can correct it?

 

myalign.PointLocation(newdist, 0, 0.0001, ref xValue, ref yValue, ref bearing);


"Very funny, Scotty. Now beam down my clothes.
4 REPLIES 4
Message 2 of 5
Jeff_M
in reply to: brianchapmandesign

How are you obtaining the newdist variable, Brian? If this is a distance along the alignment, and the distance is less than the start station, it will fail.

 

May help to see more code and a sample data set. I use this method a lot in my code and have never seen a problem.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 5
brianchapmandesign
in reply to: Jeff_M

Thanks Jeff! Don't really have anything was just doing a simple while loop to list the station coordinates.

 

Do you have a working sample you can post?


"Very funny, Scotty. Now beam down my clothes.
Message 4 of 5
Jeff_M
in reply to: brianchapmandesign

Here ya go, Brian. I create a 550' long alignment from a polyline, set the ReferenceStation to 20+00, then run a loop at 100' increments to get the location of the station.

        [CommandMethod("TestAlignStations")]
        public void testalignstations()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            CivilDocument civdoc = CivilApplication.ActiveDocument;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Polyline pline = new Polyline(2);
                pline.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0);
                pline.AddVertexAt(1, new Point2d(0, 550), 0, 0, 0);
                BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead);
                BlockTableRecord btr = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite);
                btr.AppendEntity(pline);
                tr.AddNewlyCreatedDBObject(pline, true);
                ObjectId layerId = db.Clayer;
                ObjectId siteId = ObjectId.Null;
                ObjectId alignStyle = civdoc.Styles.AlignmentStyles["Standard"];
                ObjectId alignStyleSet = civdoc.Styles.LabelSetStyles.AlignmentLabelSetStyles["Standard"];
                PolylineOptions pOpts = new PolylineOptions();
                pOpts.AddCurvesBetweenTangents = false;
                pOpts.EraseExistingEntities = true;
                pOpts.PlineId = pline.ObjectId;
                Alignment align = (Alignment)Alignment.Create(civdoc, pOpts, "TestAlignment", siteId, layerId, alignStyle, alignStyleSet).GetObject(OpenMode.ForWrite);
                align.ReferencePointStation = 2000;
                for (double i = align.StartingStation; i < align.EndingStation; i += 100)
                {
                    double n = 0, e = 0;
                    align.PointLocation(i, 0, ref n, ref e);
                    ed.WriteMessage("\nStation {0} is located at {1}, {2}", align.GetStationStringWithEquations(i), n.ToString("F2"), e.ToString("F2"));
                }
                tr.Commit();
            }
        }

 

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 5
brianchapmandesign
in reply to: Jeff_M

haha...hate how stupid you make me feel sometimes jeff lol... I was trying to make my routine walk through distances by adding 50 from zero until I got to or above the start station hahaha...have no idea why I didn't just set it to the starting station... i need a vacation my brain is toast


"Very funny, Scotty. Now beam down my clothes.

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report