eimimitu Posted October 30, 2017 Posted October 30, 2017 Hello everyone, I’ve dove head first into the overwhelming world of Autolisp… and needless to say I’m in way over my head. I’ve been trying to put together a program for AutoCAD 14 with a dialog box that will allow the user to pick from a drop down list of standard materials/click a “select objects” button… apply selected material to 3D solids and have it display the weight based on the volume of the solid/s. Furthermore, I have added two radio buttons: one for imperial measurement and one for metric measurement. There is also another “select objects” Total button to calculate and display the combined weight of the entire 3D solid assembly. I used a program called ObjectDCL to design the dialog box (ODC file and image attached). But that’s really as far as I got. I found these links as a starting point but couldn’t figure out how to tie it all together: http://www.ellenfinkelstein.com/acadblog/create-a-custom-function-in-autocads-calculator/ http://cadtips.cadalyst.com/mass-properties/tip-2258-calculate-weight http://cadtips.cadalyst.com/mass-properties/tip-2258-calculate-weight http://www.cadtutor.net/forum/showthread.php?50384-Calculating-weight-of-2d-shape-amp-3dsolid-object-by-asigned-material&highlight=material+density http://www.cadtutor.net/forum/showthread.php?89753-Help-please-need-to-combine-to-lisp&highlight=material+density I have the list of materials ready to insert along with the densities in lbs/in^3 I’m hoping one of you programming geniuses could please put it together to get it working as it is intended. I’m also hoping that I could then study that code and get some clue as to how it all works. I'm intrigued by the potential of this programming language and would love to be introduced to it by one of the many experts on this forum. Thanks in advance and please let me know if I missed anything. Matwt.lsp ODC.zip Quote
Grrr Posted October 30, 2017 Posted October 30, 2017 I guess something like this should be used: ; (GetMass (vlax-ename->vla-object (car (entsel))) '(("ByLayer" 0) ("ByBlock" 0) ("Glass" 5) ("Concrete" 20)("Global" 1))) (defun GetMass ( o L ) (if (and (eq 'VLA-OBJECT (type o)) (vlax-property-available-p o 'Material)(vlax-property-available-p o 'Volume)) (* (cond ( (cadr (assoc (vla-get-Material o) L)) ) (0)) (vla-get-Volume o)) ) ); defun GetMass Although you must learn some visual lisp and DCL (or just use LM:ListBox - if you are satisfied just with a user prompt). 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.