Jump to content

renamed: Move a char to the center of objects


AUTOCAD IS MY LIFE

Recommended Posts

i have a lisp : this lisp will be move the character to center another object(rectang, circle,...), please help me upgrade this lisp :Just click on the space of the object don't need click the object

(defun c:m2c ()
 (defun mid (ent / p1 p2)
   (vla-getboundingbox (vlax-ename->vla-object ent) 'p1 'p2)
   (setq p1 (vlax-safearray->list p1)
  p2 (vlax-safearray->list p2)
  pt (mapcar '+ p1 p2)
  pt (mapcar '* pt '(0.5 0.5 0.5))
   )
   pt
 )
 (setq src (car (entsel "\nobject to be moved: ")))
 (redraw src 3)
 (setq des (car (entsel "\npick center object: ")))
 (redraw src 4)
 (setq oldos (getvar "osmode"))
 (setvar "osmode" 0)
 (command ".move" src "" (mid src) (mid des))
 (setvar "osmode" oldos)
 (princ)
)
(vl-load-com)
Edited by fuccaro
Renamed, added CODE tags...
Link to comment
Share on other sites

  • fuccaro changed the title to renamed: Move a char to the center of objects

If you use bpoly it will make a new object inside a closed shape so can be multiple objects so long as your internal is closed. Once you have that new pline you can get centroid or some form of average point of the vertices. In the case of the circle it will make 2 arcs.

Link to comment
Share on other sites

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