Jump to content

how to align text to center of the polygon


Recommended Posts

Posted

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.

Guest kruuger
Posted

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

Posted

we have the 3dpolyline drawings not lwpolyline drawings.The message displayed as "1 Found" "1 was Filtered out" For a Single Selected Polygon.

Posted

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>)

Posted

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.

Sample2.jpg

Posted

What is the justification of the text? Does AutoCAD 2004 have M2P? If not there used to be a LISP for that.

  • 3 weeks later...
Posted

it's not working.i am having more than 500 polygons.please see the above image for reference..

Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...