TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on December 20, 2019, 01:03:32 PM
-
Ok, I sometimes get an error or crash using this code.
Yes, I'm stumped.
Here is another example for MP
Please help
-
Sorry, I forget this function:
;;;Victor Delgado VDelgado@alhansen.com
(defun ARCH:UpdateBlocks (BlockName AttTag AttVal / ssBlocks ssObjects Block)
(vl-load-com)
(setq ssBlocks (ssget "x" (list (cons 2 BlockName))))
(if ssBlocks
(progn (setq ssObjects
(vla-get-ActiveSelectionSet
(vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for
Block ssObjects
(foreach
Attribute (vlax-invoke Block "GetAttributes")
(if (= (vla-get-TagString Attribute) AttTag)
(vla-put-TextString Attribute AttVal))
(vla-update Attribute)))))
(princ))
(ARCH:UpdateBlocks "DRHortonTBH" "ADD" (vl-string-left-trim (substr (vl-filename-base (getvar "dwgname")) 1 16)
(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 27))))
-
Error message ?
-
Can't divide by 0.
Or it would just crash...
Here is an example of what I modified:
(if (= tot_areabrk nil)(setq tot_areabrk 0))
(if (= tot_areasid nil)(setq tot_areasid 0))
(if (= tot_areastn nil)(setq tot_areastn 0))
It seems to be working now...just a crude example of code.