Zitat:
Original erstellt von T_Kaulen:
Hallo,
suche zur einfachen Auswertung von A/V (Fläche zu Volumen) Verhältnissen eine Möglichkeit die Fläche von, mittels Autocad erzeugten, beliebigen 3D Körpern auszuwerten bzw. deren Summe in qm zu erhalten.
Die Masseeigenschaften weisen leider nur das Volumen aus.
Gibts sowas ?
Hallo Thomas,
in AutoCAD pur mW nicht, in MDT müsste es eigentlich gehen. Oder in Rhoino3D :-)
Aber eine Annäherung könnte darin bestehen, die Volmenkörper als STL Datei auszulesen und dann mit meinem alten STLIN wieder einzulesen - dabei werden die Flächen facettiert, und die Summe dieser ebenen Flächenelemente kann ermittelt werden. Unten findest Du die für STLIN benötigten Funktionen, den Rest musst Du selber basteln. Falls das Programm Haken und Ösen hat: ich hab' es vor fast 10 Jahren geschrieben und mindestens schon 5 Jahre nicht mehr angesehen :-)
Gruß
Tom Berger
;;; STLIN.LSP / 04JUL95
;;;
;;; Copyright (C) 1995 by Thomas Berger
;;;
;;; FREEWARE:
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and
;;; that both that copyright notice and the limited warranty and
;;; restricted rights notice below appear in all supporting
;;; documentation.
;;;
;;; THOMAS BERGER PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;;; THOMAS BERGER SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
;;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. THOMAS BERGER
;;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;;; UNINTERRUPTED OR ERROR FREE.
;;;
;;;
;;; ****************************************************************
;;; STLIN: use STLIN to read in STL files (ASCII) and create 3D-FACEs
;;; Useful to create surfaces from ACIS solids
;;;
;;; Use the C:STLIN function at the AutoCAD command prompt
;;; or the (STLIN stlfile insertionpoint) syntax as the API function.
;;; The (create_sub_stlin) can be used for objectiveCAD
;;;
;;; Accuracy depends on FACETRES settings before you use STLOUT
;;; ****************************************************************
(defun oc_newset (en / nset)
(setq nset (ssadd))
(if en
(while (setq en (entnext en))
(if (member (cdr (assoc 0 (entget en))) '("VERTEX" "SEQEND" "ATTRIB"))
nil
(setq nset (ssadd en nset))
)
)
(setq nset (ssget "X"))
)
nset
)
(defun mapent (function ss / i)
(repeat (setq i (sslength ss))
((lambda (proc args / ss function i)
(apply proc args)
)
function
(list (ssname ss (setq i (1- i))))
)
)
)
(defun replacestring (txt sea rep / tle sle part front 1st ret)
(setq tle (strlen txt)
sle (strlen sea)
part ""
)
(while (< 0 tle)
(cond
((< tle sle)
(setq part (strcat part txt)
txt ""
tle 0
)
)
(T
(setq 1st (substr txt 1 1)
front (substr txt 1 sle)
)
(if (= front sea)
(progn
(setq ret (cons rep (cons part ret))
txt (substr txt (1+ sle))
tle (strlen txt)
part ""
)
)
(setq part (strcat part 1st)
txt (substr txt 2)
tle (strlen txt)
)
)
)
)
)
(apply 'strcat (reverse (cons part ret)))
)
(defun makeblock (sset baspoint name / i e en blocktype)
(if sset
nil
(setq sset (ssadd))
)
(if (or (/= 'STR (type name)) (= "" name))
(setq name "*A")
)
(if (= (substr name 1 1) "*")
(setq blocktype 1
name "*A"
)
(setq blocktype 0)
)
(entmake (append
'((0 . "BLOCK"))
(list (cons 2 name))
(list (cons 70 blocktype))
(list (cons 10 baspoint))
)
)
(setq i -1)
(while (setq e (ssname sset (setq i (1+ i))))
(cond
((/= 1 (cdr (assoc 66 (entget e))))
(if (entget e)
(progn
(entmake (entget e '("*")))
(entdel e)
)
)
)
((= 1 (cdr (assoc 66 (entget e))))
(if (entget e)
(progn
(entmake (entget e '("*")))
(setq en e)
(while (/= "SEQEND" (cdr (assoc 0 (entget en))))
(setq en (entnext en))
(entmake (entget en '("*")))
)
(entdel e)
)
)
)
)
)
(setq name (entmake '((0 . "ENDBLK"))))
(if name
(progn
(entmake (append
'((0 . "INSERT"))
(list (cons 2 name))
(list (cons 10 baspoint))
)
)
)
)
(if name
(entlast)
nil
)
)
(defun stlin (ofile pt / line plist)
(setq ofile (open ofile "r"))
(setq pt (if pt
(trans pt 1 0)
'(0 0 0)
)
)
(cond
(ofile
(while (setq line (read-line ofile))
(if (wcmatch line "*outer loop*")
(progn
(while (not (wcmatch line "*endloop*"))
(setq line (read-line ofile))
(if (wcmatch line "*vertex*")
(setq plist (cons (read (strcat (replacestring line "vertex" "(") ")")) plist))
)
)
(if plist
(progn
(command "._3dface")
(mapcar '(lambda (x) (command (trans (cal "pt+x") 0 1))) (reverse plist))
(command "" "")
)
)
(setq plist nil)
)
)
)
(close ofile)
)
(T
(princ "\ncan´t open STL file - must be a ASCII file!")
)
)
)
(defun c:stlin (/ ofile olderr)
(setvar "cmdecho" 0)
(if (not cal)
(arxload "geomcal")
)
(setq olderr *error*)
(defun *error* (msg)
(command "._undo" "_end")
(command "._u")
(princ (strcat "\nSTLIN Error: " msg))
(setq *error* olderr)
(princ)
)
(command "._undo" "_group")
(if (setq ofile (getfiled "STLIN - STL ASCII Datei wählen" "" "stl" 0))
(progn
(initget)
(stlin ofile (getpoint "\ninsertion point <0,0,0>: "))
)
)
(command "._undo" "_end")
(setq *error* olderr)
(princ)
)
(defun BFILL_in (ofile pt / line plist on)
(if (not pt)
(setq pt '(0 0 0))
)
(setq on (entlast))
(setq ofile (open ofile "r"))
(cond
(ofile
(while (setq line (read-line ofile))
(if (and (wcmatch line "*facet normal*")
(equal '(0.0 0.0 -1.0) (read (strcat "(" (substr line 17) ")")) 0.001)
;;; eventuell ins BKS transformieren
)
(progn
(while (not (wcmatch line "*outer loop*")) (setq line (read-line ofile)))
(if (wcmatch line "*outer loop*")
(progn
(while (not (wcmatch line "*endloop*"))
(setq line (read-line ofile))
(if (wcmatch line "*vertex*")
(setq plist (cons (read (strcat (replacestring line "vertex" "(") ")")) plist))
)
)
(if plist
(progn
(command "._solid")
(mapcar '(lambda (x) (command (trans (cal "pt+x") 0 1))) (reverse plist))
(command "" "")
)
)
(setq plist nil)
)
)
)
)
)
(close ofile)
)
(T
(princ "\ncan´t open STL file - must be a ASCII file!")
)
)
(oc_newset on)
)
(defun BFILL_out (en stlfile /)
(entmake (entget en))
(command "._extrude" "_l" "" 0.1 0.0)
(command "._stlout" "_l" "" "_n" stlfile)
(entdel (entlast))
)
(defun c:BFILL (/ sset on pt stlfile)
(setvar "cmdecho" 0)
(command "._undo" "_group")
(if (not cal)
(arxload "geomcal")
)
(setq stlfile "/temp.stl")
(setq pt (getpoint "\ninternen Punkt: "))
(setq on (entlast))
(command "._-boundary" "_a" "_i" "_y" "_o" "_r" "" pt "")
(setq sset (oc_newset on))
(print (sslength sset))
(setq on (img_subtract (oc_newset on)))
(if on
(if (= "REGION" (cdr (assoc 0 (entget on))))
(progn
(BFILL_out on stlfile)
(setq on (entlast))
(setq nset (BFILL_in stlfile '(0 0 0)))
(makeblock (oc_newset on) '(0 0 0) nil)
)
)
)
(command "._undo" "_end")
(prin1)
)
(defun img_subtract (sset / on)
(setq on (entlast))
(cond
((/= 'PICKSET (type sset))
nil
)
((= 0 (sslength sset))
nil
)
((= 1 (sslength sset))
(ssname sset 0)
)
((= 'PICKSET (type sset))
(if (or (= "REGION" (cdr (assoc 0 (entget (ssname sset 0)))))
(= "SOLID" (cdr (assoc 0 (entget (ssname sset 0)))))
)
(progn
(command "._subtract" (ssname sset 0) "" sset "")
(if (equal (entlast) on)
(entlast)
(ssname sset 0)
)
)
)
)
)
)
(princ "\nSTLIN - read in STL files as 3D-FACE triangles")
(princ "\n AutoCAD ACIS Solids can be stored as ASCII files via STLOUT,")
(princ "\n but there is no STLIN command in AutoCAD to read this files in again.\n")
(princ "\n Type STLIN at the AutoCAD command prompt, or use the")
(princ "\n AutoLISP equivalent (STLIN stlfile insertionpoint).")
(princ "\n You can use STLIN as a basic object for objectiveCAD (TM).")
(princ "\n The basic object function CREATE_SUB_STLIN is included.")
(princ "\n\nBFILL - fills a closed area with SOLID entities. The area will")
(princ "\n be triangulated. The solids that fill an area will be grouped")
(princ "\n into an anonymous block.")
(princ "\n FREEWARE by Tom Berger")
(princ "\n Pfannkuchstr. 17")
(princ "\n D-34121 Kassel / Germany")
(princ "\n tberger@architektur.com")
------------------
Architekturwerkzeuge für AutoCAD: http://www.archtools.de