只需如下代码
(defun c:j(/ ENT DATA) (setq ent (entsel "Select a object to join:\n")) (setq data (entget (car ent))) (setq name (cdr (assoc 0 data))) (if (= name "LWPOLYLINE") (command "pedit" ent "j" "all" "" "") (command "pedit" ent "y" "j" "all" "" "") ) )