Results 1 to 7 of 7

Thread: Creating a Invert Level LISP

  1. #1
    Active Member
    Join Date
    2007-11
    Posts
    68
    Login to Give a bone
    0

    Red face Creating a Invert Level LISP

    Hey Guys,

    Hopefully someone can help, this is a large complicated lisp that I would love created, but i have no idea how to do it.

    What I need is, a routine that will allow me to select a polyline, enter a start invert level (in meters) and a gradent (0.0166666).
    Then it will add at each endpoint/vertex a text entry with the a number based on the Start Level - (the distance from the start of the polyline to the endpoint/vertex multiplyed by the gradient).

    I have attached an example of what i need.

    Any help will be greatly appreciated.
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Creating a Invert Level LISP

    AutoCAD Land Development Desktop has "PIPE" routines to automate this design process.

  3. #3
    Active Member
    Join Date
    2007-11
    Posts
    68
    Login to Give a bone
    0

    Thumbs up Re: Creating a Invert Level LISP

    Are there any straight Autocad routins as i doubt my boss will want another CAD package in the office..

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Creating a Invert Level LISP

    You can start to play with this code
    Code:
    (defun c:test ( / StartLevel Gradient Poly Vl-Obj #Vertex Index Dist Level Point )
      (setq StartLevel 123.45 )
      (setq Gradient 0.0166666 )
      (setq Poly (entsel "Please choose the polyline : " ) )
      (vl-load-com)
      (setq Vl-Obj (vlax-ename->vla-object (car Poly )) )
      (setq #Vertex (fix (vlax-curve-getEndParam Vl-Obj )) )
      (setq Index -1 )
      (repeat (1+ #Vertex )
        (setq Index (1+ Index ) )
        (setq Dist (vlax-curve-getDistAtParam Vl-Obj Index ) )
        (setq Level (rtos (+ StartLevel (* Gradient Dist )) 2 3 ) )
        (setq Point (vlax-curve-getPointAtParam Vl-Obj Index ) )
        (command "._text" "J" "MC" Point "10" "0" Level )
      )
      (princ)
    )
    : ) Happy Computing !

    kennet

  5. #5
    Active Member
    Join Date
    2007-11
    Posts
    68
    Login to Give a bone
    0

    Talking Re: Creating a Invert Level LISP

    Thanks so much! I tweaked it a bit to suit what i need. I learnt alot from this lisp routine and how they work.

  6. #6
    Active Member
    Join Date
    2007-11
    Posts
    68
    Login to Give a bone
    0

    Talking Re: Creating a Invert Level LISP

    Quote Originally Posted by kennet.sjoberg View Post
    You can start to play with this code
    Code:
    (defun c:test ( / StartLevel Gradient Poly Vl-Obj #Vertex Index Dist Level Point )
      (setq StartLevel 123.45 )
      (setq Gradient 0.0166666 )
      (setq Poly (entsel "Please choose the polyline : " ) )
      (vl-load-com)
      (setq Vl-Obj (vlax-ename->vla-object (car Poly )) )
      (setq #Vertex (fix (vlax-curve-getEndParam Vl-Obj )) )
      (setq Index -1 )
      (repeat (1+ #Vertex )
        (setq Index (1+ Index ) )
        (setq Dist (vlax-curve-getDistAtParam Vl-Obj Index ) )
        (setq Level (rtos (+ StartLevel (* Gradient Dist )) 2 3 ) )
        (setq Point (vlax-curve-getPointAtParam Vl-Obj Index ) )
        (command "._text" "J" "MC" Point "10" "0" Level )
      )
      (princ)
    )
    : ) Happy Computing !

    kennet

    These are the changes i made. Thank you for helping me. The main thing I learnt is to find a complete list of commands that you can do in a lisp and what they do. I found this (somewhere on the net) and it helped me alter your lisp to this...
    Code:
    (defun c:ilp ( / StartLevel Gradient Poly Vl-Obj #Vertex Index Dist Level Point )
      (setq StartLevel (getreal "Please choose the Start Invert : ") )
      (setq Gradient (getreal "Please choose the Grade : ") )
      (setq Poly (entsel "Please choose the polyline : " ) )
      (vl-load-com)
      (setq Vl-Obj (vlax-ename->vla-object (car Poly )) )
      (setq #Vertex (fix (vlax-curve-getEndParam Vl-Obj )) )
      (setq Index -1 )
      (repeat (1+ #Vertex )
        (setq Index (1+ Index ) )
        (setq Dist (/ (vlax-curve-getDistAtParam Vl-Obj Index) 1000) )
        (setq Level (rtos (- StartLevel (* Gradient Dist )) 2 3 ) )
        (setq Point (vlax-curve-getPointAtParam Vl-Obj Index ) )
        (command "-layer" "set" "HYD-iNverts" "" "_text" "J" "BL" Point (* 1 dwgscale) "45" Level )
      )
      (princ)
    )
    Last edited by RobertB; 2008-09-26 at 12:09 AM. Reason: added code tags

  7. #7
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Creating a Invert Level LISP

    I am glad if I helped you, and also glad that you have learned something.

    Not all, but a lot of Commands can you find "inside" AutoCAD
    Type Command: VLIDE to start the Visual LISP editor
    Click the icon “New File” in the upper left corner
    Type in the <Untitled-1> window ( you make your program code here )
    cond as an example ( and it will be coloured in blue )
    double click cond to make it background marked
    click the help [ ? ] button, and it will take you to the
    Developer Documentation AutoLISP Function cond

    : ) Happy Computing !

    kennet

Similar Threads

  1. 2014: How to add an invert level parameter to a manhole family
    By david684165 in forum Revit MEP - Families
    Replies: 0
    Last Post: 2014-12-08, 04:14 PM
  2. 2013: Invert Elevation Tag - Sea Level
    By Gatchy in forum Revit MEP - General
    Replies: 1
    Last Post: 2013-11-04, 01:36 PM
  3. creating road level
    By annie123 in forum AutoCAD Civil 3D - General
    Replies: 4
    Last Post: 2011-06-22, 11:51 AM
  4. Serious Error when creating Level
    By jmarchese in forum Revit - Platform
    Replies: 3
    Last Post: 2008-12-18, 06:29 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
  •