Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Can someone help me modify this lisp routine to sum the hatch areas it calculates?
I would like to be able to select the hatches one at a time or with a window and have the sum of the areas displayed.
Thanks to Daniel J. Altamura for the following routine: (discovered at http://discussion.autodesk.com/thread.jspa?message
(defun c:HatchArea (/ ENT)
(if (>= (atof (substr (getvar "acadver") 1 4)) 16.2)
(progn
(while (not (setq ENT (entsel "\nSelect hatch: ")))
(prompt "\nNo object selected.")
)
(setq ENT (entget (car ENT)))
(if (= (cdr (assoc 0 ENT)) "HATCH")
(progn
(setq ENT (vlax-ename->vla-object (cdr (assoc -1 ENT))))
(alert
(strcat
"\nArea = "
(if (or (= (getvar "lunits") 3) (= (getvar "lunits") 4))
(strcat
(rtos (vla-get-area ENT) 2)
" sq. in. ("
(rtos (/ (vla-get-area ENT) 144) 2)
" sq. ft.)"
)
(rtos (vla-get-area ENT))
)
)
)
)
(prompt "\nThis is not a hatch object.")
)
)
)
(princ)
)
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
(if (>= (atof (substr (getvar "acadver") 1 4)) 16.2)
(progn
(prompt "\nSelect hatches: ")
(if (setq sset (ssget '((0 . "hatch"))))
(progn
(setq
i (1- (sslength sset))
area 0)
(while (>= i 0)
(setq
obj (vlax-ename->vla-object (ssname sset i))
area (+ area (vla-get-area obj)))
(setq i (1- i)))
(alert
(strcat
"\nTotal area = "
(if (or (= (getvar "lunits") 3) (= (getvar "lunits") 4))
(strcat
(rtos area 2)
" sq. in. ("
(rtos (/ area 144) 2)
" sq. ft.)")
(rtos area))))))))
(princ))
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Works great!
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Can someone please tell me what I am doing wrong with trying to add this sum of hatch areas lisp routine. I have copied the routine directly from here and brought it into notepad. I saved it as a .lsp. I used the appload function to load the new lisp routine and it says it was successful. But when I type the command hatchareas, there is nothing. No error, no unknown command. It just goes back to command without doing anything or asking for any options. I am using Acad 2004.
Thanks,
Jeff
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
jbechard wrote:....when I type the command hatchareas, there is nothing. No error, no unknown command. It just goes back to command without doing anything or asking for any options. I am using Acad 2004.
....
I'm in ADT2004, and it does the same for me. It's the (if) test at the top. My ACADVER is 16.0, and that's earlier than what it's testing for. If I take out the test, I get an "unknown name: Area" message. The Area property of Hatch patterns was apparently added to a later version, but isn't available for me -- hence the (if) test. In earlier versions that don't recognize that property of Hatch patterns, it would need to be done differently, if it's even possible. You might try Searching the discussion group for some other way of calculating such areas, if there is one.
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thank you for your quick response.
That's unfortunate that it doesn't work with the earlier versions. Hopefully there's another way that it can be done out there.
Thank you for the explanation. It makes sense why it does what it does once I tried it.
Jeff
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Check out: http://www.jtbworld.com/lisp/hatchb.htm
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I just tried that routine and all it seems to do is recreate my boundaries. The problem is that when I have 2 items, for example, one circle inside of another, I need to know the area of what the hatching would be in between them. Like a thick line. But with using the boundaries to get my sum of the areas, it doesn't factor in that I am hatching in between two objects, as opposed to fully hatching both objects. So I have a zone lisp routine that gives me the sum of all boundaries, but again, it doesn't factor in the actual area that is hatched. That's why I need something that actually recognizes the hatch itself.
Re: Sum of Hatch Areas - Lisp Routine Modificati on.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Can someone help me :
I draw Several hatches in separate layers and I need a lisp that calculate cumulative area of they hatches in separate layers and print the results to an excel table. similar this :
cumulative area | Name of Layer |
................................................. | Layer1 |
................................................. | Layer2 |
| . . . |
................................................. | Layer n |

