Jump to content

minimum elevation of 3d face


motee-z

Recommended Posts

What do you mean with minimum elevation... 3DFace entity consist of 3 - 4 points that can be coplanar and also may not if there are 4... Do you want to get Z coordinate of point that is the lowest, or something else?

Link to comment
Share on other sites

Pass a 3DFACE ename to this:

 

[b][color=BLACK]([/color][/b]defun minz [b][color=FUCHSIA]([/color][/b]e / ed mz[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ed [b][color=MAROON]([/color][/b]entget e[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq mz [b][color=MAROON]([/color][/b]apply 'min [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]nth 3 [b][color=RED]([/color][/b]assoc 10 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                                 [b][color=BLUE]([/color][/b]nth 3 [b][color=RED]([/color][/b]assoc 11 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                                 [b][color=BLUE]([/color][/b]nth 3 [b][color=RED]([/color][/b]assoc 12 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                                 [b][color=BLUE]([/color][/b]nth 3 [b][color=RED]([/color][/b]assoc 13 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
mz[b][color=BLACK])[/color][/b]

 

 

-David

Link to comment
Share on other sites

Or condensing David's:

(defun minz ( e )
   (setq e (entget e))
   (apply 'min (mapcar '(lambda ( x ) (cadddr (assoc x e))) '(10 11 12 13)))
)

For selection set:

(defun minzss ( s / i m )
   (setq m 1e308)
   (repeat (setq i (sslength s))
       (setq m (min m (minz (ssname s (setq i (1- i))))))
   )
)

(minzss (ssget '((0 . "3DFACE"))))

Link to comment
Share on other sites

....:D....

 

It's cheating really; strictly I should write it:

 

(defun minzss ( s / i m )
   (setq i (1- (sslength s))
         m (minz (ssname s i))
   )
   (repeat i
       (setq m (min m (minz (ssname s (setq i (1- i))))))
   )
)

In case there is a face with vertex at minimum elevation 1.79e308 ;)

Link to comment
Share on other sites

this is what i want to do

(defun minz (e / ed mz)
 (and (setq ed (entget e))
      (setq mz (apply 'min (list (nth 3 (assoc 10 ed))
                                 (nth 3 (assoc 11 ed))
                                (nth 3 (assoc 12 ed))
                                (nth 3 (assoc 13 ed))))))
mz)
(defun c:min(/)
(setq 3DF (ssget '((0 . "3DFACE"))))
(minz)
 (print (rtos minz 2 2))

)

so how can i pass e here or pass 3df from e or other

because i lost

Link to comment
Share on other sites

As shown in my earlier post, you can pass the selection set to the posted 'minzss' function:

 

(defun minz ( e )
   (setq e (entget e))
   (apply 'min (mapcar '(lambda ( x ) (cadddr (assoc x e))) '(10 11 12 13)))
)

(defun minzss ( s / i m )
   (setq i (1- (sslength s))
         m (minz (ssname s i))
   )
   (repeat i
       (setq m (min m (minz (ssname s (setq i (1- i))))))
   )
)

(defun c:test ( / sel )
   (if (setq sel (ssget '((0 . "3DFACE"))))
       (minzss sel)
   )
)

Link to comment
Share on other sites

Hello

what code can get minimum elevation of 3d faces

If you are using AutoCAD for Windows you can get the maximum and minimum extents (and hence the maximum and minimum elevations) using the vla-GetBoundingBox function. This works for any entity, not only 3DFaces.

I've put up a simple example that displays the Minimum and maximum elevations for the selected object:

(defun c:show-elev  (/ minpt maxpt)
 (vl-load-com)
 (vla-GetBoundingBox
   (vlax-ename->vla-object
     (car (entsel "\nSelect entity: ")))
   'minpt
   'maxpt)
 (alert
   (strcat "Minimum elevation:\t"
           (rtos (last (vlax-safearray->list minpt)) 2 4)
           "\nMaximum elevation:\t"
           (rtos (last (vlax-safearray->list maxpt)) 2 4))))

This other one displays the maximum and minimum boundingbox corner:

(defun c:show-extents  (/ minpt maxpt)
 (vl-load-com)
 (vla-GetBoundingBox
   (vlax-ename->vla-object
     (car (entsel "\nSelect entity: ")))
   'minpt
   'maxpt)
 (alert
   (strcat "Minimum boundingbox corner:\t"
           (vl-princ-to-string (vlax-safearray->list minpt))
           "\nMaximum boundingbox corner:\t"
           (vl-princ-to-string (vlax-safearray->list maxpt)))))

Edited by togores
  • 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...