Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Splines to their correct elevation

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
samu3
1427 Views, 6 Replies

Splines to their correct elevation

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

6 REPLIES 6
Message 2 of 7
pbejse
in reply to: samu3


@Anonymous 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

 

Message 3 of 7
hmsilva
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

EESignature

Message 4 of 7
pbejse
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

 

Message 5 of 7
stevor
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
Message 6 of 7
samu3
in reply to: samu3

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

 

Samu

Message 7 of 7
pbejse
in reply to: samu3


@Anonymous wrote:

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

 

Samu


Happy to help samu3

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost