明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1918|回复: 2

[源码] [求助]怎么用entmake生成一个填充?

[复制链接]
发表于 2009-10-11 21:59 | 显示全部楼层 |阅读模式

如题...

怎么用entmake生成一个填充(已知各个顶点)

发表于 2022-2-22 17:30 | 显示全部楼层
本帖最后由 hpy 于 2022-2-22 17:35 编辑

下面这段代码从网上找到的,修改了一下。程序优点:创建填充图案时可以不用把线画出来,只需给定点表即可。缺点:只对由直线构成的多边形有用,对直线与曲线构成的区域和曲线构成的区域没用。
  1. ;;功能:对单个或多个区域创建hatch填充
  2. ;;参数说明:lst 点表组成的点表
  3. ;;         hatchname  hatch图案名称  
  4. ;;         Layname    图层名称
  5. ;;         hatchangle 填充角度(弧度)      
  6. ;;         pmxsca     填充比例      
  7. ;;(entmakehatch (list (list pt1 pt2 pt3 ...) (list pt11 pt12 pt13 ...)) "hatch图案名称" "图层" 填充角度(弧度) 填充比例)

  8. (defun entmakehatch (Lst hatchname Layname hatchangle pmxsca)
  9.    (entmakex
  10.       (apply
  11.          'append
  12.              (list
  13.                (list '(0 . "HATCH")
  14.                      '(100 . "AcDbEntity")
  15.                      '(410 . "Model")
  16.                       (cons 8 Layname)
  17.                      '(100 . "AcDbHatch")
  18.                      '(10 0.0 0.0 0.0)
  19.                      '(210 0.0 0.0 1.0)
  20.                   ;; '(2 . "ANSI31")
  21.                       (cons 2 hatchname)
  22.                       (cons 62 256)  ;;颜色随层
  23.                  ;;(if (= n "SOLID")
  24.                  ;;  '(70 . 1)
  25.                      '(70 . 0)
  26.                 ;; ) ;_  if
  27.                     '(71 . 0)
  28.                      (cons 91 (length Lst))
  29.                ) ;_  list
  30.                (apply 'append
  31.                     (mapcar '(lambda (a)
  32.                                 (apply 'append
  33.                                     (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a)))
  34.                                           (mapcar '(lambda (b) (cons 10 b)) a)
  35.                                          '((97 . 0))
  36.                                     ) ;_  list
  37.                                 ) ;_  apply
  38.                              ) ;_  lambda
  39.                       Lst
  40.                     ) ;_  mapcar
  41.                ) ;_  apply
  42.                (list '(75 . 0)
  43.                      '(76 . 1)
  44.                       (cons 52 hatchangle)
  45.                       (cons 41 pmxsca)
  46.                      '(77 . 0)
  47.                      '(78 . 1)
  48.                       (cons 53 hatchangle)
  49.                      '(43 . 0)
  50.                      '(44 . 0)
  51.                      '(45 . 1)
  52.                   ;;  (cons 45 s)
  53.                      '(46 . 1)
  54.                      '(79 . 0)
  55.                      '(47 . 1)
  56.                      '(98 . 2)
  57.                      '(10 0. 0. 0.0)
  58.                      '(10 0. 0. 0.0)
  59.                  ;;  '(451 . 0)
  60.                  ;;  '(460 . 0.0)
  61.                  ;;  '(461 . 0.0)
  62.                  ;;  '(452 . 1)
  63.                  ;;  '(462 . 1.0)
  64.                  ;;  '(453 . 2)
  65.                  ;;  '(463 . 0.0)
  66.                  ;;  '(463 . 1.0)
  67.                  ;;  '(470 . "LINEAR")
  68.                ) ;_  list
  69.              ) ;_  list
  70.        ) ;_  apply
  71.    ) ;_  entmakex
  72. ) ;_  defun


回复 支持 2 反对 0

使用道具 举报

发表于 2022-2-21 21:58 | 显示全部楼层
这个问题也没有解决。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-2 10:29 , Processed in 0.143864 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表