CHECK ELEVATIONS OF SELECTED OBJECTS

CHECK ELEVATIONS OF SELECTED OBJECTS

etilley327KA
Advocate Advocate
934 Views
17 Replies
Message 1 of 18

CHECK ELEVATIONS OF SELECTED OBJECTS

etilley327KA
Advocate
Advocate

I have a lisp that I'm using but ran into an issue. I'm currently collecting a group of objects including (lines, 2d polylines, arcs) and use "change" command to change all the elevations to zero. However, recently I ran into an instance were some of the objects weren't changed. Does someone know how I could create a check to alert me if any of the objects are not at zero elevation?

0 Likes
Accepted solutions (1)
935 Views
17 Replies
Replies (17)
Message 2 of 18

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

.... some of the objects weren't changed. ....


Post a small drawing with some objects that are not changed, and the AutoLisp routine.

Kent Cooper, AIA
0 Likes
Message 3 of 18

pendean
Community Legend
Community Legend
Share that LISP here along with the problem DWG that contains " some of the objects weren't changed" please.
0 Likes
Message 4 of 18

etilley327KA
Advocate
Advocate

Heres part of it. I believe the problem came because one of the 2d polyline had two different start and end z elevations.

 

(setq A (ssget '((8 . "AP-BUILDING LINE,AP-EASEMENT,AP-BOUNDARY"))))
       (setq Sline (entsel "\nSelect Source property line: "))
       (command "_.CHANGE" Sline "" "_P" "_E" "0" "")
       (setq Sline (car Sline))
       (setq Dline (car (nentsel "\nSelect Destination property line: ")))
     (command "_.CHANGE" Dline "" "_P" "_E" "0" "")
       (setq
          1stS (vlax-curve-getStartPoint Sline)
          2ndS (vlax-curve-getEndPoint Sline))
       (setq
          1stD (vlax-curve-getStartPoint Dline)
          2ndD (vlax-curve-getEndPoint Dline))

   (command "_.copybase" "0,0" A "")
   (command "_.pasteclip" "0,0")
   (command "_.align" A "" 1stS 1stD 2ndS 2ndD "" "")
0 Likes
Message 5 of 18

etilley327KA
Advocate
Advocate

Woops forgot this part.

 

(command "_.CHANGE" A "" "_P" "_E" "0" "")
0 Likes
Message 6 of 18

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

....

       (setq Sline (entsel "\nSelect Source property line: "))

       (command "_.CHANGE" Sline "" "_P" "_E" "0" "")
       (setq Sline (car Sline))
       (setq Dline (car (nentsel "\nSelect Destination property line: ")))
     (command "_.CHANGE" Dline "" "_P" "_E" "0" "")
....

Red:  For me, CHANGE doesn't accept the return of (entsel) [a list of entity and pick point].  Shouldn't the blue line be moved up above the CHANGE command line, so that CHANGE is given an entity, not a list?

Magenta:  Is it even possible to change the elevation of a nested object?  You could pick a top-level object with (nentsel), and it should work, but I expect it would fail if that property line is part of an Xref or something.

Kent Cooper, AIA
0 Likes
Message 7 of 18

etilley327KA
Advocate
Advocate

You are correct I guess I had those flipped and yes, I'm also running into the problem of the nested object not working when a xref line is selected. I'm trying to figure out how to differentiate wither the DLINE is nested object or a regular line and run the change command accordingly. However, I still run in to the issue of ensuring all the objects variable "A", at the end are at zero, even if the start and end Z are different, or to alert the user if it is so.

0 Likes
Message 8 of 18

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

.... I'm trying to figure out how to differentiate wither the DLINE is nested object or a regular line and run the change command accordingly. ....


The return of (nentsel) adds some stuff not returned by (entsel), including at the end a list of what entities the object is nested in.  So its last item is that list, rather than the list you get from (entsel) of the coordinates of the point at which you picked it.  The last thing in the return of each is a list, but what's in them differs.  So you can, for example, compare:

(type (car (last (entsel))))

returns

REAL

[the X coordinate of the pick point], whereas

(type (car (last (nentsel))))

returns

ENAME

Kent Cooper, AIA
0 Likes
Message 9 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@etilley327KA wrote:

.... I still run in to the issue of ensuring all the objects variable "A", at the end are at zero, even if the start and end Z are different, or to alert the user if it is so.


The CHANGE command gives you a notification:

Cannot change elevation of objects with differing Z coordinates.

but unfortunately, it's only informational, and doesn't cause an error that could be detected to trigger alerting the user with something more obvious.

 

You could go plowing through the selection, and check everything's bounding box for non-zero Z values, either before or after doing the CHANGE command.

Kent Cooper, AIA
0 Likes
Message 10 of 18

etilley327KA
Advocate
Advocate
Thanks for the help, but something is going wrong in my "if" I believe. What am I missing?
 
(defun c:test ()
(setq a (nentsel "\nSelect Destination property line: "))
(if
  (= "REAL" (type (car (last a))))
  (progn
    (setq a (car a))
    (command "_.CHANGE" a "" "_P" "_E" "0" "")
  )
  (setq a (car a))
)
)
0 Likes
Message 11 of 18

ВeekeeCZ
Consultant
Consultant

You can simply test the length of the return list. If it's 2, it's a basic entity. If 4, it's nested.

 

(if (setq s (nentsel))
  (if (= (length s) 2)
    (basic ent) ; the same return as from entsel
    (nested))
  (nothing selected))

 

Message 12 of 18

etilley327KA
Advocate
Advocate
Thank you
0 Likes
Message 13 of 18

etilley327KA
Advocate
Advocate

Im still trying to figure out how to see if any of the objects have an elevation higher than zero. I came up with this, but it isnt quite working. Is there a way to make this work and check if any of the return list are above zero?

 

(defun c:TEST (/ a e i ob obelev)
(setq a (ssget))
(repeat (setq i (sslength a))
  (setq e (ssname a (setq i (1- i))))
  (setq ob (cons (Cdr (assoc 10 (entget e))) ob))
  (setq obelev (cons (cddr ob) obelev)))
  (princ obelev)
)
0 Likes
Message 14 of 18

ВeekeeCZ
Consultant
Consultant

Don't you want rather use a different way to flatten objects? Possibly move to the second suggestion from HERE 

0 Likes
Message 15 of 18

Kent1Cooper
Consultant
Consultant

That's not a Text string.  Try:

 

(= 'REAL (type (car (last a))))

Kent Cooper, AIA
0 Likes
Message 16 of 18

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

Im still trying to figure out how to see if any of the objects have an elevation higher than zero. ....


Is that really what you want to know?  Those that do, but have a constant elevation [higher or lower], get taken to zero by your CHANGE command, so they should not be a problem.  Don't you really want to know whether any objects have varying elevation, no matter where the elevations may be relative to zero?  Those are the ones for which CHANGE can't fix the elevation.

Kent Cooper, AIA
0 Likes
Message 17 of 18

etilley327KA
Advocate
Advocate

Does the "MOVE" command have any issues with varying elevations? Yes you are correct, its the varying elevations that are causing the problem.

0 Likes
Message 18 of 18

Sea-Haven
Mentor
Mentor

There is a lot of suggestions but what does "Flatten" do ?

 

With objects like pline with different z you may have to walk along the pline resetting vertices to z=0, maybe same with Lines. Where 10 may have a z=0 but 11 is another value. Note also LWPOLYLINE and POLYLINE are 2 different types of pline.

 

A 2d LWPOLYLINE can have an "Elevation" variable set rather than Z 

(10 -207.615061113667 1323.xxx-xxxxxxxx)

(38 . 10.0)

 

 

0 Likes