polarpoint

Discussion in 'AutoCAD' started by robert vetrano, Jul 16, 2004.

  1. Hi

    I have a line running from 0,0,0 to 120,5,5. I want to put a point 4" up the
    line.

    I use polarpoint to move out the 4" along the line and then I use the rise
    that the 'Z' triangle makes to move it up. However it just doesn't come out
    right.



    Does anyone know of another command or any suggestions?



    Thanks

    Bob vetrano
     
    robert vetrano, Jul 16, 2004
    #1
  2. robert vetrano

    TomD Guest

    I'm not sure, exactly, what you're trying to accomplish. If you want to go
    4 units, parallel to the line, polarpoint should be exactly what you need,
    something like:

    vStPt = oLine.StartPoint
    vEnPt = oLine.EndPoint
    dAng = ThisDrawing.Utility.AngleFromXAxis(vStPt, vEnPt)

    ThisDrawing.Utility.PolarPoint vStPt, dAng, 4

    If you have something similar to this and you're not getting the point you
    expect, check your coordinate system.
     
    TomD, Jul 16, 2004
    #2
  3. robert vetrano

    Mark Propst Guest

    always easier for someone to point out whats wrong if they can see what
    you're trying...ie the code.
    other wise all that can be said is it sounds like you know where you want
    your new point to be, so just calc the coordinates and put it there.
    how are you calculating the rise?
    how are you using polar point?
    sounds like you could just use trig to calc the point then use that for the
    insertion point of the point object.
     
    Mark Propst, Jul 16, 2004
    #3
  4. You're talking about a 3d line, and the angle along the line.
    I donĀ“t think polarpoint will work for you here...
    ....unless, not sure it this will work, but maybe if you move the UCS so that
    the XY plane contains the line, and then use the polarpoint.
     
    Jorge Jimenez, Jul 16, 2004
    #4
  5. You can calculate the length of the line between the two points or get it
    from ACAD if it's a Line object. Then, no trig or anything involved,
    interpolate the X, Y, and Z values separately between the StartPoint and
    EndPoint. For instance, in your case the line's length is 120.2", so 4" is
    3.33% along the line. So your point's X would be 0.0 + 3.33% * (120 -
    0.0). And so on for Y & Z.

    James
     
    James Belshan, Jul 16, 2004
    #5
  6. hi
    what i am trying to do is put a circle 4" along a 3D line which is angled
    and rising. attached is the code. there are a lot of msgboxs to check points
    and angles. Perhaps I'm over complicating the situation.

    thanks bob Vetrano

    Sub drawline()
    Dim drawline As AcadLine
    Dim startpt As Variant
    Dim endpt As Variant
    Dim SelectedPoint As Variant
    Dim slopeLineLen As Double
    Dim slopeRun As Double, slopeRise As Double, slopeAngle As Double
    Dim DeltaSlopeX As Double
    Dim slopePlanAngle As Double
    Dim Circle1 As AcadCircle
    Dim r As Double
    Dim Ccenter As Variant
    Dim LeftSetBack As Double
    Dim DeltaLeftSetBackX As Double
    Dim DeltaLeftSetBackY As Double
    Dim PlanDeltaLeftSetBackX As Double
    Dim PlanDeltaLeftSetBackY As Double
    Dim PathStartpt As Variant
    Dim pointy As Variant

    Dim ucsobj As AcadObject
    Dim AngleY As Double

    With ThisDrawing.Utility
    .GetEntity drawline, SelectedPoint, "select line"
    End With
    startpt = drawline.StartPoint ' start point of Drawline
    endpt = drawline.EndPoint ' end point of Drawline
    slopeLineLen = drawline.Length ' length of Drawline
    slopePlanAngle = drawline.Angle ' Angle in plan of Drawline

    AngleY = 90 * 3.14159 / 180 + slopePlanAngle
    'MsgBox "... " & AngleY & ">>>"
    pointy = ThisDrawing.Utility.PolarPoint(startpt, AngleY, 8)

    'MsgBox "... " & startpt(0) & ">>>"
    'MsgBox "... " & startpt(1) & ">>>"
    'MsgBox "... " & startpt(2) & ">>>"
    'MsgBox "... " & pointy(0) & ">>>"
    'MsgBox "... " & pointy(1) & ">>>"
    'MsgBox "... " & pointy(2) & ">>>"

    'used this circle as a test to see if I had a point(pointY) that is
    perpendicular to drawline.

    r = 1
    Ccenter = ThisDrawing.Utility.PolarPoint(startpt, AngleY, 4)
    Set Circle1 = ThisDrawing.ModelSpace.AddCircle(Ccenter, r)

    ' get error when trying to set ucs

    Set ucsobj = ThisDrawing.UserCoordinateSystems.Add(startpt, endpt, pointy,
    "DrawlineUcs")


    slopeRise = endpt(2) - startpt(2) ' 'Z' distance of Drawline
    DeltaSlopeX = endpt(0) - startpt(0) ' delta 'X' distance of
    Drawline
    slopeAngle = Atn(slopeRise / DeltaSlopeX) ' Angle in the world of
    Drawline

    LeftSetBack = 4 ' setback from end of line

    DeltaLeftSetBackX = Cos(slopeAngle) * LeftSetBack ' get delta X of the 'Z'
    triangle

    DeltaLeftSetBackY = Sin(slopeAngle) * LeftSetBack ' get delta y of the 'Z'
    triangle

    PlanDeltaLeftSetBackX = Cos(slopePlanAngle) * LeftSetBack ' get delta X of
    the line in plan (top view)
    PlanDeltaLeftSetBackY = Sin(slopePlanAngle) * LeftSetBack ' get delta y of
    the line in plan (top view)

    'want to place this circle 4" up the line that is angled and
    rising


    r = 1
    Ccenter = ThisDrawing.Utility.PolarPoint(startpt, slopePlanAngle, 8)
    Set Circle1 = ThisDrawing.ModelSpace.AddCircle(Ccenter, r)

    'MsgBox "... " & slopeRise & " >>> "
    'MsgBox "... " & DeltaSlopeX & " >>> "
    'MsgBox "... " & slopeAngle & " >>> "
    'MsgBox "... " & slopePlanAngle & " >>> "
    'MsgBox "... " & DeltaLeftSetBackX & " >>> "
    'MsgBox "... " & DeltaLeftSetBackY & " >>> "
    'MsgBox "... " & PlanDeltaLeftSetBackX & " >>> "
    'MsgBox "... " & PlanDeltaLeftSetBackY & " >>> "



    End Sub
     
    robert vetrano, Jul 16, 2004
    #6
  7. robert vetrano

    TomD Guest

    In that case, I'd suggest the same as James. ;)
     
    TomD, Jul 16, 2004
    #7
  8. robert vetrano

    lorier Guest

    just a thought, but maybe if you construct a 4 unit radius circle at the end point, then get the intersectwith with acExtendthisentity and then get the new endpoint and then draw your circle there...
     
    lorier, Jul 16, 2004
    #8
  9. Bob,

    What is your final goal, your overall task? Are you really trying to draw
    circles, or do you want to create UCS's, or what?

    In order to find the plane perpendicular to the line, I wouldn't use any
    angle calculations. Instead, I would use cross products. They have the
    handy property that when you cross 2 vectors (say, first vector from the
    startpoint to the endpoint of the line, and second vector a random one), the
    resulting vector will be perpendicular to both of the first (i.e. if you
    cross X & Y axis, you get the Z-axis). If you THEN cross your new vector
    with your original vector, you get a vector that is perpendicular to your
    line. Scale this vector to a length of 4, add it to your startpoint, and
    you have a point that's 4" away from your startpoint in a direction
    perpendicular to your line.


    HTH,
    James
     
    James Belshan, Jul 17, 2004
    #9
  10. James
    I knew I was making it more complicated then then I had to. That worked
    great. I also want to thank everyone that replied and offered assistants. I
    learned something from everyone

    bob v
     
    robert vetrano, Jul 20, 2004
    #10
  11. I'm glad you could make sense of my explanation. I was trying not to write
    a book, but still give you a complete thought. But since you used this
    method, I'll add a couple of things you want to check to keep your
    cross-products from failing or giving you a useless answer...

    -- make sure the first line and your random line each have length > 0
    (this sounds obvious, but this can be tough to track down b/c you get
    (0,0,0) as an answer)
    -- make sure that first line and your random vector are not parallel (in
    either the same or opposite directions)

    HTH,

    James
     
    James Belshan, Jul 22, 2004
    #11
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.
Similar Threads
Loading...