leonucadomi Posted December 27, 2022 Posted December 27, 2022 hello all: I am making a routine that does the following. 1.- select a 3d solid (ent1) 2.- select other 3d solid (ent2) after making a subtraction. and then obtain the weight (steel) of that solid generated. here is my code. but something is wrong (defun c:test (/ wtesp ent1 ent2 sol solido masa peso peso3 opp) (vl-load-com) (setq wtesp (* 1 7850)) (setq ent1 (entsel)) (setq ent2 (entsel)) (command "__subtract" ent1 "" ent2 "") (setq sol (entlast)) (setq solido (vlax-ename->vla-object (car sol))) (setq masa (vlax-get-property solido 'Volume)) (setq peso (* masa wtesp)) (setq peso3 (/ peso 1000000000)) (setq opp (rtos peso3 2 3)) (princ "\nPeso = ") (princ opp) (princ) );fin defun Quote
mhupp Posted December 27, 2022 Posted December 27, 2022 entsel needs to have car because it returns the entity name and point of mouse click. entlast doesn't need car because its just the last entity name in the drawing database. Consolidated the code down a bit. (defun c:test (/ ent1 ent2 v p) (if (and (setq ent1 (car (entsel "\nSelect 1st Solid"))) (setq ent2 (car (entsel "\nSelect 2nd Solid")))) (progn (command "__subtract" ent1 "" ent2 "") (setq v (vlax-get-property (vlax-ename->vla-object (entlast)) 'Volume)) (setq p (/ (* v 7850) 1000000000)) ;check formula this seems off (prompt (strcat "\nArea = " (rtos v 2 3))) (prompt (strcat "\nPeso = " (rtos p 2 3))) ) ) (princ) ) 1 Quote
BIGAL Posted December 28, 2022 Posted December 28, 2022 (edited) 1 m3 = 7850 kg 1 ft3 = 490 lbs 1000000000 = 1e-09 use multiply. If object is mm. Edited December 28, 2022 by BIGAL 1 Quote
leonucadomi Posted December 28, 2022 Author Posted December 28, 2022 i will try , thanks masters Quote
leonucadomi Posted December 28, 2022 Author Posted December 28, 2022 I already tried and it does not give the correct values, I think it takes a wrong entity when executing the following times Quote
BIGAL Posted December 29, 2022 Posted December 29, 2022 Need more info like is correct volume weight being used, what is units feet mm etc. A typo ? (prompt (strcat "\nArea = " (rtos v 2 3))) (prompt (strcat "\nVolume = " (rtos v 2 3))) 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.