LISP or Command?

LISP or Command?

anderson51
Advocate Advocate
702 Views
7 Replies
Message 1 of 8

LISP or Command?

anderson51
Advocate
Advocate

I am trying to figure out how to write a LISP routine or generate an equation within a command that will take MASSPROP and divide that number by 17.28, then times it by 4.9.......when I click on a solid?

 

I apprecite the help.

 

Anderson

0 Likes
Accepted solutions (1)
703 Views
7 Replies
Replies (7)
Message 2 of 8

hmsilva
Mentor
Mentor

@anderson51 wrote:

I am trying to figure out how to write a LISP routine or generate an equation within a command that will take MASSPROP and divide that number by 17.28, then times it by 4.9.......when I click on a solid?

 

I apprecite the help.

 

Anderson


Hi Anderson,

 

@ the Visual LISP, AutoLISP and General Customization forum should be easier to help with Auto/Visual LISP

 

Perhaps something like this to do the trick

 

(vl-load-com)
(defun c:demo (/ obj ss val vol)
    (if (and (princ "\n Select a 3D Solid: ")
             (setq ss (ssget "_+.:E:S" '((0 . "3DSOLID"))))
        )
        (progn
            (setq obj (vlax-ename->vla-object (ssname ss 0))
                  vol (vla-get-volume obj)
                  val (* (/ vol 17.28) 4.9)
            )
            (princ (strcat "\n The value is: " (rtos val 2 2)))
        )
        (princ "\n You didn't select a 3D Solid... ")
    )
    (princ)
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 8

anderson51
Advocate
Advocate

Thank you for the help, that works for selecting 1 solid.

 

Is there a way to set it up where you can window a group of solids?

 

 

Thanks again.

 

Anderson

0 Likes
Message 4 of 8

hmsilva
Mentor
Mentor

@anderson51 wrote:

Thank you for the help, that works for selecting 1 solid.

 

Is there a way to set it up where you can window a group of solids?

 

 

Thanks again.

 

Anderson


You're welcome, Anderson
The final result would be only the total?

Henrique

EESignature

0 Likes
Message 5 of 8

anderson51
Advocate
Advocate

Yes.

 

0 Likes
Message 6 of 8

hmsilva
Mentor
Mentor
Accepted solution
(vl-load-com)
(defun c:demo (/ obj ss tot val vol)
    (if (and (princ "\n Select a 3D Solid: ")
             (setq ss (ssget '((0 . "3DSOLID"))))
        )
        (progn
            (setq tot 0.0)
            (repeat (setq i (sslength ss))
                (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
                      vol (vla-get-volume obj)
                      val (* (/ vol 17.28) 4.9)
                      tot (+ tot val)
                )
            )
            (princ (strcat "\n The value is: " (rtos tot 2 2)))
        )
        (princ "\n You didn't select a 3D Solid... ")
    )
    (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 7 of 8

anderson51
Advocate
Advocate

Fantastic, thank you for the help sir.

 

Anderson

0 Likes
Message 8 of 8

hmsilva
Mentor
Mentor

@anderson51 wrote:

Fantastic, thank you for the help sir.

 

Anderson


You're welcome, Anderson!
Glad I could help

Henrique

EESignature

0 Likes