leonucadomi Posted February 16 Posted February 16 hello all people: I have this routine I am interested in extruding closed polylines and thus convert them to solids , I am interested in printing the area of each polyline and obtaining the weight of the solids created. I just need to put a filter so that it only selects closed polylines Also in each iteration this appears and I would like to remove it and have the information displayed together here I put my code (defun c:test (/ ESP sel nums A1 A2 esp2 volu pes A3 pes2 ) (setvar "cmdecho" 0) (setq ESP (getreal "\nIngresa espesor en mm. ")) (prompt "\nSelecciona polilineas a extruir: ") (setq sel (ssget (list (cons 0 "LWPOLYLINE")))) (setq nums (sslength sel)) (setq n 0) (repeat nums (setq nt (ssname sel n)) (command "area" "O" nt) (setq A1 (getvar "area")) (setq A2 (/ A1 1000000)) (setq esp2 (/ ESP 1000)) (setq volu (* A2 esp2)) (setq pes (* volu 7850)) (command "_extrude" nt "" ESP "") (setq A3 ( LM:rtos (/ A1 1000000) 2 3)) (setq pes2 ( LM:rtos pes 2 3)) (textscr) (princ (strcat "\nArea(M2)" " de objeto " (itoa (1+ n)) " = " A3)) (princ (strcat "\nPeso(Kg)" " de objeto " (itoa (1+ n)) " = " pes2)) (setvar "cmdecho" 0) (setq n (1+ n)) );repeat nums (princ "\nTotal de elementos extruidos = ") (princ nums) (princ) );fin defun ;; rtos wrapper - Lee Mac ;; A wrapper for the rtos function to negate the effect of DIMZIN (defun LM:rtos ( real units prec / dimzin result ) (setq dimzin (getvar 'dimzin)) (setvar 'dimzin 0) (setq result (vl-catch-all-apply 'rtos (list real units prec))) (setvar 'dimzin dimzin) (if (not (vl-catch-all-error-p result)) result ) ) any comment is welcomed Quote
Tsuky Posted February 16 Posted February 16 It's better? (defun c:test (/ ESP sel nums A1 A2 esp2 volu pes A3 pes2 ) (setvar "cmdecho" 0) (setq ESP (getreal "\nIngresa espesor en mm. ")) (prompt "\nSelecciona polilineas a extruir: ") (setq sel (ssget '((0 . "*POLYLINE") (-4 . "<AND") (-4 . "<NOT") (-4 . "&") (70 . 120) (-4 . "NOT>") (-4 . "&") (70 . 1) (-4 . "AND>")))) (setq nums (sslength sel)) (setq n 0) (repeat nums (setq nt (ssname sel n)) (command "_.area" "_object" nt) (setq A1 (getvar "area")) (setq A2 (/ A1 1000000)) (setq esp2 (/ ESP 1000)) (setq volu (* A2 esp2)) (setq pes (* volu 7850)) (command "_.extrude" nt "" ESP) (setq A3 ( LM:rtos (/ A1 1000000) 2 3)) (setq pes2 ( LM:rtos pes 2 3)) (princ (strcat "\nArea(M2)" " de objeto " (itoa (1+ n)) " = " A3)) (princ (strcat "\nPeso(Kg)" " de objeto " (itoa (1+ n)) " = " pes2)) (setvar "cmdecho" 0) (setq n (1+ n)) );repeat nums (textscr) (princ "\nTotal de elementos extruidos = ") (princ nums) (princ) );fin defun ;; rtos wrapper - Lee Mac ;; A wrapper for the rtos function to negate the effect of DIMZIN (defun LM:rtos ( real units prec / dimzin result ) (setq dimzin (getvar 'dimzin)) (setvar 'dimzin 0) (setq result (vl-catch-all-apply 'rtos (list real units prec))) (setvar 'dimzin dimzin) (if (not (vl-catch-all-error-p result)) result ) ) 1 Quote
leonucadomi Posted February 16 Author Posted February 16 It improved a lot, could you make it also select circles? Quote
leonucadomi Posted February 16 Author Posted February 16 thanks already added this (setq sel (ssget '((-4 . "<OR") (-4 . "<AND") (0 . "LWPOLYLINE") (70 . 1) (-4 . "AND>") (-4 . "<AND") (0 . "CIRCLE") (-4 . "AND>") (-4 . "OR>") ))) Quote
BIGAL Posted February 17 Posted February 17 If you make a solid then using ( vlax-get (vlax-ename->vla-object (entlast)) 'Volume) will return the volume, note in your calcs to maintain accuracy a good idea is use reals 7850.0. You can end up with integer answers and not realise it. Quote
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.