Costinbos77 发表于 2022-7-5 23:30:10

关于多面网格特性

你好
 
如果创建对象“PolyFaceMesh”,则需要:
-顶点列表
-人脸列表
 

(setq myTinV (vla-AddPolyFaceMesh MSpace vertexList FaceList))
您可以使用以下工具检索顶点列表(坐标):
如何检索FaceList列表,恢复三角形?
 

(setqFaceList (vla-Get-XXXXXXXX myTinV) )


; AutoCAD 2013

(vlax-dump-object myTinV T)
; IAcadPolyfaceMesh: IAcadPolyfaceMesh Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000007f73afe2308>
;   Coordinate = ...Indexed contents not shown...
;   Coordinates = (500708.0 366925.0 236.775 500731.0 366912.0 236.635 ... )
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000002bf45168>
;   EntityTransparency = "ByLayer"
;   Handle (RO) = "2FF"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0000000028d5add8>
;   Layer = "Model_3d"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   NumberOfFaces (RO) = 196
;   NumberOfVertices (RO) = 114
;   ObjectID (RO) = 42
;   ObjectID32 (RO) = 42
;   ObjectName (RO) = "AcDbPolyFaceMesh"
;   OwnerID (RO) = 44
;   OwnerID32 (RO) = 44
;   PlotStyleName = "ByLayer"
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0000000028d59db0>
;   Visible = -1
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()
T
_$

 
“PolyFaceMesh”三角网、DTM、三角剖分示例:
 
 
提前感谢,
Costin
明显交点。图纸

Costinbos77 发表于 2022-7-5 23:39:12

你好。没有人碰到这个问题?

David Bethel 发表于 2022-7-5 23:50:34

这应该有效:
 

(defun c:pf-faces (/ ss en ed vn vd); vl fl cl
(and (setq ss (ssget '((0 . "POLYLINE")(-4 . "&")
                                          (70 . 64))))
      (= (sslength ss) 1)
      (setq en (ssname ss 0)
            ed (entget en)
            vl nil
            fl nil
            cl nil
            vn (entnext en)
            vd (entget vn))
      (while (= "VERTEX" (cdr (assoc 0 vd)))
             (if (and (= (logand (cdr (assoc 70 vd))64) 64)
                      (= (logand (cdr (assoc 70 vd)) 128) 128))
               (setq vl (cons (cdr (assoc 10 vd)) vl))
               (setq fl (cons (list (cdr (assoc 71 vd))
                                    (cdr (assoc 72 vd))
                                    (cdr (assoc 73 vd))
                                    (cdr (assoc 74 vd))) fl)))
             (setq vn (entnext vn)
                   vd (entget vn))))

(setq vl (reverse vl))
(foreach f fl
(setq cl (cons (list (nth (1- (abs (nth 0 f))) vl)
                     (nth (1- (abs (nth 1 f))) vl)
                     (nth (1- (abs (nth 2 f))) vl)
                     (nth (1- (abs (nth 3 f))) vl)) cl)))
(prin1))


 
 
vl顶点列表
fl面列表
cl WCS每个面的对应关系
 
它们在发布的代码中是全局的。您需要将它们本地化-大卫

cwake 发表于 2022-7-5 23:56:12

我走上了与大卫相似的道路。我还没有完全算出组码74,但我假设这是第四个面点?因为张贴的图纸有地形三角形,没有第四个点,我忽略了这一点。
但它似乎确实是提取人脸点的方法。在我的作品中,我在三角形上创建了多段线来展示这一点。

(defun c:test ( / elist ent faces vrtcs )
(while
   (progn
   (setvar "ERRNO" 0)
   (setq ent (entsel "\nSelect Polyface Mesh: "))
   (cond
       ((= 7 (getvar "ERRNO"))
      (princ "\nMissed, Try again.")
      )
       ((and (vl-consp ent)
             (or (/= (cdr (assoc 0 (setq elist (entget (car ent))))) "POLYLINE")
               (not (member '(100 . "AcDbPolyFaceMesh") elist))
               )
             )
      (princ "\nInvalid Object Selected.")
      )
       )
   )
   )
(if elist
   (progn
   (while (= (cdr (assoc 0 (setq elist (entget (entnext (cdar elist)))))) "VERTEX")
       (cond
         ((member '(100 . "AcDbVertex") elist)
          (setq vrtcs (cons (cdr (assoc 10 elist)) vrtcs))
          )
         ((member '(100 . "AcDbFaceRecord") elist)
          (setq faces (cons (list (cdr (assoc 71 elist)) (cdr (assoc 72 elist)) (cdr (assoc 73 elist))) faces))
          )
         )
       )
   (setq vrtcs (reverse vrtcs))
   (mapcar
       (function
         (lambda ( a )
         (entmakex
             (append '((0 . "LWPOLYLINE")
                     (100 . "AcDbEntity")
                     (100 . "AcDbPolyline")
                     (90 . 3)
                     (70 . 1)
                     )
                     (mapcar
                     (function
                         (lambda ( b )
                           (cons 10 (nth (1- b) vrtcs))
                           )
                         )
                     a
                     )
                     )
             )
         )
         )
       faces
       )
   )
   )
(princ)
)

David Bethel 发表于 2022-7-6 00:01:33

 
 
你在74组是对的。
 
就几个笨蛋
[列表]
[*]负的面点号表示面边缘不可见,因此(abs)调用以使用(n)个列表原子
[*]长波多段线是二维实体。需要3D多边形来表示边,或为3个点面指定OCS
[/列表]
 
 
-大卫

cwake 发表于 2022-7-6 00:08:35

 
谢谢David,我还没有解决这个问题(主要是逆向工程)。有了这些额外的知识和对组码74的确认,我必须重写我的:
 
6
 
我把你的观点放在LWPOLYLINE和3DPOLY上;我知道这一点。我的目的更多的是证明顶点已正确匹配到面。我不确定OP在提取人脸后希望实现什么?因此,我保留了修订版中的内容。

Costinbos77 发表于 2022-7-6 00:21:24

大家好!
 
谢谢你的回复。奇怪的是,虽然您可以使用Visual Lisp看到对象的某些属性,但您无法更改它。
 
我的目的是获取“PolyFaceMesh”对象的三角形,而不是分解它并收集结果。

David Bethel 发表于 2022-7-6 00:24:27

虽然有一些(很少)事情只能用VisualLisp来做,但普通autolisp仍然是一个非常(更)强大(更友好)(我的0.02美元)-David
 
如果您添加DosLIB(VL基本上偷了它(oops借用了它)),它同样对文件友好。

Costinbos77 发表于 2022-7-6 00:33:14

好的,大卫。根据你发布的内容,我可以修复我想要的(CL=坐标列表)。
页: [1]
查看完整版本: 关于多面网格特性