This is alittle strange. I have the following code that works on most setups. I have another setup that when I run the code it says the following:
Command: X2ML
Select Objects: 1 found
Select Objects: 1 found, 2 total
Select Objects: 1 found, 3 total
Select Objects: 1 found, 4 total
Select Objects Unknown command "X2ML". Press F1 for Help.
; error; Automation Error. Description was not provided.
Command:
Here is the code trying to get to work:
(defun c:X2ML (/ _dxf lp lp2 lpe ml ss txt x)
(defun _dxf (code ename)
(if ename
(cdr (assoc code (entget ename)))
)
) -->
(cond ((null (and (setq ss (ssget ":L" (list '(0 . "text,line,solid"))))
(setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
)
)
(print "Bye...")
)
((not (setq
lp (_dxf 12 (setq lpe (car (vl-remove-if-not '(lambda (x) (= "SOLID" (_dxf 0 x))) ss))))
)
)
(print "Leader point not found...")
)
((not (setq lp2
(car (vl-sort (apply 'append
(mapcar '(lambda (x) (list (_dxf 10 x) (_dxf 11 x)))
(vl-remove-if-not '(lambda (x) (= "LINE" (_dxf 0 x))) ss)
)
)
'(lambda (a b) (> (distance a lp) (distance b lp)))
)
)
)
)
(print "Lines not selected...")
)
((not (setq txt (vl-sort (vl-remove-if-not '(lambda (x) (= "TEXT" (_dxf 0 x))) ss)
'(lambda (a b) (> (cadr (_dxf 10 a)) (cadr (_dxf 10 b))))
)
)
)
(print "Text not selected...")
)
(t
(command "._mleader" lp lp2 "")
(setq ml (vlax-ename->vla-object (entlast)))
(vla-put-textstring
ml
(vl-string-right-trim
"\\P"
(apply 'strcat (mapcar '(lambda (x) (strcat (_dxf 1 x) "\\P")) txt))
)
)
(vla-put-layer ml (_dxf 8 (car txt)))
(vla-put-textstylename ml (_dxf 7 (car txt)))
(vla-put-textheight ml (_dxf 40 (car txt)))
(vla-put-arrowheadsize ml (distance lp (_dxf 10 lpe)))
(mapcar 'entdel ss)
)
)
(princ)
)
Thanks for the help guys