Jump to content

Recommended Posts

Posted

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

 

 

 

Posted

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

 

  • Thanks 1
Posted (edited)

1 m3 = 7850 kg

1 ft3 = 490 lbs

 

1000000000 = 1e-09 use multiply. If object is mm.

Edited by BIGAL
  • Thanks 1
Posted

i will try , thanks masters

Posted

I already tried and it does not give the correct values, I think it takes a wrong entity when executing the following times :(

Posted

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

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