Midpoint of a polyline

Discussion in 'AutoCAD' started by mgrigoriev, May 6, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Does anybody have a code to get the midpoint of a light weight polyline?
    Thanks,
    Mike
     
    mgrigoriev, May 6, 2004
    #1
  2. mgrigoriev

    Paul Turvill Guest

    DIVIDE command with 2 segments will put a node (point object) there.
    ___
     
    Paul Turvill, May 7, 2004
    #2
  3. mgrigoriev

    jmodglin Guest

    It is not VB(A) but works:

    (vlax-curve-getPointAtDist PolyObj (Vla-Get-Length PolyObj))

    Josh
     
    jmodglin, May 7, 2004
    #3
  4. mgrigoriev

    Jeff Mishler Guest

    And with Frank O.'s VLAX & VLAX-CURVE classes you can do this in VB(A).
    These can be found in post on here from a few weeks ago, or on Frank's Web
    site when he gets it back online, or I can email them if there is a valid
    email address given.

    And, btw, that woul be :
    (vlax-curve-getPointAtDist PolyObj (/ (Vla-Get-Length PolyObj) 2))

    HTH,
    Jeff
     
    Jeff Mishler, May 7, 2004
    #4
  5. mgrigoriev

    wivory Guest

    I use this:

    [pre]
    Private Function EntityCentroid(Entity As AcadEntity) As Double()
    Dim EntityArray(0) As AcadEntity, RegionList As Variant

    Set EntityArray(0) = Entity
    RegionList = ThisDrawing.ModelSpace.AddRegion(EntityArray)
    EntityCentroid = RegionList(0).Centroid
    RegionList(0).Delete
    End Function
    [/pre]

    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, May 10, 2004
    #5
  6. mgrigoriev

    mgrigoriev Guest

    I can't get the second part of the expression to work.

    ThisDrawing.SendCommand "(Vla-Get-Length " & EntHandle(returnObj) & ") "

    It returns bad argument type. EntHandle is a small function that sends the handent to the command. It worked well with the getPointAtDist. What am I doing wrong?
     
    mgrigoriev, May 17, 2004
    #6
  7. Wayne,
    I would've thought the AddRegion property would close the polyline and give
    you the centroid of the area, not the midpoint of the polyline. This
    doesn't seem like what he is after.

    James
     
    James Belshan, May 18, 2004
    #7
  8. mgrigoriev

    wivory Guest

    Yep, I'm not sure if you are seeing all the posts but we had come to that conclusion already.

    Regards

    Wayne
     
    wivory, May 18, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.