See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Polyline

  1. #1
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Polyline

    Hi everyone,

    I am faced with quite the challenge here. Basically I want to be able to select 2 or 3 (depending on if I can figure another part out) points on a polyline. Get all of the coordinates in between those points and then draw another polyline over top of it with those coordinates only (From starting point to ending point). If i can figure out direction that is where I believe the 3rd point will come in, so I can pick a middle point so I will know which way the user wants the line (possibly?!?!). Right now I am just having a difficult time trying to get this to work. I realize there are some errors in the code, but here is what I have so far. Also I know I will have to handle arcs too, which will come after I figure this out. Thank you all very much

    ~Chris

    Public Function PolyFollow(PolEnt As AcadEntity, Startpoint As Variant, Midpoint As Variant, Endpoint As Variant) As Double

    Dim LVAllPoints As Variant

    LVAllPoints = PolEnt.Coordinates

    Dim i As Integer
    Dim flag As Boolean
    Dim newCount As Integer
    Dim newCoordset As Double

    newCount = 0
    flag = False
    For i = 0 To UBound(LVAllPoints)
    If LVAllPoints(i) = Startpoint(0) Then
    If LVAllPoints(i + 1) = Startpoint(1) Then
    flag = True
    newCoordset(0) = Startpoint(0)
    'newCoordSet(1) = Startpoint(1)
    newCount = 2
    End If
    End If
    If flag = True Then
    If LVAllPoints(i) = Endpoint(0) Then
    If LVAllPoints(i + 1) = Endpoint(1) Then
    'newCoordSet(newCount) = LVAllPoints(i)
    'newCoordSet(newCount + 1) = LVAllPoints(i + 1)
    flag = False
    Exit For
    End If
    End If
    'newCoordSet(newCount) = LVAllPoints(i)
    newCount = newCount + 1
    End If
    Next

    'ThisDrawing.ModelSpace.AddLightWeightPolyline newCoordSet



    EDIT: Well I have it mostly working now. This is what I did instead. Kind of long winded but it seems to work.

    LVAllPoints = PolEnt.Coordinates

    'Variables that will be used for the loop and getting all of the used
    'variables.
    Dim i As Integer
    Dim flag As Boolean
    Dim newCount As Integer
    'Dim newCoordset() As Double
    'newCoordset = PolEnt.Coordinates
    newCount = 0
    flag = False

    'Loop to get all of the points that were selected.

    For i = 0 To UBound(LVAllPoints)
    If flag = True Then
    If LVAllPoints(i) = Endpoint(0) Then
    If LVAllPoints(i + 1) = Endpoint(1) Then
    newCount = newCount + 1
    flag = False
    Exit For
    End If
    End If
    newCount = newCount + 1
    End If
    If LVAllPoints(i) = Startpoint(0) Then
    If LVAllPoints(i + 1) = Startpoint(1) Then
    flag = True
    newCount = 2
    i = i + 1
    End If
    End If
    Next

    ReDim newCoordset(0 To newCount) As Double
    newCount = 0
    For i = 0 To UBound(LVAllPoints)
    If flag = True Then
    If LVAllPoints(i) = Endpoint(0) Then
    If LVAllPoints(i + 1) = Endpoint(1) Then
    newCoordset(newCount) = LVAllPoints(i)
    newCoordset(newCount + 1) = LVAllPoints(i + 1)
    flag = False
    Exit For
    End If
    End If
    newCoordset(newCount) = LVAllPoints(i)
    newCount = newCount + 1

    End If
    If LVAllPoints(i) = Startpoint(0) Then
    If LVAllPoints(i + 1) = Startpoint(1) Then
    flag = True
    newCoordset(0) = Startpoint(0)
    newCoordset(1) = Startpoint(1)
    newCount = 2
    i = i + 1
    End If
    End If
    Next

    ThisDrawing.ModelSpace.AddLightWeightPolyline newCoordset

    I now have another question. Does anyone know how i might be able to make sure this works with arcs as well. I actually just discovered another problem if anyone thinks they might be able to help. If i were to pick points and the starting point happens to be after the endpoint in the list it is breaking. How do I continue this loop to get back around. A counter possibly, when I have found all of them exit the loop?!?!
    Last edited by Christopher.cornell; 2007-07-26 at 07:33 PM.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Polyline

    I prefer not to try and solve a problem where I only know part of the picture. What are you trying to accomplish, from the user's perspective, not the program's. You've started working on a solution, which may or may not be correct. Also, your code will be more readable and paste-able if you use code tags in the advanced editor.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Re: Polyline

    Oh alright. Sorry about that. I thought I gave a description. Oh well I guess not enough. I want to select a lwpolyline on the screen and then select 3 points from it. The start, the mid(which basically is for direction), and an end. I then want to get all of the vertices in between the start and end points and then just draw the polyline from those points on top of the original. What I have will get the basic thing done as long as the starting point that is picked is not after the ending point in the list, but I do not want it to be like this. Any point should be able to be the start. Im not really sure where the advanced editor is, unless you mean the additional options.

    EDIT: It is basically just going to trace parts of a polyline over the existing one. After I get all of the bugs worked out, I want to expand this so that the user can select multiple lines and select 3 points from any of the lines that they picked and have the polyline be a continuous line drawn over the selected polyline.

    EDIT: Alright well I have worked out my problem as far as getting the basics down of what I want to do. However I still am not sure how to do the bulge part.If there is an arc on the polyline that I select I want to be able to redraw that arc as well. I also have another problem. If the user selects a point that is not exactly a vertex coordinate I do not know how to get this point. How could I go about doing this as well. Thanks
    Last edited by Christopher.cornell; 2007-07-27 at 05:01 PM.

  4. #4
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Re: Polyline

    I did not feel like putting in another edit. This one is more of a general programming problem. I can not seem to figure it out. Right now I have the polyline coordinates, and my set of coordinates that I obtained from the starting point I picked on the polyline to the ending point that i picked. I now want to draw the polyline from the new set of coordinates with bulges included. However my new set starts off with the starting point while the original polyline could start anywhere (well wherever you made the starting point, but will be different for other lines). I need to get the leg the bulge is on from the polyline and somehow transfer that to the correct leg on the new polyline. Hope that makes sense.

    I am trying to accomplish, to reiterate, that I want to pick 3 points on a polyline. Use those points to get a sub (for lack of a better word) polyline. I am hoping this will be able to span multiple polylines eventually. Any help is greatly appreciated.

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Polyline

    What I meant was "from a user's perspective", i.e. "I need to copy a door, etc." What does the pline represent? Why do they have to pick 3 points as opposed to selecting the original pline? So far, all I know is there are 2 plines.

    Quote Originally Posted by Ed Jobe
    You've started working on a solution, which may or may not be correct.
    What I meant here is that I could help you iterate pline vertices, etc. but that may not be the best way to meet your goal, which I know nothing of. Think of a program as a recipe, a goal with several steps to accomplish. The goal is to make a pie. You've come here saying, "How do I add salt?" It helps us to know what the big picture is.
    Last edited by Ed Jobe; 2007-07-27 at 08:13 PM.
    C:> ED WORKING....


    LinkedIn

  6. #6
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Re: Polyline

    HAHA....good analogy. I guess I didnt think of it like that. I thought I was giving enough information. As of right now it is just a basic program to draw over points on the pline. BUT what I eventually want this to do is lets say you have a shape that consists of several different plines. As a basic example (which im not sure why you would ever do this) but you have a square where each side is a different pline. I want to be able to select all of those plines, then vertices on those selected plines in order to draw a new one. So lets say you only wanted 3 sides of the square to be a consistent pline you would pick all 3 plines, then the starting point and the ending point of where you want the line to be drawn. The middle point is basically for direction. Because it seems (and i could be wrong) that it only goes in counterclockwise. I am at the point right now where I can get one pline and get the points I want and it draws just fine. I am having problems getting the bulges though. That is where I am stuck as of right now. After that I was thinking about just having a selection set for all the lines and just getting all of the vertices. Not sure if that is the best way to go about this. Thank you for your help, and sorry for the lack of information. Also if you think you might have an easier way that would be great. Because it seems I have run into another problem. If the user just wants a point near a vertex it will break, because I am only checking the selection points against the vertices. Is there a way to check it against all the points on the pline.

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Polyline

    Just to get it straigt in my mind, are you trying to do something like what the Join option of the PEDIT command would do? Could you just pick the 3 lines of the square and join them?
    C:> ED WORKING....


    LinkedIn

  8. #8
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Re: Polyline

    Essentially that is what I am trying to do. However for a more complicated object lets say I dont want to get the entire pline. I just want to go to a vertex in that line. Thats where I want to make the new line to. I also do not just want to join them. I actually want to draw a new line on top of the points that I am selecting. I am sorry that if I am not very clear on what I want to do.

  9. #9
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Polyline

    Quote Originally Posted by Christopher.cornell
    I am sorry that if I am not very clear on what I want to do.
    Maybe post a sample dwg? Why not just draw a new pline? How will this save you any time?

    What are you trying to model? What is the final application?
    C:> ED WORKING....


    LinkedIn

  10. #10
    Member
    Join Date
    2007-06
    Posts
    44
    Login to Give a bone
    0

    Default Re: Polyline

    If you draw a new pline you would have to trace over all of the vertices. I do not want that because what if there are a lot. In there picture, I have have 2 separate plines. The white ones are the plines. Then I want to get a line like the red one but not having to draw it all out. I just want to pick 3 points; the one all the way to the left, a point in the middle and one all the way to the right. This will give me this line. Now if there were arcs in there I would need to handle this too. I do not know how much more description I can give because I thought I have told you what all it is supposed to do.
    Attached Images Attached Images

Page 1 of 3 123 LastLast

Similar Threads

  1. 2013: z value at intersection points in 3d polyline and polyline
    By jaychandran in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2013-10-30, 05:20 PM
  2. Replies: 14
    Last Post: 2007-09-10, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •