Jump to content

Major contours vs minor contours - Polylines


TASC1

Recommended Posts

Hi all,

I was provided this large dwg file converted from lidar (1.8 Gb) of a large area (500 hectares).

The only issue is they didn't distinguish between major and minor contours.
The major contours are at 1 metre intervals.
The minor contours are at 0.25 metre intervals.

Is there a lisp routine which can scan the z values that do not have (0.25, 0.5, 0.75) and find only those with #.0 - EG 92.0, 93.0, etc....?

This is so I can identify the major contours and change the layer to major contours, and separate them from the minor contours?

Link to comment
Share on other sites

are you able to post a sample or part of the drawing. I suspect that the contours will be LWpolylines and then you should be able to identify their elevations through LISP and put on a suitable layer

Link to comment
Share on other sites

Like Steven this is just a start pick 1 pline, really need a dwg to see what your contour objects are.

 

(defun c:test ( / lay ent elev)
(setq lay "major contour")
(while (setq ent (entget (car (entsel "\npick a contour "))))
  (setq elev (cdr (assoc 38 ent)))
   (if (= (- elev (fix elev)) 0.0)(entmod (subst (cons 8 lay) (assoc 8 ent) ent)))
)
(princ)
)

 

Edited by BIGAL
Link to comment
Share on other sites

On 9/3/2024 at 7:55 AM, Steven P said:

are you able to post a sample or part of the drawing. I suspect that the contours will be LWpolylines and then you should be able to identify their elevations through LISP and put on a suitable layer

Hi I thought of that after reading through earlier posts in the forum but they aren't LWPolylines.
Someone posted a LISP routine for LWPolylines.

Link to comment
Share on other sites

On 9/3/2024 at 10:07 AM, BIGAL said:

Like Steven this is just a start pick 1 pline, really need a dwg to see what your contour objects are.

 

(defun c:test ( / lay ent elev)
(setq lay "major contour")
(while (setq ent (entget (car (entsel "\npick a contour "))))
  (setq elev (cdr (assoc 38 ent)))
   (if (= (- elev (fix elev)) 0.0)(entmod (subst (cons 8 lay) (assoc 8 ent) ent)))
)
(princ)
)

 

The contour file is 1.8 Gb, and the lines are not LWPolylines, but Polylines.
As you can imagine there are 1000's of contour lines over a 500 hectare site so going through them one by one to find the ones that don't have a Z value ending in 0.25, 0.5, 0.75 takes time.
I'm only trying to pick the contours that are 1m intervals so I can change their layer to Major Contours and leave the rest as Minor Contours.

Below is only a small fraction of what I need to process.

image.png.b128095a139958b9fe018df05d32a5c1.png

Edited by TASC1
Additional information
Link to comment
Share on other sites

Still need a sample drawing not an image.

 

Did you LIST the PLINES? If you just select the pline and Properties, it shows as Polyline if it's a LWPolyline.

 

From LIST...

 

LWPOLYLINE  Layer: "03_material_list"
                            Space: Model space
                   Handle = 2fb
              Open
    Constant width     0'-0"
              area   264.07 square in. (1.8338 square ft.)
            length   4'-3 23/32"

          at point  X=7'-5 9/16"  Y=1'-6 29/32"  Z=    0'-0"
          at point  X=5'-10 23/32"  Y=1'-6 29/32"  Z=    0'-0"
          at point  X=5'-10 23/32"  Y=0'-4 29/32"  Z=    0'-0"
          at point  X=7'-5 9/16"  Y=0'-4 29/32"  Z=    0'-0"

 

Same pline in Properties...

 

 

Polyline.png

Link to comment
Share on other sites

Like SLW210, a 3dpoly will appear as a POLYLINE.

 

Entities in set: 1
---------- Polyline -----------------------------------------------

Location:  X=   -5901.2092  Y=   18451.3999  Z=   10.0000

Location:  X=   -5638.1762  Y=   22906.5219  Z=   10.0000

Location:  X=   -2531.0985  Y=   22577.7306  Z=   10.0000

 

Again use wblock and just save a small part of your dwg and post.
 

Link to comment
Share on other sites

I don't use meters very much, but.

 

Maybe this...

 

;;; Place polylines by Z value, whole numbers on Major Contour all else on Minor Contour.                                |
;;;                                                                                                                      |
;;; https://www.cadtutor.net/forum/topic/90707-major-contours-vs-minor-contours-polylines/?do=findComment&comment=650651 |
;;;                                                                                                                      |
;;; By SLW210 (Steve Wilson)                                                                                             |
;;;                                                                                                                      |
;;; Works on AutoCAD 2000i                                                                                               |
;;;                                                                                                                      |
;;; September 6th, 2024                                                                                                  |
;;;______________________________________________________________________________________________________________________|

(defun c:PBZ ()
  (c:PolylinesByZ)
)

(defun c:PolylinesByZ (/ ss i ent layer color z pt)
  ;; Select all polylines in the drawing
  (setq ss (ssget "X" '((0 . "LWPOLYLINE"))))
  
  (if (null ss)
    (progn
      (princ "\nNo polylines found in the drawing.")
      (exit)
    )
  )

  ;; Loop through polylines
  (setq i 0)
  (repeat (sslength ss)
    (setq ent (ssname ss i))
    (setq i (1+ i))

    ;; Get the polyline's Z value
    (setq pt (cdr (assoc 10 (entget ent))))
    (setq z (if pt (vlax-get (vlax-ename->vla-object ent) 'Elevation) 0))

    ;; Determine layer based on Z value
    (if (and (numberp z) (zerop (rem z 1)))
      (progn
        (setq layer "Major Contour")
        
      )
      (progn
        (setq layer "Minor Contour")
        
      )
    )

    ;; Check if layer exists, otherwise create it
    (if (not (tblsearch "LAYER" layer))
      (progn
        (entmake
          (list
            (cons 0 "LAYER")
            (cons 2 layer)
            (cons 70 0)
            
          )
        )
      )
    )

    ;; Change the polyline's layer
    (entmod (subst (cons 8 layer) (assoc 8 (entget ent)) (entget ent)))
    (entupd ent)
  )
  
  (princ "\nPolylines sorted by Z value.")
  (princ)
)

 

Link to comment
Share on other sites

@SLW210 TASC1 has shown the objects are an object of type "POLYLINE" not a "LWPOLYLINE" so 3d object rather than a 2d object. There is no Elevation in a "POLYLINE" but there are Z values. So check object type and use Elevation or Z. Ps ssget *POLYLINE & (vlax-get obj 'objectname)

 

3dpoly (0 . "POLYLINE")(100 . "AcDb3dPolyline")

2D Polyline (0 . "LWPOLYLINE")(100 . "AcDbPolyline")(38 . 20.0) ; elevation is dxf 38 

 

 

Really need a sample dwg to check properly what object is.

Edited by BIGAL
Link to comment
Share on other sites

The OP has disappeared and I am not going to continue a guessing game.

 

Just offered up something I already had the basis of and adjusted it a little for the OP.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...