Schreibt automatisch die Flächen- und Umfangsmaße von Objekten.
Automatische Flächen- und Umfangsberechnung mit Beschriftung
admin - 23.05.2026 08:12
admin - 23.05.2026 08:12
Automatische Flächen- und Umfangsberechnung mit Beschriftung

pLaC: PoLyLine Fläche & Umfang
Berechnet die Fläche und den Umfang der ausgewählten LwPolyline-Objekte und fügt die Werte als Feldtext (Field) im geometrischen Mittelpunkt jedes Objekts ein.
Für die Texthöhe wird die aktuelle Variable TextSize verwendet. Die Anzahl der angezeigten Nachkommastellen wird aus der Variable Luprec übernommen.

pLaC: PoLyLine Fläche & Umfang
Berechnet die Fläche und den Umfang der ausgewählten LwPolyline-Objekte und fügt die Werte als Feldtext (Field) im geometrischen Mittelpunkt jedes Objekts ein.
Für die Texthöhe wird die aktuelle Variable TextSize verwendet. Die Anzahl der angezeigten Nachkommastellen wird aus der Variable Luprec übernommen.
Code:
;|===========================================================================|;
;| pLaC: PoLyLine Fläche & Umfang |;
;| Fläche und Umfang der ausgewählten LwPolyline-Objekte werden als |;
;| Feldtext (Field) im geometrischen Mittelpunkt eingefügt. Als Texthöhe |;
;| wird TextSize verwendet, die Anzahl der Nachkommastellen wird aus der |;
;| Variablen Luprec übernommen. |;
;| Erstellt von: M. Şahin Güvercin - www.autocadokulu.com |;
;|---------------------------------------------------------------------------|;
(defun c:pLaC (/ *error* pLns Fob n PvT vLo oID x y z PnT m TxH pR pA pC)
(setvar "cmdecho" 0) (command "_.undo" "group") (vl-load-com)
(defun *error* (/ er) (princ (strcat "n" er)) (command "_.undo" "e")(prin1))
(if (not oFc) (setq oFc 1))
(setq FaC (getreal (strcat "nZeichnungseinheit/Berechnungseinheit <"(rtos oFc)">: ")))
(if (not FaC) (setq Fac oFc) (setq oFc FaC))
(princ "nWählen Sie die LwPolyline-Objekte aus, deren Fläche und Umfang beschriftet werden sollen: ")
(setq pLns (ssget (list (cons 0 "LwPoLyLine")))
Fob (ssadd) n (sslength pLns))
(while (not (minusp (setq n (1- n))))
(setq PvT (ssname pLns n) vLo (vlax-ename->vla-object PvT)
oID (itoa (vla-get-ObjectID vLo)) x 0 y 0 z (getvar "elevation")
PnT (vlax-safearray->list (vlax-variant-value
(vlax-get-property vLo 'Coordinates))) m (length PnT))
(while (not (minusp (setq m (- m 2))))
(setq x (+ x (nth m PnT)) y (+ y (nth (1+ m) PnT))))
(setq x (/ x (/ (length PnT) 2)) y (/ y (/ (length PnT) 2))
TxH (getvar "TextSize") pR (getvar "Luprec")
pA (polar (list x y z) (/ pi 2.0) (* 0.833333 TxH))
pC (polar (list x y z) (* pi 1.5) (* 0.833333 TxH)))
(entmake (list (cons 0 "Text") (cons 10 pA) (cons 40 TxH)
(cons 1 (strcat "%<AcObjProp Object(%<_ObjId " oID
">%).Area f "%lu2%pr" (itoa pR)
"%ps[A=,]%ct8["(rtos(* FaC FaC)2 8)"]">%"))
(cons 50 0.0) (cons 72 1) (cons 11 pA))) (ssadd (entlast) Fob)
(entmake (list (cons 0 "Text") (cons 10 pC) (cons 40 TxH)
(cons 1 (strcat "%<AcObjProp.16.2 Object(%<_ObjId " oID
">%).Length f "%lu2%pr" (itoa pR)
"%ps[C=,]%ct8[" (rtos FaC 2 8) "]">%"))
(cons 50 0.0) (cons 72 1) (cons 11 pC))) (ssadd (entlast) Fob))
(command "_.UpdateFieLd" Fob "") (command "_.undo" "e") (prin1))
;| pLaC: PoLyLine Fläche & Umfang |;
;| Fläche und Umfang der ausgewählten LwPolyline-Objekte werden als |;
;| Feldtext (Field) im geometrischen Mittelpunkt eingefügt. Als Texthöhe |;
;| wird TextSize verwendet, die Anzahl der Nachkommastellen wird aus der |;
;| Variablen Luprec übernommen. |;
;| Erstellt von: M. Şahin Güvercin - www.autocadokulu.com |;
;|---------------------------------------------------------------------------|;
(defun c:pLaC (/ *error* pLns Fob n PvT vLo oID x y z PnT m TxH pR pA pC)
(setvar "cmdecho" 0) (command "_.undo" "group") (vl-load-com)
(defun *error* (/ er) (princ (strcat "n" er)) (command "_.undo" "e")(prin1))
(if (not oFc) (setq oFc 1))
(setq FaC (getreal (strcat "nZeichnungseinheit/Berechnungseinheit <"(rtos oFc)">: ")))
(if (not FaC) (setq Fac oFc) (setq oFc FaC))
(princ "nWählen Sie die LwPolyline-Objekte aus, deren Fläche und Umfang beschriftet werden sollen: ")
(setq pLns (ssget (list (cons 0 "LwPoLyLine")))
Fob (ssadd) n (sslength pLns))
(while (not (minusp (setq n (1- n))))
(setq PvT (ssname pLns n) vLo (vlax-ename->vla-object PvT)
oID (itoa (vla-get-ObjectID vLo)) x 0 y 0 z (getvar "elevation")
PnT (vlax-safearray->list (vlax-variant-value
(vlax-get-property vLo 'Coordinates))) m (length PnT))
(while (not (minusp (setq m (- m 2))))
(setq x (+ x (nth m PnT)) y (+ y (nth (1+ m) PnT))))
(setq x (/ x (/ (length PnT) 2)) y (/ y (/ (length PnT) 2))
TxH (getvar "TextSize") pR (getvar "Luprec")
pA (polar (list x y z) (/ pi 2.0) (* 0.833333 TxH))
pC (polar (list x y z) (* pi 1.5) (* 0.833333 TxH)))
(entmake (list (cons 0 "Text") (cons 10 pA) (cons 40 TxH)
(cons 1 (strcat "%<AcObjProp Object(%<_ObjId " oID
">%).Area f "%lu2%pr" (itoa pR)
"%ps[A=,]%ct8["(rtos(* FaC FaC)2 8)"]">%"))
(cons 50 0.0) (cons 72 1) (cons 11 pA))) (ssadd (entlast) Fob)
(entmake (list (cons 0 "Text") (cons 10 pC) (cons 40 TxH)
(cons 1 (strcat "%<AcObjProp.16.2 Object(%<_ObjId " oID
">%).Length f "%lu2%pr" (itoa pR)
"%ps[C=,]%ct8[" (rtos FaC 2 8) "]">%"))
(cons 50 0.0) (cons 72 1) (cons 11 pC))) (ssadd (entlast) Fob))
(command "_.UpdateFieLd" Fob "") (command "_.undo" "e") (prin1))
Autor: cizimokulu.com
Beschreibung: AutoLISP-Funktion zur automatischen Flächen- und Umfangsberechnung mit Beschriftung
Etikett: Automatische Flächen- und Umfangsberechnung mit Beschriftung
Kommentare :
Noch kein Kommentar vorhanden





Kategorienindex
