找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1897|回复: 6

[求助] 2008填充边界重建椭圆线跑偏了

[复制链接]

已领礼包: 264个

财富等级: 日进斗金

发表于 2014-9-21 02:55:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
用hatchedit命令结果如图,只有椭圆线不对,有什么程序可以解决这个问题
20140921025512.jpg
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 859个

财富等级: 财运亨通

发表于 2014-9-21 09:23:36 来自手机 | 显示全部楼层
2015测试没有这个情况,不过Ellipse的Normal反向了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 344个

财富等级: 日进斗金

发表于 2014-9-21 10:14:01 | 显示全部楼层
算是CAD2008的Bug吧,只能自己写个程序重建边界了!网上搜一下,有这样的代码,最著名的就是那个hatchb.lsp了!

点评

找到了!  详情 回复 发表于 2014-9-21 10:31
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 264个

财富等级: 日进斗金

 楼主| 发表于 2014-9-21 10:31:39 | 显示全部楼层
牢固 发表于 2014-9-21 10:14
算是CAD2008的Bug吧,只能自己写个程序重建边界了!网上搜一下,有这样的代码,最著名的就是那个hatchb.lsp ...


找到了!
  1. ;;; HATCHB.LSP ver 2.0
  2. ;;; Recreates hatch boundary by selecting a hatch
  3. ;;; Boundary is created in current layer/color/linetype in WCS
  4. ;;; By Jimmy Bergmark
  5. ;;; Copyright (C) 1997-2003 JTB World, All Rights Reserved
  6. ;;; Website: www.jtbworld.com
  7. ;;; E-mail: info@jtbworld.com
  8. ;;; 2000-02-12 - First release
  9. ;;; 2000-03-27 - Counterclockwise arc's and ellipse's fixed
  10. ;;;              Objects created joined to lwpolyline if possible
  11. ;;;              Error-handling, undo of command
  12. ;;;              Can handle PLINETYPE = 0,1,2
  13. ;;; 2000-03-30 - Integrating hatchb and hatchb14
  14. ;;;              Selection of many hatches
  15. ;;;              Splines supported if closed.
  16. ;;; 2001-04-02 - Fixed bug with entmake of line with no Z for r14
  17. ;;; 2001-07-31 - Removed an irritating semicolon to enable polylines to be created.
  18. ;;; 2001-10-04 - Changed mail and homepage so it's easy to find when new versions comes up.
  19. ;;; 2003-02-06 - Minor fix
  20. ;;; 2003-02-17 - Area returned if no islands is found since it's not consistant
  21. ;;; 2003-05-19 - Fix to take PEDITACCEPT variable used in AutoCAD 2004 into account
  22. ;;; Tested on AutoCAD r14, 2000, 2000i, 2002, 2004
  23. ;;; should be working on older versions too.
  24. (defun c:hb () (c:hatchb))                ; this line can be commented out if there is an existing command called hb
  25. (defun c:hatchb        (/           es             blay      ed1         ed2
  26.                  loops1           bptf             part      et         noe
  27.                  plist           ic             bul       nr         ang1
  28.                  ang2           obj             *ModelSpace*         *PaperSpace*
  29.                  space           cw             errexit   undox         olderr
  30.                  oldcmdecho             ss1       lastent         en1
  31.                  en2           ss             lwp       list->variantArray
  32.                  3dPoint->2dPoint    A2k       ent         i
  33.                  ss2           knot-list controlpoint-list         kn
  34.                  cn           pos             xv               bot         area
  35.                  hst
  36.                 )
  37.   (setq A2k (>= (substr (getvar "ACADVER") 1 2) "15"))
  38.   (if A2k
  39.     (progn
  40.       (defun list->variantArray        (ptsList / arraySpace sArray)
  41.         (setq arraySpace
  42.                (vlax-make-safearray
  43.                  vlax-vbdouble
  44.                  (cons 0 (- (length ptsList) 1))
  45.                )
  46.         )
  47.         (setq sArray (vlax-safearray-fill arraySpace ptsList))
  48.         (vlax-make-variant sArray)
  49.       )
  50.       (defun areaOfObject (en / curve area)
  51.         (if en
  52.           (if A2k
  53.             (progn
  54.               (setq curve (vlax-ename->vla-object en))
  55.               (if
  56.                 (vl-catch-all-error-p
  57.                   (setq
  58.                     area
  59.                      (vl-catch-all-apply 'vlax-curve-getArea (list curve))
  60.                   )
  61.                 )
  62.                  nil
  63.                  area
  64.               )
  65.             )
  66.             (progn
  67.               (command "._area" "_O" en)
  68.               (getvar "area")
  69.             )
  70.           )
  71.         )
  72.       )
  73.     )
  74.   )
  75.   (if A2k
  76.     (defun 3dPoint->2dPoint (3dpt)
  77.       (list (float (car 3dpt)) (float (cadr 3dpt)))
  78.     )
  79.   )
  80.   (defun errexit (s)
  81.     (princ "\nError:  ")
  82.     (princ s)
  83.     (restore)
  84.   )
  85.   (defun undox ()
  86.     (command "._ucs" "_p")
  87.     (command "._undo" "_E")
  88.     (setvar "cmdecho" oldcmdecho)
  89.     (setq *error* olderr)
  90.     (princ)
  91.   )
  92.   (setq        olderr        *error*
  93.         restore        undox
  94.         *error*        errexit
  95.   )
  96.   (setq oldcmdecho (getvar "cmdecho"))
  97.   (setvar "cmdecho" 0)
  98.   (command "._UNDO" "_BE")
  99.   (if A2k
  100.     (progn
  101.       (vl-load-com)
  102.       (setq *ModelSpace* (vla-get-ModelSpace
  103.                            (vla-get-ActiveDocument (vlax-get-acad-object))
  104.                          )
  105.             *PaperSpace* (vla-get-PaperSpace
  106.                            (vla-get-ActiveDocument (vlax-get-acad-object))
  107.                          )
  108.       )
  109.     )
  110.   )
  111.   (if (/= (setq ss2 (ssget '((0 . "HATCH")))) nil)
  112.     (progn
  113.       (setq i 0)
  114.       (setq area 0)
  115.       (setq bMoreLoops nil)
  116.       (while (setq ent (ssname ss2 i))
  117.         (setq ed1 (entget ent))
  118.         (if (not (equal (assoc 210 ed1) '(210 0.0 0.0 1.0)))
  119.           (princ "\nHatch not in WCS!")
  120.         )
  121.         (setq xv (cdr (assoc 210 ed1)))
  122.         (command "._ucs" "_w")
  123.         (setq loops1 (cdr (assoc 91 ed1)))
  124.                                         ; number of boundary paths (loops)
  125.         (if (and A2k (= (strcase (cdr (assoc 410 ed1))) "MODEL"))
  126.           (setq space *ModelSpace*)
  127.           (setq space *PaperSpace*)
  128.         )
  129.         (repeat        loops1
  130.           (setq ed1 (member (assoc 92 ed1) ed1))
  131.           (setq bptf (cdr (car ed1)))        ; boundary path type flag
  132.           (setq ic (cdr (assoc 73 ed1))) ; is closed
  133.           (setq noe (cdr (assoc 93 ed1))) ; number of edges
  134.           (setq bot (cdr (assoc 92 ed1))) ; boundary type
  135.           (setq hst (cdr (assoc 75 ed1))) ; hatch style
  136.           (setq ed1 (member (assoc 72 ed1) ed1))
  137.           (setq bul (cdr (car ed1)))        ; bulge
  138.           (setq plist nil)
  139.           (setq blist nil)
  140.           (cond
  141.             ((> (boole 1 bptf 2) 0)        ; polyline
  142.              (repeat noe
  143.                (setq ed1 (member (assoc 10 (cdr ed1)) ed1))
  144.                (setq plist (append plist (list (cdr (assoc 10 ed1)))))
  145.                (setq blist (append blist
  146.                                    (if (> bul 0)
  147.                                      (list (cdr (assoc 42 ed1)))
  148.                                      nil
  149.                                    )
  150.                            )
  151.                )
  152.              )
  153.              (if A2k
  154.                (progn
  155.                  (setq polypoints
  156.                         (apply 'append
  157.                                (mapcar '3dPoint->2dPoint plist)
  158.                         )
  159.                  )
  160.                  (setq VLADataPts (list->variantArray polypoints))
  161.                  (setq
  162.                    obj (vla-addLightweightPolyline space VLADataPts)
  163.                  )
  164.                  (setq nr 0)
  165.                  (repeat (length blist)
  166.                    (if (/= (nth nr blist) 0)
  167.                      (vla-setBulge obj nr (nth nr blist))
  168.                    )
  169.                    (setq nr (1+ nr))
  170.                  )
  171.                  (if (= ic 1)
  172.                    (vla-put-closed obj T)
  173.                  )
  174.                )
  175.                (progn
  176.                  (if (= ic 1)
  177.                    (entmake '((0 . "POLYLINE") (66 . 1) (70 . 1)))
  178.                    (entmake '((0 . "POLYLINE") (66 . 1)))
  179.                  )
  180.                  (setq nr 0)
  181.                  (repeat (length plist)
  182.                    (if (= bul 0)
  183.                      (entmake (list (cons 0 "VERTEX")
  184.                                     (cons 10 (nth nr plist))
  185.                               )
  186.                      )
  187.                      (entmake (list (cons 0 "VERTEX")
  188.                                     (cons 10 (nth nr plist))
  189.                                     (cons 42 (nth nr blist))
  190.                               )
  191.                      )
  192.                    )
  193.                    (setq nr (1+ nr))
  194.                  )
  195.                  (entmake '((0 . "SEQEND")))
  196.                )
  197.              )
  198.             )
  199.             (t                                ; not polyline
  200.              (setq lastent (entlast))
  201.              (setq lwp T)
  202.              (repeat noe
  203.                (setq et (cdr (assoc 72 ed1)))
  204.                (cond
  205.                  ((= et 1)                ; line
  206.                   (setq ed1 (member (assoc 10 (member (assoc 72 ed1) ed1)) ed1))
  207.                   (if A2k
  208.                     (vla-AddLine
  209.                       space
  210.                       (vlax-3d-point (cdr (assoc 10 ed1)))
  211.                       (vlax-3d-point (cdr (assoc 11 ed1)))
  212.                     )
  213.                     (entmake
  214.                       (list
  215.                         (cons 0 "LINE")
  216.                         (list 10
  217.                               (cadr (assoc 10 ed1))
  218.                               (caddr (assoc 10 ed1))
  219.                               0
  220.                         )
  221.                         (list 11
  222.                               (cadr (assoc 11 ed1))
  223.                               (caddr (assoc 11 ed1))
  224.                               0
  225.                         )
  226.                                         ;  (cons 210 xv)
  227.                       )
  228.                     )
  229.                   )
  230.                   (setq ed1 (cddr ed1))
  231.                  )
  232.                  ((= et 2)                ; circular arc
  233.                   (setq ed1 (member (assoc 10 (cdr ed1)) ed1))
  234.                   (setq ang1 (cdr (assoc 50 ed1)))
  235.                   (setq ang2 (cdr (assoc 51 ed1)))
  236.                   (setq cw (cdr (assoc 73 ed1)))
  237.                   (if (equal ang2 6.28319 0.00001)
  238.                     (progn
  239.                       (if A2k
  240.                         (vla-AddCircle
  241.                           space
  242.                           (vlax-3d-point (cdr (assoc 10 ed1)))
  243.                           (cdr (assoc 40 ed1))
  244.                         )
  245.                         (entmake (list (cons 0 "CIRCLE")
  246.                                        (assoc 10 ed1)
  247.                                        (assoc 40 ed1)
  248.                                  )
  249.                         )
  250.                       )
  251.                       (setq lwp nil)
  252.                     )
  253.                     (if        A2k
  254.                       (vla-AddArc
  255.                         space
  256.                         (vlax-3d-point (cdr (assoc 10 ed1)))
  257.                         (cdr (assoc 40 ed1))
  258.                         (if (= cw 0)
  259.                           (- 0 ang2)
  260.                           ang1
  261.                         )
  262.                         (if (= cw 0)
  263.                           (- 0 ang1)
  264.                           ang2
  265.                         )
  266.                       )
  267.                       (entmake (list (cons 0 "ARC")
  268.                                      (assoc 10 ed1)
  269.                                      (assoc 40 ed1)
  270.                                      (cons 50
  271.                                            (if (= cw 0)
  272.                                              (- 0 ang2)
  273.                                              ang1
  274.                                            )
  275.                                      )
  276.                                      (cons 51
  277.                                            (if (= cw 0)
  278.                                              (- 0 ang1)
  279.                                              ang2
  280.                                            )
  281.                                      )
  282.                                )
  283.                       )
  284.                     )
  285.                   )
  286.                   (setq ed1 (cddddr ed1))
  287.                  )
  288.                  ((= et 3)                ; elliptic arc
  289.                   (setq ed1 (member (assoc 10 (cdr ed1)) ed1))
  290.                   (setq ang1 (cdr (assoc 50 ed1)))
  291.                   (setq ang2 (cdr (assoc 51 ed1)))
  292.                   (setq cw (cdr (assoc 73 ed1)))
  293.                   (if A2k
  294.                     (progn
  295.                       (setq obj        (vla-AddEllipse
  296.                                   space
  297.                                   (vlax-3d-point (cdr (assoc 10 ed1)))
  298.                                   (vlax-3d-point (cdr (assoc 11 ed1)))
  299.                                   (cdr (assoc 40 ed1))
  300.                                 )
  301.                       )
  302.                       (vla-put-startangle
  303.                         obj
  304.                         (if (= cw 0)
  305.                           (- 0 ang2)
  306.                           ang1
  307.                         )
  308.                       )
  309.                       (vla-put-endangle
  310.                         obj
  311.                         (if (= cw 0)
  312.                           (- 0 ang1)
  313.                           ang2
  314.                         )
  315.                       )
  316.                     )
  317.                     (princ "\nElliptic arc not supported!")
  318.                   )
  319.                   (setq lwp nil)
  320.                  )
  321.                  ((= et 4)                ; spline
  322.                   (setq ed1 (member (assoc 94 (cdr ed1)) ed1))
  323.                   (setq knot-list nil)
  324.                   (setq controlpoint-list nil)
  325.                   (setq kn (cdr (assoc 95 ed1)))
  326.                   (setq cn (cdr (assoc 96 ed1)))
  327.                   (setq pos (vl-position (assoc 40 ed1) ed1))
  328.                   (repeat kn
  329.                     (setq
  330.                       knot-list        (cons (cons 40 (cdr (nth pos ed1)))
  331.                                       knot-list
  332.                                 )
  333.                     )
  334.                     (setq pos (1+ pos))
  335.                   )
  336.                   (setq pos (vl-position (assoc 10 ed1) ed1))
  337.                   (repeat cn
  338.                     (setq controlpoint-list
  339.                            (cons
  340.                              (cons 10 (cdr (nth pos ed1)))
  341.                              controlpoint-list
  342.                            )
  343.                     )
  344.                     (setq pos (1+ pos))
  345.                   )
  346.                   (setq knot-list (reverse knot-list))
  347.                   (setq controlpoint-list (reverse controlpoint-list))
  348.                   (entmake (append
  349.                              (list '(0 . "SPLINE"))
  350.                              (list (cons 100 "AcDbEntity"))
  351.                              (list (cons 100 "AcDbSpline"))
  352.                              (list (cons 70
  353.                                          (+ 1
  354.                                             8
  355.                                             (* 2 (cdr (assoc 74 ed1)))
  356.                                             (* 4 (cdr (assoc 73 ed1)))
  357.                                          )
  358.                                    )
  359.                              )
  360.                              (list (cons 71 (cdr (assoc 94 ed1))))
  361.                              (list (cons 72 kn))
  362.                              (list (cons 73 cn))
  363.                              knot-list
  364.                              controlpoint-list
  365.                            )
  366.                   )
  367.                   ;(vla-put-closed (vlax-ename->vla-object (entlast)) :vlax-false)
  368.                   (command ".splinedit" (entlast) "o" "")
  369.                   (setq ed1 (member (assoc 10 ed1) ed1))
  370.                   (setq lwp nil)
  371.                  )
  372.                )                        ; end cond
  373.              )                                ; end repeat noe
  374.              (if lwp
  375.                (progn
  376.                  (setq en1 (entnext lastent))
  377.                  (setq ss (ssadd))
  378.                  (ssadd en1 ss)
  379.                  (while        (setq en2 (entnext en1))
  380.                    (ssadd en2 ss)
  381.                    (setq en1 en2)
  382.                  )
  383.                  (if (= (getvar "peditaccept") 1)
  384.                    (command "_.pedit" (entlast) "_J" ss "" "")
  385.                    (command "_.pedit" (entlast) "_Y" "_J" ss "" "")
  386.                  )
  387.                )
  388.              )
  389.             )                                ; end t
  390.           )                                ; end cond
  391.         )                                ; end repeat loops1
  392.         (if (= loops1 1)
  393.           (setq area (+ area (areaOfObject (entlast))))
  394.           (setq bMoreLoops T)
  395.         )
  396.         (setq i (1+ i))
  397.       )
  398.     )
  399.   )
  400.   ;|(if (and area (not bMoreLoops))
  401.     (progn
  402.       (princ "\nTotal Area = ")
  403.       (princ area)
  404.     )
  405.   )|;
  406.   (restore)
  407.   (princ)
  408. )

评分

参与人数 1D豆 +2 收起 理由
/db_自贡黄明儒_ + 2 很给力!经验;技术要点;资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 40个

财富等级: 招财进宝

发表于 2016-9-18 01:23:50 | 显示全部楼层

2008下,这个LISP测试,结果也不对,看图

xdrx_hatch_mkbpoly 结果正确,并生成了连续的SPLINE封闭边界。

搜狗截图20160918011905.png
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 593个

财富等级: 财运亨通

发表于 2016-9-18 05:38:34 来自手机 | 显示全部楼层
这个程序对spline ellipse在某些情况下有bug,在autocad没有提供hatchedit重建边界之前我修改过这个程序,有了命令就用不到了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 51个

财富等级: 招财进宝

发表于 2016-9-18 09:59:57 | 显示全部楼层
上面N版提供的是生成连续的SPLINE边界的例子,下面代码能得到组成边界的单独的实体,两椭圆和两SPLINE

  1. (defun c:tt()
  2.    (if (setq e (car(xdrx_entsel "\n拾取填充<退出>:" '((0 . "hatch")))))
  3.       (progn
  4.          (setq numLoop (xdrx_getpropertyvalue e "numLoops"))
  5.          (setq i -1)
  6.          (repeat numLoop
  7.             (setq ges (xdrx_getpropertyvalue e "getloopat" (setq i (1+ i))))
  8.             (xdge::entity:make (cdr ges))
  9.          )
  10.       )
  11.    )
  12.    (xdge::free)
  13.    (princ)
  14. )



搜狗截图20160918095553.png

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 08:33 , Processed in 0.424053 second(s), 45 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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