Jump to content

help with routine...


leonucadomi

Recommended Posts

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

image.png.5cb237d1ca6a161969cdd9321249ee83.png

 

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

Link to comment
Share on other sites

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
    )
)

 

  • Thanks 1
Link to comment
Share on other sites

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>")
    )))

 

Link to comment
Share on other sites

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.

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...