motee-z Posted February 28, 2013 Share Posted February 28, 2013 Hello what code can get minimum elevation of 3d faces Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted February 28, 2013 Share Posted February 28, 2013 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? Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 28, 2013 Author Share Posted February 28, 2013 sorry for that please find attached dwg 3dface.dwg Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 28, 2013 Share Posted February 28, 2013 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 Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 28, 2013 Author Share Posted February 28, 2013 very thanks david Quote Link to comment Share on other sites More sharing options...
motee-z Posted February 28, 2013 Author Share Posted February 28, 2013 i have a selection set of 3d face (setq 3df (ssget '((0 . "3DFACE")))) how can i pass ename from 3df Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2013 Share Posted February 28, 2013 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")))) Quote Link to comment Share on other sites More sharing options...
GP_ Posted February 28, 2013 Share Posted February 28, 2013 (setq m 1e308) ........ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2013 Share Posted February 28, 2013 ........ 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 Quote Link to comment Share on other sites More sharing options...
motee-z Posted March 1, 2013 Author Share Posted March 1, 2013 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 1, 2013 Share Posted March 1, 2013 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) ) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted March 1, 2013 Author Share Posted March 1, 2013 thank you Lee Mac for reply and to all posted here Quote Link to comment Share on other sites More sharing options...
togores Posted March 1, 2013 Share Posted March 1, 2013 (edited) Hellowhat 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 March 1, 2013 by togores 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 1, 2013 Share Posted March 1, 2013 thank you Lee Macfor reply and to all posted here You're welcome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.