(defun c:Hatch2MPolygon (/ vla-Hatch n loop  LoopList hatchename aws)
  (if (and
	(princ "\nAssoziative Schraffuren auswählen: ")
	(ssget '((0 . "HATCH")))
	)
    (progn
      (vlax-for	vla-Hatch
			  (vla-get-activeselectionset
			    (vla-get-activedocument
			      (vlax-get-acad-object)
			      )
			    )
	(setq n -1)
	(setq LoopList nil)
	(repeat	(vla-get-NumberOfLoops vla-Hatch)
	  (setq n (+ n 1))
	  (vla-getloopat vla-Hatch n 'loop)

	  (if (eq (type loop) 'safearray)
	    (setq LoopList (append LoopList
				   (mapcar 'vlax-vla-object->ename
					   (vlax-safearray->list loop)
					   )
				   )
		  )
	    );endif
	  )

	(setq hatchename (vlax-vla-object->ename vla-Hatch))

        ;; Layer für die Schraffur
        (setq ed1 (entget hatchename))
        (setq layer (cdr (assoc 8 ed1))); Layername
	(setvar "CLAYER" layer); Layer für das MPolygon setzen
	  	
        ;; Auswahlsatz für die Border
        (setq aws(ssadd));init
	(setq i 0);index
        (while(setq ent(nth i LoopList))
          (ssadd ent aws)
          (setq i(1+ i))
        );end-while

        ;; erstellen des MPOLYGON
        (command "_mpolygon" "A" aws "" "B" )

        ;; Löschen der Border
       (COMMAND "_ERASE" aws "")
	
	;; Löschen der Schraffur
       (COMMAND "_ERASE" hatchename "")
	
	)
      );end-progn
    );endif
  ;;RetList
(princ)
  );end-defun

;|«Visual LISP© Format Options»
(72 2 40 1 nil "end of " 60 9 0 0 0 T T nil T)
;*** KEINEN Text unterhalb des Kommentars hinzufügen! ***|;