Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
samu3
Posts: 57
Registered: ‎06-13-2008
Message 1 of 7 (406 Views)
Accepted Solution

Splines to their correct elevation

406 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

*Expert Elite*
pbejse
Posts: 2,425
Registered: ‎11-24-2009
Message 2 of 7 (402 Views)

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

 

*Expert Elite*
hmsilva
Posts: 2,667
Registered: ‎12-17-2004
Message 3 of 7 (395 Views)

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

*Expert Elite*
pbejse
Posts: 2,425
Registered: ‎11-24-2009
Message 4 of 7 (392 Views)

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

 

Mentor
stevor
Posts: 838
Registered: ‎12-26-2005
Message 5 of 7 (387 Views)

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
Valued Contributor
samu3
Posts: 57
Registered: ‎06-13-2008
Message 6 of 7 (333 Views)

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

*Expert Elite*
pbejse
Posts: 2,425
Registered: ‎11-24-2009
Message 7 of 7 (308 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community