• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Contributor
    Posts: 25
    Registered: ‎06-13-2008
    Accepted Solution

    Splines to their correct elevation

    187 Views, 6 Replies
    12-05-2012 02:54 AM

    Hi all,

     

    I have a (2D) drawing with hundreds of elevation lines as splines. They all have their supposed z elevation as text next to them. Is there a lisp that would raise these splines to the elevation in the text by firstselecting the spline and then clicking on the elevation text?

     

    Thanks!

     

    Samu

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Splines to their correct elevation

    12-05-2012 03:23 AM in reply to: samu3

    samu3 wrote:

    Hi all,

     

    I have a (2D) drawing with hundreds of elevation lines as splines. They all have their supposed z elevation as text next to them. Is there a lisp that would raise these splines to the elevation in the text by firstselecting the spline and then clicking on the elevation text?

     

    Thanks!

     

    Samu


    (defun c:elevate (/ spl txt elev)
      (vl-load-com)
      (prompt "\nSelect Polyline")
      (while (and (setq spl (ssget "_:S:L" '((0 . "*POLYLINE"))))
    	      (not (redraw (setq pl (ssname spl 0)) 3))
    	      (princ "\nSelect text for elevation:")
    	      (setq txt (ssget "_:S" '((0 . "TEXT"))))
    	      (numberp
    		(setq elev (read (vla-get-textstring (vlax-ename->vla-object (ssname txt 0)))))
    	      ) ;_ end of numberp
    	 ) ;_ end of and
        (redraw pl 4)
        (vla-put-elevation (vlax-ename->vla-object pl) elev)
        (princ (strcat "\nElevation at " (rtos elev 2 2)))
      ) ;_ end of while
      (princ)
    )

     

    HTH

     

    Please use plain text.
    *Expert Elite*
    Posts: 1,220
    Registered: ‎12-17-2004

    Re: Splines to their correct elevation

    12-05-2012 04:04 AM in reply to: samu3

    samu3 wrote:
    ...I have a (2D) drawing with hundreds of elevation lines as splines....would raise these splines to the elevation in the text
    by firstselecting the spline and then clicking on the elevation text?...


    it if they are splines, and not lwpolylines with the spline option ...
    they are 3d objects and don't have the elevation property, each fit point may have different elevation,
    So, if they all have the same elevation, try this code:

     

    (defun c:test(/ tx)
     (prompt "\nSelect contour line to change elevation : ")
     (command "select" "single" pause)
     (setq tx (cdr (assoc 1 (entget (car (entsel"\nSelect elevation text : "))))))
     (command "change" "p" "" "p" "e" tx "")
     (PRINC)
    )

     

    Hope that helps,

    Henrique

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Splines to their correct elevation

    12-05-2012 04:15 AM in reply to: hmsilva

    hmsilva wrote:

     

     

    it if they are splines, and not lwpolylines with the spline option ...
    they are 3d objects and don't have the elevation property, each fit point may have different elevation,

    Henrique


    Good point Henrique

     

    ....
    (if (vlax-property-available-p (vlax-ename->vla-object pl) 'Elevation) (progn (vla-put-elevation (vlax-ename->vla-object pl) elev) (princ (strcat "\n<<<Elevation at " (rtos elev 2 2) ">>>")) )(princ (strcat "\n<<<Unable to Change Elevation>>>")))
    .... 

     

    Holler if you need help putting this together samu3

     

    HTH

     

    Please use plain text.
    Mentor
    Posts: 768
    Registered: ‎12-26-2005

    Re: Splines to their correct elevation

    12-05-2012 04:36 AM in reply to: samu3
    A procedure: 1. SSget all TEXTs that could be associated with the SPLINE entities that you want to 'reaise.' 2. For each TEXT entity, use a ssget "w" or "c" of appropriate size to get the closest SPLINE. 3. and modify that SPLINE entity/object, or create another and delete that one, at the new coordinates. If you post a sample DWG, make it just a few of the objects, and in an old dwg format, like 2000, and no reactors; to get the most help.
    S
    Please use plain text.
    Contributor
    Posts: 25
    Registered: ‎06-13-2008

    Re: Splines to their correct elevation

    12-14-2012 12:18 PM in reply to: samu3

    Sorry for the late reply... But thank you so much guys, you solved my problem! Appreciate it!

     

    Samu

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: Splines to their correct elevation

    12-16-2012 11:17 PM in reply to: samu3

    samu3 wrote:

    Sorry for the late reply... But thank you so much guys, you solved my problem! Appreciate it!

     

    Samu


    Happy to help samu3

     

    Cheers

    Please use plain text.