+ Reply to Thread
Page 1 of 7 1 2 3 ... LastLast
Results 1 to 10 of 66
  1. #1
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2009
    Posts
    40

    Drawing Lisp file request

    Registered forum members do not see this ad.

    I enjoy a challenge, but sometimes I want to try things that are above my expertise. So, if there is anyone out there that enjoys a challenge and would like to help me out I have a request. I work in civil drafting and at the company I work for we don’t all have Civil 3d, for cost reasons. This is understandable, but I am always finding ways to use standard AutoCAD to make my job easier. With that in mind, I understand that Civil 3d will do what I am about to ask, but I don’t have that option.

    When I draw a plan and profile of a sanitary sewer line I label the pipe in the profile to read as follows:

    304 L.F. OF 8" P.V.C. @ 0.014 SLOPE

    What I would like to be able to do is maybe pick the flow line out of the first manhole then pick the flow line out of the upstream manhole and have the above string of text placed above the pipe in the profile. I would like the text to be dtext and be bottom center justification and be placed at the midpoint of the top line of the pipe that is in the profile. I know that AutoCAD can calc the l.f. which is just the “x” distance of the two picked points. The slope could probably be calculated too but the profiles are at an exaggerated y scale so if this isn’t possible a place holder that can be edited would be fine. I have attached a dwg with an example of how the text should look. To whoever tackles this, if you need more info or I wasn’t clear on something, let me know.
    Attached Files
    Last edited by Stryder; 2nd Apr 2009 at 07:54 pm. Reason: Changed dwg attachment

  2. #2
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    A suggestion..

    If the top line of the pipe would accurately represent the LF (x distance), user could select just this line, and provide the y scale exaggeration. With the selected line & the exaggeration, the routine would know the LF, the slope, and exactly where to place the text & the orientation. (could ask user for text height also). It could provide everything except the pipe diameter & type, but could use X" P.V.C. as the default.

  3. #3
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2009
    Posts
    40

    Default

    True, however, the way the pipe lines are drawn in my profiles, the lines are trimmed back to the outer edge of the manhole. The manholes are typically the same dia. in the profile, so the routine would have to calculate and add some extra to make up the difference.

  4. #4
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,798

    Default

    Did something similar pretty easy just break down into one step at a time

    Enter vert scale
    Enter hor scale
    pick pit1 c/l /inv point
    Pick pit2 c/l /inv point
    pick top pipe
    the rest is just maths taking into account the scales

    taking your words I enjoy a challenge

    (setq pt1 (Getpoint "pick point 1"))
    (setq pt2 (Getpoint "pick point 2"))
    (setq x1 (car pt1)) x value of pt1
    (setq y1 (cadr pt1)) y value of pt1

    keep going got you started
    Last edited by BIGAL; 3rd Apr 2009 at 03:09 am.

  5. #5
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2009
    Posts
    40

    Default

    Well, thanks for the start, but when I said I enjoy a challenge I also mentioned this was above me. I can write scripts (who can't?), write code for toolbar buttons and know some diesel expressions but I can't write lisp files. So, maybe I am asking for too much, if I am, I am sorry.

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Just noticed this thread - request doesn't seem too bad - but I can't view the drawing with only '04 at my disposal - would it be possible to upload an '04 compatable drawing please
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #7
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2009
    Posts
    40

    Default

    Thanks for the response and yes, I have changed it to where you can view. Let me know if you have any problems viewing.
    Attached Files

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Perhaps something like this to start us off:

    Code:
    (defun c:pipetxt (/ *error* vlst ovar diam lEnt lObj lLen lAng lMid)
      (vl-load-com)
    
      (defun *error* (msg)
        (if ovar (mapcar 'setvar vlst ovar))
        (if tObj (entdel tObj))
        (if (not (member msg '("Function cancelled" "quit / exit abort")))
          (princ (strcat "\nError: " (strcase msg)))
          (princ "\n<-- cancelled -->"))
        (princ))
    
      (setq vlst '("OSMODE" "CLAYER")
        ovar (mapcar 'getvar vlst))
      (setvar "OSMODE" 0)
    
      (or (tblsearch "LAYER" "TXT-100")
          (vla-add (vla-get-layers
             (vla-get-ActiveDocument
               (vlax-get-acad-object))) "TXT-100"))
    
      (or pip:dia (setq pip:dia 8))
      (initget 6)
      (setq diam (getreal (strcat "\nSepcify Diameter of Pipeline <"
                      (rtos pip:dia 2 0) "\">: ")))
      (or (not diam) (setq pip:dia diam))
    
      (while (and (setq lEnt (car (entsel "\nSelect Pipeline: ")))
              (eq "LINE" (cdadr (entget lEnt))))
        (setq lObj (vlax-ename->vla-object lEnt)
          lLen (vla-get-length lObj)
          lAng (angle (vlax-curve-getStartPoint lObj)
                    (vlax-curve-getEndPoint lObj))
          lMid (vlax-curve-getPointatParam lObj
             (/ (vlax-curve-getEndParam lObj) 2.0)))
        (if (and (> lAng 0) (<= lAng (/ pi 2)))
        nil (setq lAng (+ lAng pi)))
        (Make_Text lMid (strcat (rtos lLen 2 0) " L.F. OF "
                    (rtos pip:dia 2 0) "\"%%C P.V.C. @ "
                    (angtos lAng 0 3) " SLOPE") lAng))
      (mapcar 'setvar vlst ovar)
      (princ))
    
    (defun Make_Text  (pt val rot)
      (entmake (list '(0 . "TEXT")
             '(8 . "TXT-100")
             (cons 10 pt)
             (cons 40 (getvar "TEXTSIZE"))
             (cons 1 val)
             (cons 50 rot)
             (cons 7 (getvar "TEXTSTYLE"))
             '(71 . 0)
             '(72 . 1)
             '(73 . 1)
             (cons 11 pt))))
    Last edited by Lee Mac; 6th Apr 2009 at 09:59 pm.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #9
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2009
    Posts
    40

    Default

    This is an EXCELLENT start. I am not sure how to fix this so I will tell you the tweaking that needs to be done and see if it can be done. Only 3 things; First, the length is the total length of the line and I need the "x" distance only from center of manhole to center of manhole not the end of the line. Second, the slope in this lisp is giving me the xy angle of the line. I need rise over run as in "y / x = slope". Third and last, the text height is too tall in my other drawings. I have no idea what the problem is with the text height because it works fine in the drawing that I uploaded.

    If it helps, and I said this above, our manholes are the same size in all drawings and you could just add the additional footage to the calculated "x" distance?

    Also, a common mistake, I make it myself and I fixed it already but, the DAI. symbol is %%C instead of %%D.

    Thank you very much for your help Lee Mac and looking forward to the finished product! As I have said above, if you need any more info from me just ask.

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Stryder View Post
    This is an EXCELLENT start. I am not sure how to fix this so I will tell you the tweaking that needs to be done and see if it can be done.
    Thanks Stryder - I knew there'd be a few things needed tweaking after reading a few of the previous posts - but I thought I'd start us off with something concrete first

    Quote Originally Posted by Stryder View Post
    Only 3 things; First, the length is the total length of the line and I need the "x" distance only from center of manhole to center of manhole not the end of the line.
    Would you still prefer to select the line only, and have the "x" distance added on? (It would make the LISP more stable this way imo).

    Quote Originally Posted by Stryder View Post
    Second, the slope in this lisp is giving me the xy angle of the line. I need rise over run as in "y / x = slope".
    This should be easily achieved.

    Quote Originally Posted by Stryder View Post
    Third and last, the text height is too tall in my other drawings. I have no idea what the problem is with the text height because it works fine in the drawing that I uploaded.
    The text height I am using is just retrieved from the "TEXTSIZE" variable in whatever drawing you are working in - but I can modify this to whatever you desire.

    Quote Originally Posted by Stryder View Post
    Also, a common mistake, I make it myself and I fixed it already but, the DAI. symbol is %%C instead of %%D.
    Coincidentally, I noticed this just before you posted this reply - I altered the code in my original post - but thanks for pointing it out all the same.



    Cheers

    Lee
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Request for Lisp to draw Duct Elbow
    By LSA in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 30th May 2013, 09:01 am
  2. A lisp request
    By Joro-- in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 1st Apr 2007, 02:24 pm
  3. Double Line Lisp request
    By LSA in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 12th Apr 2006, 08:54 pm
  4. Request for Lisp
    By aledtaylor in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st Dec 2005, 04:01 pm
  5. request: code to change text in the file
    By guest in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 19th Nov 2005, 08:04 pm

Bookmarks

Posting Permissions

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