+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Slope routine

  1. #1
    Forum Newbie
    Using
    AutoCAD 2009
    Join Date
    Dec 2010
    Posts
    2

    Default Slope routine

    Registered forum members do not see this ad.

    Hello im new on this, i just whant help for a lisp routine that draw a slope.

    I already try a lot of them but doesnt work correctly.

    Thank´s

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,137

    Default

    Could you provide us with more detail please? And be as specific as possible. Thank you.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  3. #3
    Forum Newbie
    Using
    AutoCAD 2009
    Join Date
    Dec 2010
    Posts
    2

    Default

    Ok, i try many routines but they bring the message "this is not a polyline" but in fact the line that i indicate was a polyline.


  4. #4
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Give this a try
    Code:
    Code:
    ;|--------------Inclination of line-------------------
                    q_|_|| _\|| q_|| _\|                  
                                                          
      يقوم بتحديد ميل الخط من خلال اختيار نقطتين عليه      
                       و من الممكن ان يختار المستخدم      
                    بين ان يرسم خط بين النقطتين او لا      
                                                          
    ------------------------------------------------------
      Author: Hasan M. Asous, 2010                        
      Copyright © 2010 by HasanCAD, All Rights Reserved.  
      Contact: HasanCAD @ TheSwamp.org,                   
               asos2000 @ CADTutor.net                    
               HasanCAD@gmail.com                         
    ------------------------------------------------------
      Version: 1     20 Oct 2010                          
    ____________________________________________________|;
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Mainroutine Start      ;
    (defun c:TanLine (/ p1 p2 p3)
      ; @ HasanCAD
      (vl-load-com)
      (HSN:DDwnMnuSetSysVar)
      (and
        (setq doc (cond (doc) ((vla-get-ActiveDocument (vlax-get-Acad-Object)))))
        (setq spc (if (zerop (vla-get-activespace doc))
      (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc))
      (vla-get-modelspace doc)))
        )
      
      (if (not TL-sel) (setq TL-sel "Points"))
      (initget "select Line or Points")
      (setq TL-sel (cond ( (getkword (strcat "\nChoose  هل تريد تحديد خط او اختيار نقطتين [Line/Points] <" TL-sel ">: ") ) ) ( TL-sel ) ))
      (if (equal TL-sel "Points")
        (progn
          (and
     (setq p1 (trans (getpoint "\nFirst Point اختار النقطة الاولى على الخط ")1 0))
            (setq p2 (trans (getpoint p1 "\nSecond Point اختار النقطة الثانية على الخط")1 0))
            (setq p3 (trans (getpoint "\nText insertion Point قم بتحديد مكان النص")1 0))
            )
          (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
          (IF (< 1000 (ABS (- (cadr p2) (cadr p1))))
     (setq h 220)
     (if (< 100 (ABS (- (cadr p2) (cadr p1))))
       (setq h 22)
       (setq h 2.2)))
          (if (not TL-Line) (setq TL-Line "Yes"))
          (initget "Yes No")
          (setq TL-Line (cond ( (getkword (strcat "\nChoose هل تريد رسم خط بين النقطتين [Yes/No] <" TL-Line ">: ") ) ) ( TL-Line ) ))
          (if (equal TL-Line "Yes")
     (progn
       (HSN:TL-Text h)
              (HSN:TL-Line)
       )
     (progn
       (HSN:TL-Text h)
       )
     )
          )
        (progn
          (setq TL:SS (entget (car (entsel))))
          (if (and
         (equal TL-sel "Line")
         (equal (cdr (assoc 0 TL:SS)) "LINE")
         )
     (Progn   
              (setq p1 (cdr (assoc 10 TL:SS)))
              (setq p2 (cdr (assoc 11 TL:SS)))
       (setq p3 (trans (getpoint "\nText insertion Point قم بتحديد مكان النص")1 0))
       (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
       (HSN:TL-Text)
       )
     (progn
       (princ "\n  PLease Seect a line or Points")
       )
     )
          )
        )
      (HSN:ReDDwnMnuSetSysVar)
      (vla-EndUndoMark ActDoc)
      )
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Mainroutine End        ;
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Subroutine Start       ;
    (defun *error* (msg)
      (and uFlag (vla-EndUndoMark doc))
      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
          (princ (strcat "\n** Error: " msg " **")))
      (princ)
      )
    (defun HSN:DDwnMnuSetSysVar ()
      ; @ HasanCAD
      (setq OldOS (getvar "osmode"))
      (setq OldDynmode (getvar "dynmode"))
      (setq OldDynprompt (getvar "dynprompt"))
      
      (setvar "osmode" 33)
      (setvar "dynmode" 1)
      (setvar "dynprompt" 1)
      (setvar "cmdecho" 0)       
      )
    (defun HSN:ReDDwnMnuSetSysVar ()
      ; @ HasanCAD
      (setq *error* TERR$)
      (setvar "osmode" OldOS)
      (setvar "dynmode" OldDynmode)
      (setvar "dynprompt" OldDynprompt)
      )
    (defun HSN:TL-Text (H)
      ; @ HasanCAD
           (entmakex (list
         (cons 0 "TEXT")
                       (cons 10  p3)
                       (cons 40 H)
                       (cons 1 (strcat (rtos (abs (* tan2 100))2 2) "%"))
         ))
      )
    (defun HSN:TL-Line ()
      ; @ HasanCAD
           (entmake (list
        (cons 0 "LINE")
                      (cons 10 p1)
                      (cons 11 p2)
        ))
      )
    ;     q_|_|| _\|| q_|| _\|     ;
    ;        Subroutine End        ;
    (princ "\n  TanLine.lsp ~ Copyright © by HasanCAD")
    (princ "\n     ...Type TanLine to Invoke...   ")
    (princ)
    Sorry for my English.

  5. #5
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Quote Originally Posted by asos2000 View Post
    Give this a try
    Code:
    Code:
    ;|--------------Inclination of line-------------------
                    q_|_|| _\|| q_|| _\|                  
                                                          
      يقوم بتحديد ميل الخط من خلال اختيار نقطتين عليه      
                       و من الممكن ان يختار المستخدم      
                    بين ان يرسم خط بين النقطتين او لا      
                                                          
    ------------------------------------------------------
      Author: Hasan M. Asous, 2010                        
      Copyright © 2010 by HasanCAD, All Rights Reserved.  
      Contact: HasanCAD @ TheSwamp.org,                   
               asos2000 @ CADTutor.net                    
               HasanCAD@gmail.com                         
    ------------------------------------------------------
      Version: 1     20 Oct 2010                          
    ____________________________________________________|;
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Mainroutine Start      ;
    (defun c:TanLine (/ p1 p2 p3)
      ; @ HasanCAD
      (vl-load-com)
      (HSN:DDwnMnuSetSysVar)
      (and
        (setq doc (cond (doc) ((vla-get-ActiveDocument (vlax-get-Acad-Object)))))
        (setq spc (if (zerop (vla-get-activespace doc))
      (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc))
      (vla-get-modelspace doc)))
        )
      
      (if (not TL-sel) (setq TL-sel "Points"))
      (initget "select Line or Points")
      (setq TL-sel (cond ( (getkword (strcat "\nChoose  هل تريد تحديد خط او اختيار نقطتين [Line/Points] <" TL-sel ">: ") ) ) ( TL-sel ) ))
      (if (equal TL-sel "Points")
        (progn
          (and
     (setq p1 (trans (getpoint "\nFirst Point اختار النقطة الاولى على الخط ")1 0))
            (setq p2 (trans (getpoint p1 "\nSecond Point اختار النقطة الثانية على الخط")1 0))
            (setq p3 (trans (getpoint "\nText insertion Point قم بتحديد مكان النص")1 0))
            )
          (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
          (IF (< 1000 (ABS (- (cadr p2) (cadr p1))))
     (setq h 220)
     (if (< 100 (ABS (- (cadr p2) (cadr p1))))
       (setq h 22)
       (setq h 2.2)))
          (if (not TL-Line) (setq TL-Line "Yes"))
          (initget "Yes No")
          (setq TL-Line (cond ( (getkword (strcat "\nChoose هل تريد رسم خط بين النقطتين [Yes/No] <" TL-Line ">: ") ) ) ( TL-Line ) ))
          (if (equal TL-Line "Yes")
     (progn
       (HSN:TL-Text h)
              (HSN:TL-Line)
       )
     (progn
       (HSN:TL-Text h)
       )
     )
          )
        (progn
          (setq TL:SS (entget (car (entsel))))
          (if (and
         (equal TL-sel "Line")
         (equal (cdr (assoc 0 TL:SS)) "LINE")
         )
     (Progn   
              (setq p1 (cdr (assoc 10 TL:SS)))
              (setq p2 (cdr (assoc 11 TL:SS)))
       (setq p3 (trans (getpoint "\nText insertion Point قم بتحديد مكان النص")1 0))
       (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
       (HSN:TL-Text)
       )
     (progn
       (princ "\n  PLease Seect a line or Points")
       )
     )
          )
        )
      (HSN:ReDDwnMnuSetSysVar)
      (vla-EndUndoMark ActDoc)
      )
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Mainroutine End        ;
    ;     q_|_|| _\|| q_|| _\|     ;
    ;       Subroutine Start       ;
    (defun *error* (msg)
      (and uFlag (vla-EndUndoMark doc))
      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
          (princ (strcat "\n** Error: " msg " **")))
      (princ)
      )
    (defun HSN:DDwnMnuSetSysVar ()
      ; @ HasanCAD
      (setq OldOS (getvar "osmode"))
      (setq OldDynmode (getvar "dynmode"))
      (setq OldDynprompt (getvar "dynprompt"))
      
      (setvar "osmode" 33)
      (setvar "dynmode" 1)
      (setvar "dynprompt" 1)
      (setvar "cmdecho" 0)       
      )
    (defun HSN:ReDDwnMnuSetSysVar ()
      ; @ HasanCAD
      (setq *error* TERR$)
      (setvar "osmode" OldOS)
      (setvar "dynmode" OldDynmode)
      (setvar "dynprompt" OldDynprompt)
      )
    (defun HSN:TL-Text (H)
      ; @ HasanCAD
           (entmakex (list
         (cons 0 "TEXT")
                       (cons 10  p3)
                       (cons 40 H)
                       (cons 1 (strcat (rtos (abs (* tan2 100))2 2) "%"))
         ))
      )
    (defun HSN:TL-Line ()
      ; @ HasanCAD
           (entmake (list
        (cons 0 "LINE")
                      (cons 10 p1)
                      (cons 11 p2)
        ))
      )
    ;     q_|_|| _\|| q_|| _\|     ;
    ;        Subroutine End        ;
    (princ "\n  TanLine.lsp ~ Copyright © by HasanCAD")
    (princ "\n     ...Type TanLine to Invoke...   ")
    (princ)

    Your routine is not returning the Dynamic Input as it was adjusted before .
    And the option for Points is not working at the first time you start the routine .
    An error return at the end of the routine ...

    Command: TANLINE
    Choose ?? ???? ????? ?? ?? ?????? ?????? [Line/Points] <Line>: P
    First Point ????? ?????? ?????? ??? ????
    Second Point ????? ?????? ??????? ??? ????
    Text insertion Point ?? ?????? ???? ????
    Choose ?? ???? ??? ?? ??? ???????? [Yes/No] <Yes>:
    ; error: bad argument type: VLA-OBJECT nil
    Why do not you rotate the insertion text according to line rotation slope or selected points .

  6. #6
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    And also all the following system variables are not re-set as they were before .
    Code:
     (setvar "osmode" 33)
      (setvar "dynmode" 1)
      (setvar "dynprompt" 1)
      (setvar "cmdecho" 0)
    Please recheck your routine once again .

    Thanks.

    Tharwat

  7. #7
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Thanks Tharwat for your reply

    Could you please help me for fixing this error
    Second comment I can handle

    Thanks
    Sorry for my English.

  8. #8
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Quote Originally Posted by asos2000 View Post
    Thanks Tharwat for your reply
    Could you please help me for fixing this error
    Second comment I can handle

    Thanks
    You're welcome .

    Check this out , Do not hesitate to ask if you have any question .

    Code:
    (defun c:TanLine (/ doc spc *error* TH:UnDo TH:StartUnDo p1 p2 p3 tan2 TL-Line TH:UnDo)
      (vl-load-com)
      (and (setq doc (cond (doc) ((vla-get-ActiveDocument (vlax-get-Acad-Object)))))
           (setq spc (if (zerop (vla-get-activespace doc))
                  (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc))
                  (vla-get-modelspace doc)))
        )
      (defun *error* (msg)
      (and TH:UnDo (vla-EndUndoMark doc))
      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
          (princ (strcat "\n** Error: " msg " **")))
      (princ)
      )
      (setq TH:StartUnDo (vla-StartUndoMark doc))
    (initget "Line Points")
      (if (eq (setq TL-sel (getkword (strcat "\nChoose [Line/Points]: " "< Line >"))) "Points")
        (progn
               (setq p1 (getpoint "\n First Point  "))
               (setq p2 (getpoint p1 "\n Second Point "))
               (setq p3 (getpoint "\n Text insertion Point "))
               (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
               (entmake (list (cons 0 "LINE")(cons 10 (trans p1 1 0))(cons 11 (trans p2 1 0))))
               (entmake (list (cons 0 "TEXT")(cons 10 (trans p3 1 0)) (cons 40 (getvar 'textsize))
               (cons 1 (strcat (rtos (abs (* tan2 100))2 2) "%"))))
          )
        (progn
          (prompt "\n please Select Line : ")
          (setq TL-Line (ssget '((0 . "LINE"))))
          (setq e (ssname TL-Line 0))
          (setq p1 (cdr (assoc 10 (entget e))))
          (setq p2 (cdr (assoc 11 (entget e))))
          (setq p3 (getpoint "\nText insertion Point "))
          (setq tan2 (/ (- (cadr p2) (cadr p1)) (- (car p2) (car p1))))
          (entmake (list (cons 0 "TEXT")(cons 10 (trans p3 1 0)) (cons 40 (getvar 'textsize))
                   (cons 1 (strcat (rtos (abs (* tan2 100))2 2) "%"))))
          )
        )
    (setq TH:UnDo (vla-EndUndoMark Doc))
      (princ "\n Modified by Tharwat")
      (princ)
      )
    Enjoy the codes.

    Tharwat

  9. #9
    Banned athabe's Avatar
    Computer Details
    athabe's Computer Details
    Operating System:
    Linux and Window 7
    Using
    AutoCAD 2009
    Join Date
    Oct 2011
    Posts
    8

    Default It acurate

    The code is wonderful it give you the correct answer (slope reading)

    Can I wish to get the answer in 4 decimals and in option of inserting the text or showing message for the reading.

    Thanks
    Last edited by athabe; 6th Oct 2011 at 06:31 pm. Reason: It is accurate

  10. #10
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by athabe View Post
    The code is wonderful it give you the correct answer (slope reading)

    Can I wish to get the answer in 4 decimals and in option of inserting the text or showing message for the reading.

    Thanks
    Which routine you have used and worked for you ? ( the post number )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

Similar Threads

  1. Slope
    By merdrignac in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 6
    Last Post: 4th May 2010, 09:00 am
  2. Slope arrow
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 21st Jan 2010, 07:33 pm
  3. 3D Slope Dimension
    By petrading in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 3rd Nov 2009, 05:21 pm
  4. Slope arrow
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 21st Oct 2009, 04:20 pm
  5. Slope / Invert Lisp Routine?
    By mcklem in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 20th Oct 2009, 12:50 am

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