Bikey_4 Posted July 4, 2016 Share Posted July 4, 2016 Hi there, I've got a LisP file which help me to get area value of closed polyline and assign it to a text. It require picking a point inside then it will creat a closest polyline around the picked point. However, my drawing has already had some polyline, and I want to get their area by clicking at the polyline itself. Unfortunately, I have no idea about LisP. Hope you guy can help me solve this problem. Thx a lot! (Pls see attachment for more details) DTICH.LSP Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted July 4, 2016 Share Posted July 4, 2016 (defun c:test ( / a b c) (if (setq a (ssget '((0 . "*polyline")))) (progn (setq b 0) (repeat (setq i (sslength a)) (setq b (+ (vla-get-area (vlax-ename->vla-object (ssname a (setq i (1- i)))) ) b ) ) ) (setq c (strcat "\nComponent Area : " (rtos b 2 5))) (alert c) (prompt c) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Bikey_4 Posted July 4, 2016 Author Share Posted July 4, 2016 Seems your LisP is used to get the sum of polyline's areas. Is there any idea for separated polylines? Thanks for your comment! Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted July 4, 2016 Share Posted July 4, 2016 You can select at the time for that else Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted July 4, 2016 Share Posted July 4, 2016 This one marks text with the area at start point of the polyline. (defun c:test (/ a b c) (vl-load-com) (if (setq a (ssget '((0 . "*polyline")))) (repeat (setq i (sslength a)) (setq b (vlax-ename->vla-object (ssname a (setq i (1- i))))) (setq c (vlax-get b 'coordinates)) (command ".text" "c" "_non" (list (car c) (cadr c)) 50 ; <- change text height here as per your requirement 0 ; <- change text rotation here as per your requirement (rtos (vla-get-area b) 2 5) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 6, 2016 Share Posted July 6, 2016 Another way to approach is to still use the bpoly get its area then erase Last and write text. I think its code by GP has a brilliant area routine whereby it works out the center of the area for the text position. Quote Link to comment Share on other sites More sharing options...
zwonko Posted April 23 Share Posted April 23 On 7/6/2016 at 4:53 AM, BIGAL said: think its code by GP has a brilliant area routine whereby it works out the center of the area for the text position. Could You explain what code You mean? Loking for something that will work out the center of polyline. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 23 Share Posted April 23 (edited) This may help (setq pt (osnap (vlax-curve-getStartPoint obj) "gcen")) ; obj is a VL object But note if you have say a "U" shape pt may not be inside pline. Edited April 23 by BIGAL Quote Link to comment Share on other sites More sharing options...
zwonko Posted April 24 Share Posted April 24 Thanks @BIGAL. Thought about that, that geometric center is not always inside polyline. Using QGIS, it also can label in center of polyline but it also have option "force point inside polygon". I'm curious about the algorithm that controls that. For me, most problem is "L" shape polylines. Thought that algorith in QGIS could be something like that it is finding geometric center or something like here in ATM code: https://jtbworld.com/autocad-areatext-lsp After finding center (geometric or like in ATM) it is finding intersection with horizontal (or vertical xlines). After that, sorting X (or Y for vertical) and find if center is before/inside/after X of intersection. After that, choose/calculate new X. Quote Link to comment Share on other sites More sharing options...
GP_ Posted April 26 Share Posted April 26 (edited) On 7/6/2016 at 4:53 AM, BIGAL said: Another way to approach is to still use the bpoly get its area then erase Last and write text. I think its code by GP has a brilliant area routine whereby it works out the center of the area for the text position. Edited April 26 by GP_ 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.