minhphuong_humg Posted July 1, 2018 Posted July 1, 2018 Hi everybody, I have a drawing with Texts (elevation) and Circles. I want move Texts to Center into Circle (view attach). Please, help me a lisp to Move Texts into Center Circle. Thank you very much! Please, view file attach. Elevation.dwg Quote
dlanorh Posted July 1, 2018 Posted July 1, 2018 Is this connected with the post in the other thread about placing a node at the center of a circle/block? If it is the two could be combined. Does the block need to remain in the drawing or does it need to be replaced? Quote
BIGAL Posted July 1, 2018 Posted July 1, 2018 Lee's code gives you a lot of clues for a block. You dont need a Point as you are after the insertion point as a variable. In a simple routine just window text and object. Look at the objects if a block use Lee's code if a circle just get center point. You will need say 3 defuns Circle, block, text. The last step is to just do the move text. If you want to do all in one go then you would ssget the text only and look for an object close by, again lots of examples of how to do this. Quote
mrroyal102 Posted July 3, 2018 Posted July 3, 2018 You can create a circle to point using lisp move text to point Quote
BIGAL Posted July 3, 2018 Posted July 3, 2018 Any way had a go BUT ! the dwg has some problems see image below, text is repeated so its not perfect. ; hard coded for 10 units away (defun ah:test4 ( / x ss ss2 pt pt2 pt3 pt4 pt5 obj obj2 objpt oldsnap) (setq ss (ssget (list (cons 0 "insert")(cons 2 "DCCT")))) (setq oldsnap (getvar 'osmode)) (repeat (setq x (sslength ss)) (princ x)(princ "\n") (setq pt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint (vlax-ename->vla-object (ssname ss (setq x (- x 1))) ))))) (setq pt2 (polar (polar pt 0.0 10)(/ pi 2.0) 10)) (setq pt3 (polar pt2 pi 20)) (setq pt4 (polar pt3 (* 1.5 pi) 20)) (setq pt5 (polar pt4 0.0 20)) (if (/= (setq ss2 (ssget "_wp" (list pt2 pt3 pt4 pt5) (list (cons 0 "Text")))) nil) (progn (setq obj (ssname ss2 0)) (setq objpt (vlax-safearray->list (vlax-variant-value (vla-get-TextAlignmentPoint (vlax-ename->vla-object obj) )))) (command "move" obj "" objpt pt) ) (alert "object missed greater than 10 away") ) (setq ss2 nil) ) (setvar 'osmode oldsnap) (princ) ) (AH:test4) Quote
Emmanuel Delay Posted July 3, 2018 Posted July 3, 2018 Elevation2.dwg I notice a lot of doubles: 2 or 3 texts per circle. Anyway, they get put one on the other. It takes some time to process all of this, mostly therefor I print the number of texts that have been processed. (defun c:dd ( / circles texts i j dist min ti) (setq texts (ssget "_X" '((0 . "TEXT") ) )) (if (setq circles (ssget "_X" '((0 . "INSERT") (2 . "DCCT") ) )) (progn (setq i 0) (repeat (sslength texts) (setq j 0) (setq min 10000) (repeat (sslength circles) (setq dist (distance (cdr (assoc 10 (entget (ssname texts i)))) (cdr (assoc 10 (entget (ssname circles j)))) ) ) (if (< dist min) (progn (setq min dist) (setq ti j) ;; ti remembers the index of the circle to be moved to )) (setq j (+ j 1)) ) (princ "\nText: ") (princ i) (vla-move (vlax-ename->vla-object (ssname texts i)) (vlax-3d-point (cdr (assoc 10 (entget (ssname texts i))))) (vlax-3d-point (cdr (assoc 10 (entget (ssname circles ti))))) ) (setq i (+ i 1)) ) )) (princ) ) 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.