Hello,
In one of the many exercises to understand entmod better I have created a nudge command for CIRCLE, TEXT & MTEXT. The basic premise is to modify the coordinates in the 10 list. This is due to them being common coordinates across all three entities. They each mean the following
CIRCLE - centrepoint coordinates
MTEXT - justification point
TEXT - first alignment point
The code works for CIRCLE and MTEXT entities but only on TEXT entities that have Left justification. (ie a number 0 in fields 72 and 73, and the 11 list reads (11 0 0 0). Is there a reason as to why the TEXT entities which have a justification point will not move when I modify the 10 list?
I have posted the code below. (Please note the variable nudgefactor is set separately when I set up a drawing each time)
(defun c:nuntest ( / nudgenorthstuffssget nudgenorthstufflist txtdtxtormtxt);nudge an object north by the stated nudgefactor (nudgfactor)
(princ "\n Select the objects you wish to NUDGE north: ")
(setq nudgenorthstuffssget (ssget (list '(-4 . "<OR") '(0 . "*TEXT") '(0 . "CIRCLE") '(-4 . "OR>"))));creates the selection set using standard autocad selection procedures
(command "UNDO" "BEGIN")
(if nudgenorthstuffssget
(repeat (setq xyxy (sslength nudgenorthstuffssget))
(setq nudgenorthstufflist (cons (ssname nudgenorthstuffssget (setq xyxy (1- xyxy))) nudgenorthstufflist))
);(repeat)
);(if) Lee Mac create a list for processing from the selection set
(foreach nudgenorthstuffpos nudgenorthstufflist ;for each north position (nudgenorthstuffpos) of each entity in the selection set list (nudgenorthstufflist)
(progn
(setq nudgenorthinfo (entget nudgenorthstuffpos));get the entity data as a list
(setq txtdtxtormtxt (assoc 0 nudgenorthinfo));set variable to entity database type (ie TEXT, MTEXT, CIRCLE, ARC and so on)
(setq nudgenorthxy (assoc 10 nudgenorthinfo));get the current x and y coords of alignment point
(setq nudgenorthxcoor (nth 1 nudgenorthxy));gets the current x coordinate for the text
(setq nudgenorthycoorold (nth 2 nudgenorthxy));gets the current y coordinate for the text
(setq nudgenorthycoor (+ nudgefactor nudgenorthycoorold));calculates new x coordinate for the text
(setq nudgenorthxynew (list 10 nudgenorthxcoor nudgenorthycoor 0.0));builds new coordinate list
(entmod (subst nudgenorthxynew nudgenorthxy nudgenorthinfo));replace the current coords with new coords (modified x & y)
);entity data processing (progn)
);each item to be processed (foreach)
(command "UNDO" "END")
(princ)
)