select last entry in autocad and get elevation (Z)

select last entry in autocad and get elevation (Z)

narasimharaoarza0211
Enthusiast Enthusiast
663 Views
10 Replies
Message 1 of 11

select last entry in autocad and get elevation (Z)

narasimharaoarza0211
Enthusiast
Enthusiast

required a lisp program for :

select last entry  in autocad drawing ( Polyline ) and get the " Z " value of the polyline.

0 Likes
664 Views
10 Replies
Replies (10)
Message 2 of 11

john.uhden
Mentor
Mentor

@narasimharaoarza0211 

Are you saying that the last object created is a polyline, or do you mean the last polyline created?

Is the polyline always 2D or LWPolyline or maybe a 3D polyline?

If it's 3D do you want the last vertex?  Of course, if it is closed, I think that would be the first vertex.

Does it matter what space it is in?

John F. Uhden

0 Likes
Message 3 of 11

pbejse
Mentor
Mentor

What @john.uhden  said.

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

To add one more "does it matter" question:

 

Does it matter in what World-or-User Coordinate System the Polyline is drawn, and whether that is the current Coordinate System at the time that you want to get its elevation?  [If you are talking only and always about things drawn in the WCS, never mind the question.]

Kent Cooper, AIA
0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

@narasimharaoarza0211 wrote:

.... select last entry  in autocad drawing ( Polyline ) and get the " Z " value of the polyline.


Come to think of it....

 

Under what circumstances are you selecting the last entry?  If you want to know immediately after drawing it, without having done anything to it or changed any settings, then a simple (getvar 'elevation) will tell you where you just drew it, without the need to actually select it.  But if you have Moved it vertically since drawing it, that's a different situation [but perhaps still simple, depending on the answers to questions posed so far].

Kent Cooper, AIA
0 Likes
Message 6 of 11

narasimharaoarza0211
Enthusiast
Enthusiast

Good morning sir,

It is to further development to:  Offset for 2d or 3d closed polylines (Polygon ) with different horizontal and vertical distance.

It is polygon ( Polyline)  having equal elevation.

While running the program with offset method:

  1. Immediately the last offset polyline should be read out ( Z value) and to be modify to our request.
  2. (getvar 'elevation) is not working  in drawing.
  3. While drawing a rectangle with giving elevation the result is  0.0

 

Command: _rectang

Current rectangle modes:  Elevation=600.000

 

Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: e

 

Specify the elevation for rectangles <600.000>:

 

Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]:

Specify other corner point or [Area/Dimensions/Rotation]:

Command: (getvar 'elevation)

0.0

 

Command:

Command: LI

LIST 1 found

 

                  LWPOLYLINE  Layer: "0"

                            Space: Model space

                   Handle = 57bd

            Closed

    Constant width     0.000

              area   18571.563

         perimeter   547.327

 

          at point  X=370927.361  Y=311284.153  Z=  600.000

          at point  X=371051.890  Y=311284.153  Z=  600.000

          at point  X=371051.890  Y=311135.018  Z=  600.000

          at point  X=370927.361  Y=311135.018  Z=  600.000

0 Likes
Message 7 of 11

hak_vz
Advisor
Advisor

Rectangles elevation set in command RECTANGLE is not the value of system variable elevation.

To get elevation of the last rectangle created you can use something like:

 

(defun rectElev( / eo)
	(cond 
		((and 
			(setq eo (vlax-ename->vla-object (entlast)))
			(vlax-property-available-p eo 'elevation)
		)
			(vlax-get eo 'elevation)
		)
	)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 11

narasimharaoarza0211
Enthusiast
Enthusiast

Command: PL
PLINE
Specify start point: 0,0,600

Current line-width is 0.000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]: @10000,10000,600

2D point or option keyword required.

Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:

Command:
Command: li
LIST 1 found

LWPOLYLINE Layer: "0"
Space: Model space
Handle = 57bc
Open
Constant width 0.000
area 0.000
length 2929.431

at point X= 0.000 Y= 0.000 Z= 600.000
at point X= 2044.887 Y= 2097.619 Z= 600.000

Command: *Cancel*

Command: (getvar 'elevation)
0.0

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

@narasimharaoarza0211 wrote:

....
Specify start point: 0,0,600

....
Specify next point or [Arc/Halfwidth/Length/Undo/Width]: @10000,10000,600

2D point or option keyword required.

....


PLINE won't accept an XYZ point for subsequent vertices [it will for the start point], because they can't have varying elevation.  Give it @10000,10000 without the ,600, and it will be at that elevation.  Then at the end, don't look for the 'elevation System Variable, but for the elevation of the Polyline just drawn:

(getpropertyvalue (entlast) "ELEVATION")

or

(cdr (assoc 38 (entget (entlast))))

Kent Cooper, AIA
Message 10 of 11

narasimharaoarza0211
Enthusiast
Enthusiast

OK , Than you very much 

Message 11 of 11

Kent1Cooper
Consultant
Consultant

@narasimharaoarza0211 wrote:

OK , Than you very much 


You're welcome.  I'm realizing that my advice in Message 5 was based on the assumption that you would have drawn the Polyline at the current Elevation System Variable setting.  That advice is no longer valid if you drew it with a non-zero Z coordinate specified in the start point, as in Message 8.  That forces it to a different elevation from the current Elevation System Variable setting.  That is why I had to suggest looking at something different in Message 9 from what I had suggested in Message 5.

Kent Cooper, AIA
0 Likes