+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Computer Details
    samsudeenmanoos's Computer Details
    Operating System:
    windows
    Discipline
    Surveying
    samsudeenmanoos's Discipline Details
    Occupation
    Draftsman
    Discipline
    Surveying
    Using
    Map 3D 2016
    Join Date
    Aug 2017
    Location
    qatar
    Posts
    4

    Smile Dear guys please help me to get elevation in the attached lisp

    Registered forum members do not see this ad.

    I tried many times to get elevation but i cannot make it please can anyone solve this?
    [ATTACH]DSS.dwg[/ATTACH]
    Attached Files

  2. #2
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    710

    Default

    Code:
    (defun C:ENZ (/ ov p pt e n z)
      (setq ov (getvar 'cmdecho))
      (setvar 'cmdecho 0)
      (while (and (setq p (getpoint "\nPick Point : ")) (setq pt (getpoint p "\nInsert Text : ")))
        (progn (mapcar '(lambda(a b) (set a (strcat (vl-princ-to-string a) "= " (rtos b 2 3)))) '(E N Z) p)
    	   (eval (vl-list* vl-cmdf
    			   "_leader"
    			   "_non"
    			   'p
    			   "_non"
    			   'pt
    			   ""
    			   (list E N Z "") 
    			   ) 
    		 )
    	   (princ (strcat "\r" E " " N " " Z))
    	   
    	   )
        ) 
      (if ov (setvar 'cmdecho 0)) 
      (princ "Done!\n")
      (princ)
      )
    Last edited by hanhphuc; 12th Jun 2018 at 02:36 pm. Reason: previous code was incorrect if the text not placed on each vertex
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  3. #3
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,581

    Default

    Its a typo

    Code:
    (setq P1Z (cadr pnt1))   ; returns Y
    (setq P1Z (caddr pnt1)) ; returns Z
    
    also need ;
    ; Labeling N,E,Z Coordinates with Leader - David B. Stewart
    you could condense the code if you want and not use so many variables.

    Code:
    (defun C:LP(/ pnt1 COORDN COORDE PTXT)
        (setq PNT1 (getpoint  "\nPick coordinate point: "))
        (setq COORDN (strcat "E " (rtos (car pnt1) 2 3)  ))
        (setq COORDE (strcat "N " (rtos (cadr pnt1) 2 3)  ))
        (setq ELEZ (strcat "EL " (rtos (caddr pnt1) 2 3)  ))
        (setq PTXT (getpoint    "\nPick text location: "))
        (command "LEADER" PNT1 PTXT "" COORDN  COORDE  ELEZ "")
        (princ)
    )
    Code:
    ; even less
    (defun C:LP(/ )
        (command "LEADER" (getpoint  "\nPick coordinate point: ")  (getpoint    "\nPick text location: ") "" 
        (strcat "E " (rtos (car pnt1) 2 3)  )
        (strcat "N " (rtos (cadr pnt1) 2 3)  ) 
        (strcat "EL " (rtos (caddr pnt1) 2 3)  ) "")
        (princ)
    )
    A man who never made mistakes never made anything

  4. #4
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,581

    Default

    Registered forum members do not see this ad.

    Back to the dwg its 3d pline etc are you after the vertice co-ords or a 3d point along the pline. ObjectName (RO) = "AcDb3dPolyline"

    What I posted previously does not work with 3dpoly.

    Try this just need to add a bettter defun and error check
    Code:
    ; pline co-ords example
    ; By Alan H
    ; write z of vertices added
    
    (defun getcoords (ent)
      (vlax-safearray->list
        (vlax-variant-value
          (vlax-get-property
        (setq obj (vlax-ename->vla-object ent))
        "Coordinates"
          )
        )
      )
    )
     
     ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
    (defun co-ords2xy ()
    (setq len (length co-ords))
    (if (= (vla-get-ObjectName obj) "AcDb3dPolyline")
    (progn
    (setq numb (/ len 3))
    (setq odd "yes")
    )
    (progn
    (setq numb (/ len 2)) ; even and odd check required
    (setq odd "no")
    )
    )
     (setq I 0)
    (setq co-ordsxy '())
    (repeat numb
    (cond 
    ((= odd "yes") (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))(setq I (+ I 3)))
    ((= odd "no" ) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))(setq I (+ I 2)))
    )
    (setq co-ordsxy (cons xy co-ordsxy))
    )
    )
    
    
    ; program starts here
    (setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
    (co-ords2xy) ; list of 2d or 3d points making pline
    ; list is co-ordsxy
    
    `
    (repeat (setq i(length co-ordsxy))
    (setq pt (nth  (setq i (- i 1)) co-ordsxy))
    (setq x (car pt) )
    (setq  y(cadr pt) )
    (if (= odd "yes")
    (setq z  (caddr pt))
    (setq z "-")
    )
    (command "-text" (list x y) "" "" (rtos z 2 3))
    )
    Last edited by BIGAL; 12th Jun 2018 at 11:28 am.
    A man who never made mistakes never made anything

Similar Threads

  1. Lisp to Array Blocks (as per the attached)
    By anupmadhu in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 13th Sep 2015, 12:41 pm
  2. How do you guys manage your LISP within AutoCAD?
    By vernonlee in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 24th Mar 2015, 02:33 pm
  3. Hey Guys and Gals, LISP for writing all blocks to a .txt
    By Bhull1985 in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 17th Jul 2014, 01:36 pm
  4. Lisp need for the attached drawing
    By smiley in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 14th Sep 2011, 04:03 am
  5. Scaling LISP - can you guys please help me tidy it up a litte...
    By lamensterms in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 15th Jul 2011, 03:47 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