With a little patience, I analyzed the code better and rewritten based on my habits:
(defun RiassociaQuote (selez / n ent1 d pt)
(setvar "OSMODE" 0)
(setq n 0)
(setq ent1 (ssname selez n)) ;nome della prima entità della selezione
(while (/= ent1 nil)
(progn
(if (= (vall 0 ent1) "DIMENSION")
(progn
(setq d (entget ent1))
(setq pt (trans (mapcar '(lambda (a b) (/ (+ a b) 2.0)) (cdr (assoc 13 d))(cdr (assoc 14 d))) 0 1))
(if (and
(or
(eq (cdr (assoc 100 (reverse d))) "AcDbAlignedDimension")
(eq (cdr (assoc 100 (reverse d))) "AcDbRotatedDimension")
)
(nentselp pt)
)
(progn
(command "_.dimreassociate" ent1 "" "_S" "_non" pt)
(while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command ""))
)
)
)
)
;--
(setq n (+ n 1))
(setq ent1 (ssname selez n)) ;nome dell'oggetto successivo
)
)
)
But not always work correctly.
The problem is the following line:
(command "_.dimreassociate" ent1 "" "_S" "_non" pt)
In practice, even if the snap is turned off with "_non", the selection of the object through a point (pt), is very influenced by the value of the zoom.
So when in the vicinity of pt there are other nearby objects, is not always selected the correct object.
PS. I assure you that pt passes on a single object, but often are selected nearby objects.
Do you have any idea on how to get around this problem.
I have finished my resources and then ask for help to you.
Thanks in advance.