Jump to content

3DPOLY - change Z-Value by factor (0.001 in this case...)


aridzv

Recommended Posts

Hi.

I received  a contour lines file and the Z-Values are in millimeters instead of meters - See attached file.

I need to divide all the Vertices Z-Value by 1,000 to get it in meters.

Is it possible to do such a thing?

 

Thanks,

Aridzv.

conours.dwg

Edited by aridzv
Link to comment
Share on other sites

These are 3d polylines so I converted them to 2d polylines to get he elevation property. and ran this macro that divides the elevation by 1000.

 

;;----------------------------------------------------------------------;;
;; Change point data for polylines
(defun C:Change-Elevation (/ SS elv)
  (vl-load-com)
  (if (setq SS (ssget '((0 . "*POLYLINE"))))
    (foreach obj (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))
      (setq elv (vla-get-elevation obj))
      (vla-put-elevation obj (/ elv 1000))
    )
  )
  (prompt "\n"(itoa (sslength ss))" polylines Change")
  (princ)
)

 

  • Thanks 1
Link to comment
Share on other sites

My version

((lambda ( / ss n ent l_dxf s_dxf pt)
  (setq ss (ssget '((0 . "POLYLINE") (-4 . "&=") (70 . 8) (67 . 0))))
  (cond
    (ss
      (repeat (setq n (sslength ss))
        (setq
          ent (ssname ss (setq n (1- n)))
          l_dxf (entget ent)
          s_dxf (entget (entnext (cdar l_dxf)))
        )
        (while (/= (cdr (assoc 0 s_dxf)) "SEQEND")
          (cond
            ((zerop (boole 1 207 (cdr (assoc 70 s_dxf))))
              (setq
                pt (cdr (assoc 10 s_dxf))
                pt (list (car pt) (cadr pt) (* 0.001 (caddr pt)))
              )
              (entmod (subst (cons 10 pt) (assoc 10 s_dxf) s_dxf))
              (setq s_dxf (entget (entnext (cdar s_dxf))))
            )
          )
        )
        (entupd ent)
      )
    )
  )
  (prin1)
))

 

Link to comment
Share on other sites

@mhupp

Thanks, works (as always...👏) like a charm!!

I added the option to let the user choose the division factor - the code is attached.

THANKS!!!

;;----------------------------------------------------------------------;;
;; Change point data for polylines
(defun C:Change-Elevation (/ SS elv ht)
  (vl-load-com)

  (setq ht (getreal "\nEnter the division factor<1000>: "))
  (if (= ht nil)
    (setq ht 1000)
  )

  (if (setq SS (ssget '((0 . "*POLYLINE"))))
    (foreach obj (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))
      (setq elv (vla-get-elevation obj))
      (vla-put-elevation obj (/ elv ht))
    )
  )
  (prompt "\n"(itoa (sslength ss))" polylines Change")
  (princ)
)

 

Link to comment
Share on other sites

@Tsuky

thanks.

I could not run your code.

I think there is a problem with the function declaration in the first line: 

((lambda ( / ss n ent l_dxf s_dxf pt)

 

Link to comment
Share on other sites

Quote

@Tsuky

thanks.

I could not run your code.

I think there is a problem with the function declaration in the first line: 

@aridzv

Simply copy and paste the code directly on the command line (possibly validate behind the last parenthesis if it is displayed) and the code will be executed.

  • Like 1
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...