Autolisp and getting ALTITUDE value

Discussion in 'AutoCAD' started by domm, Aug 3, 2004.

  1. domm

    domm Guest

    Hi all,

    I need to read the value of "altitude" from the properties of
    a polyline, in Autodesk Land Desktop 2005.

    Does anyone know the command's needed to do this?

    regards
    Dom
     
    domm, Aug 3, 2004
    #1
  2. Hi,

    There are no commands of which I'm aware to publish this data.

    You can get the information with the [Terrain][3D polylines][edit 3D
    polyline] command.

    With VBA you can get the polyline coordinates. You can extract the data and
    format it any way you like.

    Extract of help file below:

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au

    Sub Example_Coordinates()
    ' This example creates a polyline. It then uses the Coordinates
    ' property to return all the coordinates in the polyline. It then
    ' resets one of the vertices using the Coordinates property.

    Dim plineObj As AcadPolyline

    ' Create Polyline
    Dim points(5) As Double
    points(0) = 3: points(1) = 7: points(2) = 0
    points(3) = 9: points(4) = 2: points(5) = 0
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ThisDrawing.Regen True

    ' Return all the coordinates of the polyline
    Dim retCoord As Variant
    retCoord = plineObj.Coordinates

    ' Display current coordinates for the first vertex
    MsgBox "The current coordinates of the second vertex are: " & points(3)
    & ", " & points(4) & ", " & points(5), vbInformation, "Coordinates Example"

    ' Modify the coordinate of the second vertex to (5,5,0). Note that in
    ' case of a lightweight Polyline, indices will be different because the
    points are 2D only.
    points(3) = 5
    points(4) = 5
    points(5) = 0
    plineObj.Coordinates = points

    ' Update display
    ThisDrawing.Regen True

    MsgBox "The new coordinates have been set to " & points(3) & ", " &
    points(4) & ", " & points(5), vbInformation, "Coordinates Example"
    End Sub
    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Aug 3, 2004
    #2
  3. domm

    Jürg Menzi Guest

    Hi Dom

    In addition to Laurie's VBA sample, the counterpart in LISP:
    Code:
    (defun C:GetPlineCoords ( / CurEnt CurObj ObjNme RetLst TmpLst)
    (vl-load-com)
    (setq CurEnt (entsel "\nSelect a Polyline: "))
    (if CurEnt
    (progn
    (setq CurObj (vlax-ename->vla-object (car CurEnt))
    ObjNme (vla-get-ObjectName CurObj)
    )
    (cond
    ((eq ObjNme "AcDbPolyline")		;LwPolyline
    (setq TmpLst (vlax-get CurObj 'Coordinates))
    (while
    (setq RetLst (cons
    (mapcar '(lambda (l) (nth l TmpLst)) '(0 1))
    RetLst		;2D points
    )
    TmpLst (cddr TmpLst)
    )
    )
    )
    ((wcmatch ObjNme "AcDb*Polyline")	;Old/3DPolyline
    (setq TmpLst (vlax-get CurObj 'Coordinates))
    (while
    (setq RetLst (cons
    (mapcar '(lambda (l) (nth l TmpLst)) '(0 1 2))
    RetLst		;3D points
    )
    TmpLst (cdddr TmpLst)
    )
    )
    )
    ((princ "selected object is not a Polyline. "))
    )
    )
    )
    (reverse RetLst)
    )
    Cheers
     
    Jürg Menzi, Aug 3, 2004
    #3
  4. domm

    domm Guest

    Hey,

    Thanks for your quick responces! I have no experience with
    VBA, had a go but couldn't get it running. I have used LISP
    some, and have been able to get the X and Y co-ordinates,
    before, using something similar. But I am needing to get the Altitude.

    I can change it manualy, by selecting the polyline, then right
    clicking, then properties. But I need to do it on lot's, so would
    like a script to save time.

    Is there something like:
    (setq TmpLst (vlax-get CurObj 'Coordinates))

    except using 'Altitude, as using 'Coordinates only gives me
    the X and Y values, not the altitude. If I have understood correctly.

    regards
    Dom
     
    domm, Aug 3, 2004
    #4
  5. domm

    Jürg Menzi Guest

    Hi Dom

    I'm not familiar with Autodesk Land Desktop...

    My function returns a point list. A LwPolyline has no z coordinates,
    old style Polylines and 3DPolylines have z coordinates.

    Cheers
     
    Jürg Menzi, Aug 3, 2004
    #5
  6. domm

    MP Guest

    try looking at the "Elevation" property
    (setq TmpElev (vlax-get CurObj 'Elevation))
     
    MP, Aug 3, 2004
    #6
  7. domm

    MP Guest

    sorry,
    I assumed he was talking about lwpolylines "representing contours" of fixed
    elevation
    rather than 3d polylines
    It's been a while since I worked in civil and back then contours were
    represented (in plan view) by successive polylines - each at it's own
    elevation - or at least labeled as an elevation -
     
    MP, Aug 3, 2004
    #7
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.