SWfangirl Posted June 27, 2011 Share Posted June 27, 2011 (edited) Hello, My coworker found this lisp and it doesn't appear to be working correctly. I honestly still don't know enough about lisp to figure it out. As the title says it should select all of the hatch in a drawing then calculate the total area. If anyone can help I would really appreciate it. Again this is not something either of us wrote it was found in the autodesk discussion groups. When I load it this is the error I get. ; error: no function definition: VLAX-ENAME->VLA-OBJECT [font=Times New Roman][size=3](defun c:HatchAreas (/ sset i area obj)[/size][/font] [size=3][font=Times New Roman](if (>= (atof (substr (getvar "acadver") 1 4)) 16.2)[/font][/size] [size=3][font=Times New Roman](progn[/font][/size] [size=3][font=Times New Roman](prompt "\nSelect hatches: ")[/font][/size] [size=3][font=Times New Roman](if (setq sset (ssget '((0 . "hatch"))))[/font][/size] [size=3][font=Times New Roman](progn[/font][/size] [size=3][font=Times New Roman](setq[/font][/size] [size=3][font=Times New Roman]i (1- (sslength sset))[/font][/size] [size=3][font=Times New Roman]area 0)[/font][/size] [size=3][font=Times New Roman](while (>= i 0)[/font][/size] [size=3][font=Times New Roman](setq[/font][/size] [size=3][font=Times New Roman]obj (vlax-ename->vla-object (ssname sset i))[/font][/size] [size=3][font=Times New Roman]area (+ area (vla-get-area obj)))[/font][/size] [size=3][font=Times New Roman](setq i (1- i)))[/font][/size] [size=3][font=Times New Roman](alert[/font][/size] [size=3][font=Times New Roman](strcat[/font][/size] [size=3][font=Times New Roman]"\nTotal area = "[/font][/size] [size=3][font=Times New Roman](if (or (= (getvar "lunits") 3) (= (getvar "lunits") 4))[/font][/size] [size=3][font=Times New Roman](strcat[/font][/size] [size=3][font=Times New Roman](rtos area 2)[/font][/size] [size=3][font=Times New Roman]" sq. in. ("[/font][/size] [size=3][font=Times New Roman](rtos (/ area 144) 2)[/font][/size] [size=3][font=Times New Roman]" sq. ft.)")[/font][/size] [size=3][font=Times New Roman](rtos area))))))))[/font][/size] [size=3][font=Times New Roman](princ))[/font][/size] Edited June 27, 2011 by SLW210 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 27, 2011 Share Posted June 27, 2011 Check this one buddy . (defun c:Test (/ ar ss sset i vl e) ;; Tharwat 27. 06. 2011 (setq ar 0) (vl-load-com) (if (setq ss (ssget "_x" '((0 . "HATCH")))) (repeat (setq i (sslength ss)) (setq sset (ssname ss (setq i (1- i)))) (setq vl (vlax-ename->vla-object sset)) (setq e (entget sset)) (setq ar (+ ar (vla-get-area vl))) ) (princ) ) (alert (strcat "\n" (strcat "Area of Hatches :" " " (rtos ar 2)) ) ) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 (edited) Hello,My coworker found this lisp and it doesn't appear to be working correctly. I honestly still don't know enough about lisp to figure it out. As the title says it should select all of the hatch in a drawing then calculate the total area. If anyone can help I would really appreciate it. Again this is not something either of us wrote it was found in the autodesk discussion groups. When I load it this is the error I get. ; error: no function definition: VLAX-ENAME->VLA-OBJECT [font=Times New Roman][size=3](defun c:HatchAreas (/ sset i area obj)[/size][/font] [size=3][font=Times New Roman](if (>= (atof (substr (getvar "acadver") 1 4)) 16.2)[/font][/size] [size=3][font=Times New Roman](progn[/font][/size] [size=3][font=Times New Roman](prompt "\nSelect hatches: ")[/font][/size] [size=3][font=Times New Roman](if (setq sset (ssget '((0 . "hatch"))))[/font][/size] [size=3][font=Times New Roman](progn[/font][/size] [size=3][font=Times New Roman](setq[/font][/size] [size=3][font=Times New Roman]i (1- (sslength sset))[/font][/size] [size=3][font=Times New Roman]area 0)[/font][/size] [size=3][font=Times New Roman](while (>= i 0)[/font][/size] [size=3][font=Times New Roman](setq[/font][/size] [size=3][font=Times New Roman]obj (vlax-ename->vla-object (ssname sset i))[/font][/size] [size=3][font=Times New Roman]area (+ area (vla-get-area obj)))[/font][/size] [size=3][font=Times New Roman](setq i (1- i)))[/font][/size] [size=3][font=Times New Roman](alert[/font][/size] [size=3][font=Times New Roman](strcat[/font][/size] [size=3][font=Times New Roman]"\nTotal area = "[/font][/size] [size=3][font=Times New Roman](if (or (= (getvar "lunits") 3) (= (getvar "lunits") 4))[/font][/size] [size=3][font=Times New Roman](strcat[/font][/size] [size=3][font=Times New Roman](rtos area 2)[/font][/size] [size=3][font=Times New Roman]" sq. in. ("[/font][/size] [size=3][font=Times New Roman](rtos (/ area 144) 2)[/font][/size] [size=3][font=Times New Roman]" sq. ft.)")[/font][/size] [size=3][font=Times New Roman](rtos area))))))))[/font][/size] [size=3][font=Times New Roman](princ))[/font][/size][/quote] Try adding (vl-load-com) to the code. You need to load the Visual LISP/ActiveX function library. Edited June 27, 2011 by SLW210 Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 OH yeah, and read this: http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 27, 2011 Share Posted June 27, 2011 ; error: no function definition: VLAX-ENAME->VLA-OBJECT Check this one buddy . (defun c:Test (/ ar ss sset i vl e) (setq ar 0) (vl-load-com) (if (setq ss (ssget "_x" '((0 . "HATCH")))) (repeat (setq i (sslength ss)) (setq sset (ssname ss (setq i (1- i)))) (setq vl (vlax-ename->vla-object sset)) (setq e (entget sset)) (setq ar (+ ar (vla-get-area vl))) ) (princ) ) (alert (strcat "\n" (strcat "Area of Hatches :" " " (rtos ar 2)) ) ) (princ) ) Try adding (vl-load-com) to the code. You need to load the Visual LISP/ActiveX function library. ........ Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 27, 2011 Share Posted June 27, 2011 ........ Wonder why ! Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 Just getting ready... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 27, 2011 Share Posted June 27, 2011 Blow up pop corns everywhere Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 27, 2011 Share Posted June 27, 2011 Wonder why ! That's even funnier. The OP needed a toothpick, and you gave them a tree. In other words, you chose to work harder... LoL Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 The OP needed a toothpick, and you gave them a tree. The OP had a box of toothpicks, but couldn't open them. He cut down the tree and whittled out a toothpick, rather than showing them how, or just opening the box for them. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted June 27, 2011 Share Posted June 27, 2011 Please use code tags (#) SWfangirl. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 27, 2011 Share Posted June 27, 2011 The OP had a box of toothpicks, but couldn't open them. He cut down the tree and whittled out a toothpick, rather than showing them how, or just opening the box for them. That's fair. ... And don't get me wrong, I know I've done the same in the past. That's why it's funny to me. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 Please use code tags (#) SWfangirl. What, you think you're some kind of moderator or something? YES I DO..... Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 That's fair. ... And don't get me wrong, I know I've done the same in the past. That's why it's funny to me. It's all funny to me. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 27, 2011 Share Posted June 27, 2011 You are in a great mood Alan today/tonight. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 What, you think you're some kind of moderator or something? YES I DO..... You dirty dog! ROFL Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 27, 2011 Share Posted June 27, 2011 That's even funnier. The OP needed a toothpick, and you gave them a tree. In other words, you chose to work harder... LoL I hope that they would get the fruit of it , not the mood. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 I hope that they would get the fruit of it , not the mood. ...................... Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 27, 2011 Share Posted June 27, 2011 I hope that they would get the fruit of it , not the mood. Wow... a self-inflicted face-palm... haven't seen one of those in a while. lmao Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 27, 2011 Share Posted June 27, 2011 Forget the exchange of knowledge and/or pr0n, THIS is why I love the internet. Quote Link to comment Share on other sites More sharing options...
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.