stephenjose Posted August 24, 2011 Posted August 24, 2011 using autolisp program or any tool in autocad 2004.I want to align the text to the center of the polygon.I have pasted the text in end of the each polygon.But now i want to align it to the center of the polygon.It should be worked for all selected polygons.Polygons Size are different. Quote
Guest kruuger Posted August 24, 2011 Posted August 24, 2011 you can use this on start (defun c:CEN (/ SS C CEN) (princ "\nSelect polygones: ") (if (setq SS (ssget '((0 . "LWPOLYLINE")))) (progn (setq C 0) (repeat (sslength SS) (setq CEN (kr:GOE_GetCentroidCoordinates (vlax-Ename->vla-Object (ssname SS C)) ) ) (entmakex (list (cons 0 "CIRCLE") (cons 10 (trans CEN 1 0)) (cons 40 2) ) ) (setq C (1+ C)) ) ) (princ "\n** Nothing selected **") ) (princ) ) ; ============================================================ ; ; Get centroid coordinates ; ; Obj - VLA object ; ; ============================================================ ; (defun kr:GOE_GetCentroidCoordinates (Obj / RA PT TEMP) (if (not (vl-catch-all-error-p (setq RA (vl-catch-all-apply 'vlax-invoke (list (vla-get-modelspace (vla-get-document Obj) ) 'AddRegion (list Obj) ) ) ) ) ) (progn (setq PT (vlax-get (setq TEMP (car RA)) 'Centroid ) ) (vla-delete TEMP) ) ) PT ) kruuger Quote
stephenjose Posted August 24, 2011 Author Posted August 24, 2011 we have the 3dpolyline drawings not lwpolyline drawings.The message displayed as "1 Found" "1 was Filtered out" For a Single Selected Polygon. Quote
Lee Mac Posted August 24, 2011 Posted August 24, 2011 This will return the coordinates of the centroid of an object, using a similar method to Kruuger: (defun _centroid ( obj / reg cen ) (setq reg (car (vlax-invoke (vla-objectidtoobject (vla-get-document obj) (vla-get-ownerid obj)) 'addregion (list obj))) cen (vlax-get reg 'centroid) ) (vla-delete reg) cen ) Call with: (_centroid <VLA-Object>) Quote
BlackBox Posted August 24, 2011 Posted August 24, 2011 FWIW - I added Gile's Custom OSNAPs program a while back, and find it to be very useful. Quote
stephenjose Posted August 24, 2011 Author Posted August 24, 2011 I have attached the sample gif and highlighted the text placed in polygons.I want to align the text to center of the polygon for all single polygons.I have tried more lisp and auto cad 2004 tools but still cannot resolve the issue.Thanks. Quote
SLW210 Posted August 24, 2011 Posted August 24, 2011 What is the justification of the text? Does AutoCAD 2004 have M2P? If not there used to be a LISP for that. Quote
stephenjose Posted September 12, 2011 Author Posted September 12, 2011 it's not working.i am having more than 500 polygons.please see the above image for reference.. Quote
pBe Posted September 12, 2011 Posted September 12, 2011 it's not working.i am having more than 500 polygons.please see the above image for reference.. What is not working? What code did you use? do you have the actual routine to move the text to the center of the polyline? As stated before, factors to consider. Text justification UCS Type of pline Quote
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.