Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My lisp routine isn't working anymore. Can you help me with this?
Moderator Edit** Post your code in a code window.
;
;
;C:SOLID_WEIGHT FUNCTION TO FIND THE WEIGHT OF A SOLID OR SET OF SOLIDS. ALERTS OF WEIGHT
;OR FILLS OUT WEIGHT BLOCK IF FOUND
(DEFUN C:SOLWT ( / WEIGHT done fp line ofp v ss1 weight_block weight_block_SS matltype matlfact atts WEIGHTLB wb)
(initerr)
(setq fp "c:/temp/solid_weight.mpr")
(setq ofp (open fp "w"))
(close ofp)
(prompt "\nSelect objects to weigh...")
(setq ss1 (ssget))
(initget 1 "S CC SS A 2 G C I")
(setq matltype (getkword "Select material type (<S>A36/A588/A514/AR360 <CC>Chrome Carbide <SS>304/316 Stainless <A>ALUMINUM <2>2205 Stainless <I>Inconel 625 <G>HASTELLOY B-582 <C>HASTELLOY B-575: "))
(cond
((= matltype "S")
(setq matlfact 7.841805)
)
((= matltype "CC")
(setq matlfact 8.248705)
)
((= matltype "G")
(setq matlfact 8.58086660)
)
((= matltype "SS")
(setq matlfact 8.0272623)
)
((= matltype "A")
(setq matlfact 2.71266105)
)
((= matltype "2")
(setq matlfact 7.69509970)
)
((= matltype "C")
(setq matlfact 8.885)
)
((= matltype "I")
(setq matlfact 8.44246550)
)
)
(IF SS1
(PROGN
(command "_massprop" ss1 "" "y" fp )
(setq ofp (open fp "r"))
(while (and (not done)(/= (setq line (read-line ofp)) nil))
(if (= (instr line "Volume") 1)
(progn
(setq v (atof (substr line 26)))
(setq done t)
)
)
)
(close ofp)
(if (= "M" (strcase (get_default "METRIC-ENGLISH" "defaults.dat")))
(SETQ WEIGHT (* (* matlfact 0.000001) V)) ; need to adjust this is for metric models
(SETQ WEIGHT (* 16.387048667871174969170323209728 (* (* matlfact 0.001) V))) ; need to adjust this for english models
)
(SETQ WEIGHTLB (* WEIGHT 2.2046))
(setq wb (ssget "X" (list (CONS 2 "WEIGHT")(CONS 0 "INSERT")(CONS 410 (GETVAR "CTAB")))))
(if wb
(setq weight_block (ssname wb 0))
(IF (/= (setq clayout (STRCASE (getvar "ctab"))) "MODEL")
(PROGN
(COMMAND "PSPACE")
(setq attdia_sav (getvar "attdia"))
(setq ATTREQ_SAV (getvar "ATTREQ"))
(setvar "attdia" 0)
(setvar "ATTREQ" 0)
(default_layer "dimension")
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(command "_insert" "WEIGHT" "8.5522,57.9783,0" "1" "" "0")
(setvar "osmode" oldsnap)
(PREV_LAY)
(setvar "ATTREQ" ATTREQ_SAV)
(setvar "attdia" attdia_sav)
(setq wb (ssget "X" (list (CONS 2 "*WEIGHT")(CONS 0 "INSERT")(CONS 410 (GETVAR "CTAB")))))
(setq weight_block (ssname wb 0))
)
)
)
(setq atts (append (list (list "WEIGHT" (STRCAT (rtos WEIGHTLB 2 3) " lbs."))) atts))
(IF weight_block
(ATT_REP weight_block atts)
(alert (strcat "\nWeight of selected solids is " (rtos weight 2 2) " Kg." "\n" (rtos WEIGHTLB 2 3) " Lbs."))
)
WEIGHTLB
)
)
(RESET)
)
Solved! Go to Solution.