.NET

.NET

Reply
Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 1 of 10 (474 Views)
Accepted Solution

given coordinate, find polyline width at that segment

474 Views, 9 Replies
01-14-2013 11:11 AM

i have a set of coordinates, not on the polyline. i want to find the polyline width where that coodinate intersects perpendicular to the polyline (shortest distance). without going through all the vertices.

 

i have a polyline with many segments with varying width, which are constant through the each segments (no taper width). need to read off the "instantaneous" width.

 

just 2dpoly or lwpoly not 3d.

 

i found this

 

http://through-the-interface.typepad.com/through_the_interface/2012/01/testing-whether-a-point-is-on...

 

not quite what i want.

 

thanks

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011

wang890 wrote:

the getparameteratpoint returns a double? what is it which parameter does it return?


For Polyline parameter is number of vertex. For example parameter == 1 means second vertex, parameter = 2.5 means  middle between third and fourth vertex.

 

What are AcDbCurve/Curve Parameters? ObjectARX/.NET

Getting the Midpoint of each Polyline Segment using ObjectARX

Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 2 of 10 (468 Views)

Re: given coordinate, find polyline width at that segment

01-14-2013 11:56 AM in reply to: wang890

i thought about going through the polyline vertices one at a time and then take my point and calculate distance. find the shortest distance from that and then record the index where that happens.

 

but i am afraid it may slow down my program. i have 1000 of these to run and if it goes through 1000 vertices could be slow. but i am gonna try it with my way first and hopefully someone has a better way.

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
*Expert Elite*
Jeff_M
Posts: 4,519
Registered: ‎07-22-2003
Message 3 of 10 (447 Views)

Re: given coordinate, find polyline width at that segment

01-14-2013 05:51 PM in reply to: wang890

A polyline derives froma Curve, so it inherits the GetClosestPointTo() method. With the point you can get the parameter at the point which you can then use to GetStartWidthAt()

Jeff_M, also a frequent Swamper
Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 4 of 10 (429 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 09:02 AM in reply to: Jeff_M

thanks jeff very helpful. not figured out yet but getting there.

 

where is the help file for all these rare functions? i think there is none. like roughly explains what the arguments you need to feed it do.

 

not just for this but generally for everything.

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 5 of 10 (426 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 09:25 AM in reply to: wang890

how do you get closest index giving a point?

 

doesn't have a "GetIndexAt" function

 

the getparameteratpoint returns a double? what is it which parameter does it return?

 

i need to get the index without going through the vertices as this will slow down my subassembly.

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 6 of 10 (422 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 09:54 AM in reply to: wang890

wang890 wrote:

the getparameteratpoint returns a double? what is it which parameter does it return?


For Polyline parameter is number of vertex. For example parameter == 1 means second vertex, parameter = 2.5 means  middle between third and fourth vertex.

 

What are AcDbCurve/Curve Parameters? ObjectARX/.NET

Getting the Midpoint of each Polyline Segment using ObjectARX


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 7 of 10 (418 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 10:09 AM in reply to: Alexander.Rivilis

seen.

i am off testing this now.

 

2.6 of a vertex lol.

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 8 of 10 (405 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 05:05 PM in reply to: wang890

works, here's the code

Dim oEmbankmentTypeTarget As WidthOffsetTarget

            Try
                oEmbankmentTypeTarget = oParamsOffsetTarget.Value("TargetHA1")

                Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
                Dim acCurDb As Database = acDoc.Database
                Using lock As DocumentLock = acDoc.LockDocument
                    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                        '' Open the Block table for read
                        Dim acBlkTbl As BlockTable
                        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

                        '' Open the Block table record Model space for write
                        Dim acBlkTblRec As BlockTableRecord
                        acBlkTblRec = CType(acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                                        OpenMode.ForWrite), BlockTableRecord)

                        Dim obj As DBObject = acTrans.GetObject(oEmbankmentTypeTarget.TargetId, OpenMode.ForWrite)

                        If TypeOf obj Is Polyline Then
                            Dim oPoly2dOrig As Polyline = CType(obj, Polyline)


                            'get the index where the current station is closest to
                            Dim x, y, z As Double
                            corridorState.SoeToXyz(corridorState.CurrentAlignmentId, corridorState.CurrentStation, 0, 0, x, y, z)
                            Dim oPt3D_CL As New Point3d(x, y, z)

                            'get vertex index (fraction)
                            Dim dVertex As Double = oPoly2dOrig.GetParameterAtPoint(oPoly2dOrig.GetClosestPointTo(oPt3D_CL, True))

                            'get polyline width
                            dSegmentWidth = oPoly2dOrig.GetStartWidthAt(Truncate(dVertex))

                        End If

                    End Using

                End Using

 

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 9 of 10 (395 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 10:18 PM in reply to: wang890

IMHO method Truncate should be replaced with method Round.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Mentor
wang890
Posts: 831
Registered: ‎06-08-2007
Message 10 of 10 (390 Views)

Re: given coordinate, find polyline width at that segment

01-15-2013 10:56 PM in reply to: wang890

no, have to round down.

 

say point 0 to 10 is 0.5m wide, 10-20 is 1.0m wide. when hit 9.99 say it is still within the 0.5m geotechnical zone.

 

don't worry i am all good.

 

cheers mate.

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.