+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Apr 2011
    Posts
    139

    Default Marking Level on the plan autocad

    Registered forum members do not see this ad.

    Hi,

    Found this little lisp routine at http://www.autocadproblems.com/2014/...n-autocad.html

    However, when tried it doesn't seem to work. Here's the coding,

    Code:
    ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    (defun c:lm()
    
           (while (not 
             (setq GL1 (entsel "\nFirst Value :"))
              ))
             (setq Lvl1 (entget (car GL1)))
              
           (if (> (length Lvl1) 22) 
                      (setq G_val1 (nth 13 Lvl1))
           
             (setq G_Val1 (nth 11 Lvl1))
            )
    
    
           (while (not 
             (setq GL2 (entsel "\nSecond Level :"))
              ))
             (setq Lvl2 (entget (car GL2)))
             
           (if (> (length Lvl2) 22) 
                      (setq G_val2 (nth 13 Lvl2))
           
             (setq G_Val2 (nth 11 Lvl2))
            )
         
          
           (setq p1 (getpoint "Pick Range from :"))
           (setq d (getdist p1 "Pick Range to :"))
           (setq d (float d))
           
          
               (setq slp1  (-  (atof(cdr G_val2))  (atof(cdr G_val1))))
               (setq slp  (/ slp1 d))
                   
    (while 
    	 (setq Txt_Pnt (getpoint "\nPick Text Point:"))
             (setq d1 (distance p1 Txt_pnt))
             (setq new_lvl (+ (atof(cdr G_val1)) (* d1 slp))) 
             (setq val1 (rtos new_lvl 2 3))  
             (command "text" Txt_pnt "" "" val1)  
            )
    )
    It gives following error "; error: bad argument type: stringp 1"

    Any help appreciated.

  2. #2
    Senior Member jonathann3891's Avatar
    Computer Details
    jonathann3891's Computer Details
    Operating System:
    Window 7 64 Bit
    Discipline
    Structural
    jonathann3891's Discipline Details
    Occupation
    Oil & Gas
    Discipline
    Structural
    Using
    AutoCAD 2012
    Join Date
    Dec 2008
    Location
    Houston, TX
    Posts
    118

    Default

    Works fine on my machine.

    Code:
    ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    (defun c:lm()
    
           (while (not 
             (setq GL1 (entsel "\nFirst Value :"))
              ))
             (setq Lvl1 (entget (car GL1)))
              
           (if (> (length Lvl1) 22) 
                      (setq G_val1 (nth 13 Lvl1))
           
             (setq G_Val1 (nth 11 Lvl1))
            )
    
    
           (while (not 
             (setq GL2 (entsel "\nSecond Level :"))
              ))
             (setq Lvl2 (entget (car GL2)))
             
           (if (> (length Lvl2) 22) 
                      (setq G_val2 (nth 13 Lvl2))
           
             (setq G_Val2 (nth 11 Lvl2))
            )
         
          
           (setq p1 (getpoint "Pick Range from :"))
           (setq d (getdist p1 "Pick Range to :"))
           (setq d (float d))
           
          
               (setq slp1  (-  (atof(cdr G_val2))  (atof(cdr G_val1))))
               (setq slp  (/ slp1 d))
                   
    (while 
    	 (setq Txt_Pnt (getpoint "\nPick Text Point:"))
             (setq d1 (distance p1 Txt_pnt))
             (setq new_lvl (+ (atof(cdr G_val1)) (* d1 slp))) 
             (setq val1 (rtos new_lvl 2 3))  
             (command "text" Txt_pnt "" "" val1)  
            )
    )
    Jonathan Norton
    Blog | Linkedin

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Apr 2011
    Posts
    139

    Default

    I tried it again and found out that the routine only picks up text and not MText. Is there anyway that it could pick up either?

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,292

    Default

    Change this you should be using ASSOC 1 which is the text string

    Code:
    (setq G_val1 (nth 13 Lvl1))
    
    (setq G_val1 (cdr (assoc 1 Lvl1)))
    A man who never made mistakes never made anything

  5. #5
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Apr 2011
    Posts
    139

    Default

    Hi BIGAL,

    Tried it but without success, changed line as suggested. It seems to be picking up the levels and points but once that part completes it gives the following error:

    First level :
    Second Level ick Range from ick Range to :; error: bad argument type: consp "4.234"

    My first level is 4.234 and the second is 3.956 distance between them is 5m.

    Here's the amended coding changed line in red:

    Code:
    ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    (defun c:marklevel()
    
           (while (not 
             (setq GL1 (entsel "\nFirst level :"))
              ))
             (setq Lvl1 (entget (car GL1)))
              
           (if (> (length Lvl1) 22) 
                      (setq G_val1 (cdr (assoc 1 Lvl1)))
           
             (setq G_Val1 (nth 11 Lvl1))
            )
    
    
           (while (not 
             (setq GL2 (entsel "\nSecond Level :"))
              ))
             (setq Lvl2 (entget (car GL2)))
             
           (if (> (length Lvl2) 22) 
                      (setq G_val2 (cdr (assoc 1 Lvl1)))
           
             (setq G_Val2 (nth 11 Lvl2))
            )
         
          
           (setq p1 (getpoint "Pick Range from :"))
           (setq d (getdist p1 "Pick Range to :"))
           (setq d (float d))
           
          
               (setq slp1  (-  (atof(cdr G_val2))  (atof(cdr G_val1))))
               (setq slp  (/ slp1 d))
                   
    (while 
    	 (setq Txt_Pnt (getpoint "\nPick Text Point:"))
             (setq d1 (distance p1 Txt_pnt))
             (setq new_lvl (+ (atof(cdr G_val1)) (* d1 slp))) 
             (setq val1 (rtos new_lvl 2 3))  
             (command "text" Txt_pnt "" "" val1)  
            )
    )

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,292

    Default

    Have a look at this

    Code:
    ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    (defun c:marklevel()
    (while (/= nil (setq Lvl1 (entget (car (entsel "\nFirst level :")))))
     
    (setq GL2 (entget (car (entsel "\nSecond Level :"))))
    (setq G_val1 (cdr (assoc 1 Lvl1)))
    (setq G_val2 (cdr (assoc 1 Gl2)))
    (setq p1 (getpoint "Pick Range from :"))
    (setq d (getdist p1 "Pick Range to :"))
    (setq d (float d))
    (setq slp1 (- (atof G_val2) (atof G_val1)))
    (setq slp (/ slp1 d))
     
    (setq Txt_Pnt (getpoint "\nPick Text Point:"))
    (setq d1 (distance p1 Txt_pnt))
    (setq new_lvl (+ (atof G_val1) (* d1 slp))) 
    (command "text" Txt_pnt "" "" (rtos new_lvl 2 3)) 
    ) ; while
    ) ; defun
    A man who never made mistakes never made anything

  7. #7
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Apr 2011
    Posts
    139

    Default

    Hi BIGAL,

    Tested it but somehow's routine has lost its functionality, where it would allow you to pick successive point along the line between the two points until cancelled. It now only marks the level for a single point and then asks for first level and second level again. Having a look at the coding you only have a single while loop running which is why after marking level for a single point along a line it reverts back to asking for first level.

  8. #8
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,292

    Default

    I thought that was what you were trying to do. Have a go at fixing it by adding a (while in correct spot and an extra ) to end it.
    A man who never made mistakes never made anything

  9. #9
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Apr 2011
    Posts
    139

    Default

    Hi BIGAL

    Ok here's where I've tried the (while and ) but it keeps looping around the first part of the routine in that it keeps asking for first point etc. This is where my battles with AutoLISP lie. The points I had placed the while loop and closed the first while loop were where it seemed logical to place them . The red highlights shows where I have included them. Please can you point out where I am making the mistake even though it might seem obvious as I cannot work it out.

    Code:
     ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    (defun c:marklevel()
    (while (/= nil (setq Lvl1 (entget (car (entsel "\nFirst level :")))))
     
    (setq GL2 (entget (car (entsel "\nSecond Level :"))))
    (setq G_val1 (cdr (assoc 1 Lvl1)))
    (setq G_val2 (cdr (assoc 1 Gl2)))
    (setq p1 (getpoint "Pick Range from :"))
    (setq d (getdist p1 "Pick Range to :"))
    (setq d (float d))
    (setq slp1 (- (atof G_val2) (atof G_val1)))
    (setq slp (/ slp1 d))
    )
    (While
    (setq Txt_Pnt (getpoint "\nPick Text Point:"))
    (setq d1 (distance p1 Txt_pnt))
    (setq new_lvl (+ (atof G_val1) (* d1 slp))) 
    (command "text" Txt_pnt "" "" (rtos new_lvl 2 3)) 
    ) ; while
    ) ; defun

  10. #10
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,292

    Default

    Registered forum members do not see this ad.

    So close just needed a bit further down glad to see you had a go. Just need to think about where you are picking the extra points

    Code:
    ;Marking Levels in a Horizontal plan
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    (defun c:marklevel()
    (while (/= nil (setq Lvl1 (entget (car (entsel "\nFirst level :")))))
     
    (setq GL2 (entget (car (entsel "\nSecond Level :"))))
    (setq G_val1 (cdr (assoc 1 Lvl1)))
    (setq G_val2 (cdr (assoc 1 Gl2)))
    (setq p1 (getpoint "Pick Range from :"))
    (While
    (setq d (getdist p1 "Pick Range to :"))
    (setq d (float d))
    (setq slp1 (- (atof G_val2) (atof G_val1)))
    (setq slp (/ slp1 d))
    (setq Txt_Pnt (getpoint "\nPick Text Point:"))
    (setq d1 (distance p1 Txt_pnt))
    (setq new_lvl (+ (atof G_val1) (* d1 slp))) 
    (command "text" Txt_pnt "" "" (rtos new_lvl 2 3))
    ) ; while
    ) ; while
    ) ; defun
    A man who never made mistakes never made anything

Similar Threads

  1. Replies: 13
    Last Post: 7th Dec 2016, 01:29 pm
  2. Road Cross Section Through Coordinate plan and Level
    By mfahadrazzaq in forum AutoCAD Beginners' Area
    Replies: 0
    Last Post: 28th Sep 2015, 06:28 am
  3. AutoCAD NVQ Level 2 Past Papers?
    By Elysia in forum Student Project Questions
    Replies: 0
    Last Post: 11th Sep 2014, 09:57 am
  4. revit 2009 moving a plan to a different level
    By darris07 in forum Revit General
    Replies: 5
    Last Post: 3rd Dec 2008, 05:06 pm
  5. adding another floor plan level
    By darris07 in forum Revit General
    Replies: 2
    Last Post: 3rd Dec 2008, 10:09 am

Tags for this Thread

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