Author Topic: Getting Area From Hatch Error  (Read 1444 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Getting Area From Hatch Error
« 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
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Getting Area From Hatch Error
« Reply #1 on: December 20, 2019, 01:13:10 PM »
Sorry, I forget this function:

Code: [Select]
;;;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))))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Dlanor

  • Bull Frog
  • Posts: 263
Re: Getting Area From Hatch Error
« Reply #2 on: December 20, 2019, 04:12:28 PM »
Error message ?

GDF

  • Water Moccasin
  • Posts: 2081
Re: Getting Area From Hatch Error
« Reply #3 on: December 20, 2019, 04:41:13 PM »
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.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64