乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 41|回复: 19

[编程交流] 切割面积

[复制链接]

8

主题

50

帖子

42

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:02:43 | 显示全部楼层 |阅读模式
我需要有人谁可以使这个cad lisp切割面积从一大片土地。。我正在寻找并厌倦了手动计算一部分土地。
 
这是我的样品。。

                               
登录/注册后可看大图
回复

使用道具 举报

0

主题

269

帖子

279

银币

限制会员

铜币
-4
发表于 2022-7-5 18:08:20 | 显示全部楼层
思维过程是什么;
 
-给定一块土地,可以是任何不规则形状
-需要根据已知目标区域切除一部分
-切割线始终与用户选择的一侧平行?
 
Q
-地块始终是闭合多段线还是由直线组成。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:11:54 | 显示全部楼层
我对伪代码的思考。。。
 
选择“外部边界”,然后选择“平行线”。
 
然后,不知何故,从选定的线和它与主多段线相交的地方形成一条闭合的多段线。。。可能很难找到从哪一边得到面积。。。可能需要用户的另一个选择。
 
最后,使用AREA命令查找区域。。
回复

使用道具 举报

8

主题

50

帖子

42

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:12:58 | 显示全部楼层
 
是的,地块是多段线。。。
 
这是另一块土地样本。。

                               
登录/注册后可看大图

 
这个有很多点或角点,所以我需要时间来计算。。
希望有一天能帮助解决这个问题。
 
非常感谢。
 
奥利弗
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:17:55 | 显示全部楼层
你能不能在平行线的交点处打断外基线,使其成为闭合基线,然后只使用“面积”命令?
 
或者这就是你一直在做的事情?
回复

使用道具 举报

8

主题

50

帖子

42

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:19:17 | 显示全部楼层
耶。。之前,我通过从参考线或基线偏移并调整20x来手动完成。。
 
你说试试区域指挥。。我一直都在这么做,但没什么能成功。。它只是加和减。。
 
奥利弗
回复

使用道具 举报

8

主题

50

帖子

42

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:22:30 | 显示全部楼层
哦gr8t。。我发现了一个常规的Lisp程序。
 
  1. ;;;DIVAREA.LSP  Land division utility
  2. ;;;  Suppose that you have to split a big part into 2, 3, 4 (or even 5.014!)
  3. ;;;  or you want to cut a part of 2345 m2 out of the big one.
  4. ;;;
  5. ;;;  All you need is a CLOSED LWPOLYLINE enclosing the big part.
  6. ;;;
  7. ;;;  Load the utility, after placing it into an appropriate folder,
  8. ;;;  let's say \Program Files\Acad2000\Support, invoke "APPLOAD" command
  9. ;;;  or invoke (LOAD"DIVAREA") and run it by typing DIVAREA.
  10. ;;;
  11. ;;;  Answer the few questions you will be asked and REMEMBER:
  12. ;;;
  13. ;;;  When you are prompted to indicate the two points of
  14. ;;;  the approximate division line, please bear in mind that
  15. ;;;
  16. ;;;     1. This DIVISION LINE will be rotated (or be offseted) and
  17. ;;;  neither of its endpoints should reside outside of the boundary,
  18. ;;;  (although it should have been easy to overcome this bug),
  19. ;;;  so pick points as FAR OUT from the boundary as possible,
  20. ;;;  not exceeding, of course, your current visibe area.
  21. ;;;  As for the FIXED POINT, in case you prefer "F"
  22. ;;;  rather than "C" as an answer in the previous question, it has to
  23. ;;;  reside on the lwpoly or outside of it, never inside.
  24. ;;;
  25. ;;;     2. When indicating point into the part which will obtain the desired
  26. ;;;  area, you have to indicate INTO it and AS FAR from division line as
  27. ;;;  possible, so this point will not be outside of the desired part
  28. ;;;  while the division line is moving into it.
  29. ;;;
  30. ;;;     3. Finally, you have to indicate exactly by the same way,
  31. ;;;  FAR FROM DIVISION line and INTO the remaining piece.
  32. ;;;  If you prefer more precision you can decrease local vars step2
  33. ;;;  and step1 accordingly.
  34. ;;;
  35. ;;;******************UTILITY STARTS HERE*******************************
  36. (defun prerr (s)
  37. (if (/= s "Function cancelled")
  38.     (princ (strcat "\nError: " s))
  39. );endif
  40. (setq *error* olderr)
  41. (princ)
  42. );close defun
  43. (Defun C:DIVAREA(/ osm strpf strdc ex arxset arx arxon k scl ok
  44.                   d p1 p2 pts ptb deln ar par tem
  45.                   stp stp1 stp2               
  46.                )
  47. (setq olderr *error*
  48.       *error* prerr)
  49. (setq osm(getvar "osmode"))
  50. (setvar "osmode" 0)
  51. (setvar "cmdecho" 0)
  52. (setq ex 0
  53.       stp  0.01
  54.       stp1 0.005
  55.       stp2 0.0005
  56. )
  57. (setq arxset (entsel "\nSelect closed LWPOLY to divide: ")
  58.       arx    (entget(car arxset))
  59.       arxon  (cdr (assoc -1 arx))
  60. )
  61. (if (not(and(equal (cdr(assoc 0 arx)) "LWPOLYLINE") (= (cdr(assoc 70 arx)) 1)))
  62.     (progn
  63.           (princ "\nSORRY, ONLY CLOSED LWPOLYLINES ALLOWED...")
  64.           (setq ex 1)
  65.     )
  66. )
  67. (if (= ex 0)
  68.     (progn
  69.       (command "_undo" "m") ;if something goes bad, you may return here
  70.       (command "_layer" "m" "Area_Division" "")
  71.       (command "_area" "e" arxon)
  72.       (setq ar(getvar "area"))
  73.       (initget "Divide Cut")
  74.       (setq strdc(getkword "\nDIVIDE by number or CUT a part ? (D/C) :"))
  75.       (if (= strdc "Divide")
  76.           (progn
  77.                 (setq k  (getreal "\nEnter number to divide the whole part by : "))
  78.                 (setq tem(/ ar k))
  79.           )
  80.       )
  81.       (if (= strdc "Cut")
  82.           (setq tem (getreal "\nEnter area to cut from the whole part (m2) : "))
  83.       )
  84.       (initget "Parallel Fixed")
  85.       (setq strpf(getkword "\nPARALLEL to a direction or FIXED side? (P/F) :"))
  86.       (if (= strpf "Fixed")
  87.           (fixpt)
  88.       )
  89.       (if (= strpf "Parallel")
  90.           (parpt)
  91.       )
  92.       (ready)
  93.     )
  94.     (ready)
  95. )
  96. )
  97. ;******************************************************************************
  98. (defun fixpt ()
  99. (setvar "osmode" osm)
  100. (setq scl    0.05
  101.       p1     (getpoint "\nPick fixed point of the division line : ")
  102.       p2     (getpoint "\nPick second point of division line: ")
  103. )
  104. (setvar "osmode" 0)
  105. (command "_line" p1 p2 "")
  106. (setq deln (entlast))
  107. (setq pts (getpoint "\nPick any point into FIRST piece, FAR from division line: "))
  108. (setq ptb (getpoint "\nPick any point into the REST of the piece, FAR from division line: "))
  109. (setvar "blipmode" 0)
  110. (princ "\nPlease wait...")
  111. (command "_boundary" pts "")
  112. (command "_area" "e" "l")
  113. (setq par(getvar "area"))
  114. (setq ok -1)
  115. (if (< par tem)
  116. (progn
  117.        (while (< par tem)
  118.         (entdel (entlast))
  119.         (if (< (- tem par) 50)(setq scl stp))
  120.         (if (< (- tem par) 10)(setq scl stp2))
  121.         (command "_rotate" deln "" p1 (* scl ok))
  122.         (command "_boundary" pts "")
  123.         (command "_area" "e" "l")
  124.         (if (< (getvar "area") par)
  125.             (setq ok(* ok -1))
  126.         )
  127.         (setq par(getvar "area"))
  128.        );endwhile
  129.        (entdel deln)
  130. )
  131. (progn
  132.        (while (> par tem)
  133.         (entdel (entlast))
  134.         (if (< (- par tem) 50)(setq scl stp))
  135.         (if (< (- par tem) 10)(setq scl stp2))
  136.         (command "_rotate" deln "" p1 (* scl ok))
  137.         (command "_boundary" pts "")
  138.         (command "_area" "e" "l")
  139.         (if (> (getvar "area") par)
  140.             (setq ok(* ok -1))
  141.         )
  142.         (setq par(getvar "area"))
  143.        );endwhile
  144.        (entdel deln)
  145. )
  146. )
  147. (command "_change" "l" "" "p" "c" "green" "")
  148. (command "_boundary" ptb "")
  149. (command "_change" "l" "" "p" "c" "red" "")
  150. (ready)
  151. )
  152. ;******************************************************************************
  153. (defun parpt ()
  154. (setvar "osmode" osm)
  155. (setq scl    0.25
  156.       p1     (getpoint "\nPick one point of division line (far from lwpoly) : ")
  157.       p2     (getpoint "\nPick other point of division line (far from lwpoly) : ")
  158. )
  159. (setvar "osmode" 0)
  160. (command "_line" p1 p2 "")
  161. (setq deln(entlast))
  162. (setq pts (getpoint "\nPick any point into FIRST piece, FAR from division line: "))
  163. (setq ptb (getpoint "\nPick any point into the REST of the piece, FAR from division line: "))
  164. (setvar "blipmode" 0)
  165. (princ "\nPlease wait...")
  166. (command "_boundary" pts "")
  167. (command "_area" "e" "l")
  168. (setq par(getvar "area"))
  169. (if (< par tem)
  170. (progn
  171.        (while (< par tem)
  172.         (entdel (entlast))
  173.         (if (< (- tem par) 50)(setq scl stp1))
  174.         (if (< (- tem par) 10)(setq scl stp2))
  175.         (command "_offset" scl deln ptb "")
  176.         (entdel deln)
  177.         (setq deln(entlast))
  178.         (command "_boundary" pts "")
  179.         (command "_area" "e" "l")
  180.         (setq par(getvar "area"))
  181.        )
  182.        (entdel deln)
  183. )
  184. (progn
  185.        (while (> par tem)
  186.         (entdel (entlast))
  187.         (if (< (- par tem) 50)(setq scl stp1))
  188.         (if (< (- par tem) 10)(setq scl stp2))
  189.         (command "_offset" scl deln pts "")
  190.         (entdel deln)
  191.         (setq deln(entlast))
  192.         (command "_boundary" pts "")
  193.         (command "_area" "e" "l")
  194.         (setq par(getvar "area"))
  195.        )
  196.        (entdel deln)
  197. )
  198. )
  199. (command "_change" "l" "" "p" "c" "green" "")
  200. (command "_boundary" ptb "")
  201. (command "_change" "l" "" "p" "c" "red" "")
  202. )
  203. ;******************************************************************************
  204. (defun ready ()
  205. (princ scl)
  206. (princ "\nActual : ")
  207. (princ par)
  208. (princ "\nMust be: ")
  209. (princ tem)
  210. (setq *error* olderr)
  211. (setvar "osmode" osm)
  212. (setvar "cmdecho" 1)
  213. (setvar "blipmode" 1)
  214. (princ "\nThanks...")
  215. (princ)
  216. );close defun

 
干杯
 
奥利弗
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-5 18:25:10 | 显示全部楼层
您也可以尝试:
http://cadtips.cadalyst.com/2d-editing/subdivide-lot-desired-areas-equal-or-unequal
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:29:02 | 显示全部楼层
也许是这个?
 
  1. ;;;=======================================================
  2. ;;;=======================================================
  3. ;;;
  4. ;;;  FUNCTION: Area Division (AreaDiv.lsp)
  5. ;;;  Calculates the area of a partitioned region.
  6. ;;;
  7. ;;;  AUTHOR
  8. ;;;  Copyright © 2009 Lee McDonnell
  9. ;;;    (contact ~ Lee Mac, CADTutor.net)
  10. ;;;
  11. ;;;  VERSION
  12. ;;;  1.0  ~  23.03.2009
  13. ;;;
  14. ;;;=======================================================
  15. ;;;=======================================================
  16. (defun c:ADiv  (/ *error* vlst ovar spc cEnt vpt cCur
  17.          cAng clen grlist arpt spt pt1 pt2 iLin
  18.          iArr iLst ptLst plst stpar vpts aPly)
  19. (vl-load-com)
  20. (defun *error*  (msg)
  21.    (grtext) (redraw)
  22.    (if    ovar (mapcar 'setvar vlst ovar))
  23.    (if    (not (member msg '("Function cancelled" "quit / exit abort")))
  24.      (princ (strcat "\n<!> Error: " (strcase msg) " <!>")))
  25.    (princ))
  26. (setq    vlst '("CMDECHO" "OSMODE")
  27.    ovar (mapcar 'getvar vlst))
  28. (mapcar 'setvar vlst '(0 0))
  29. (setq    spc (vla-get-ModelSpace
  30.          (vla-get-ActiveDocument
  31.        (vlax-get-Acad-Object))))
  32. (if (and (setq cEnt (entsel "\nSelect Edge for Segregation: "))
  33.       (eq "LWPOLYLINE" (cdadr (entget (car cEnt)))))        
  34.    (progn
  35.      (setq vpt (osnap (cadr cEnt) "_nea")
  36.        cCur (vlax-ename->vla-object (car cEnt))
  37.        cAng (angle    '(0 0 0) (vlax-curve-getFirstDeriv cCur
  38.                   (vlax-curve-getParamAtPoint cCur vpt))))
  39.      (setq clen (distance (vlax-curve-getPointatParam cCur
  40.                 (fix (vlax-curve-getParamAtPoint cCur vpt)))
  41.               (vlax-curve-getPointatParam cCur
  42.                 (1+ (fix (vlax-curve-getParamAtPoint cCur vpt))))))
  43.      (grtext -1 "Select Area Segregation...")
  44.      (while (= 5 (car (setq grlist (grread t 1))))
  45.    (redraw)
  46.    (if (= 'list (type (setq arpt (cadr grlist))))
  47.      (progn
  48.        (setq spt (vlax-curve-getClosestPointto cCur arpt)
  49.          pt1 (polar spt cAng (/ clen 3.0))
  50.          pt2 (polar spt cAng (/ clen -3.0)))
  51.        (grdraw pt1 pt2 3))))
  52.      (setq iLin (vla-Addline spc (vlax-3D-point spt)
  53.           (vlax-3D-point (polar spt cAng clen)))
  54.        iArr (vlax-variant-value
  55.           (vla-IntersectWith iLin cCur acExtendThisEntity)))
  56.      (if (> (vlax-safearray-get-u-bound iArr 1) 0)
  57.    (progn
  58.      (setq iLst (vlax-safearray->list iArr))
  59.      (while (not (zerop (length iLst)))
  60.        (setq ptLst    (cons (list (car iLst) (cadr iLst) (caddr iLst)) ptLst)
  61.          iLst    (cdddr iLst)))
  62.      (and (vla-delete iLin) (setq iLin nil))
  63.      (if (> (length ptlst) 1)
  64.        (progn
  65.          (setq plst  (vl-sort (list (vlax-curve-getParamAtPoint cCur (car ptLst))
  66.                (vlax-curve-getParamAtPoint cCur (cadr ptLst))) '<)
  67.            stpar (1+ (fix (car plst))))
  68.          (while (< stpar (cadr plst))
  69.        (setq plst (append plst (list stpar))
  70.              stpar (1+ stpar)))
  71.          (setq plst (vl-sort plst '<)
  72.            vpts (mapcar '(lambda (p) (vlax-curve-getPointatParam cCur p)) plst))
  73.          (command "_pline") (foreach x vpts (command x)) (command "_C")
  74.          (vla-put-color (setq aPly (vlax-ename->vla-object (entlast))) acRed)
  75.          (princ (strcat "\n<<<  Area of Enclosed Region: " (rtos (vla-get-Area aPly)) " >>>")))
  76.        (princ "\n<!> Selected Segregation not Closed <!>")))
  77.    (princ "\n<!> Area Not Segregated Properly <!>")))
  78.    (princ "\n<!> Nothing Selected or this isn't an LWPLINE <!>"))
  79. (mapcar 'setvar vlst ovar)
  80. (grtext) (redraw)
  81. (princ))
  82. (princ "\n** AreaDiv.lsp Successfully Loaded - type "ADiv" to invoke **") (princ)
回复

使用道具 举报

8

主题

50

帖子

42

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 18:32:06 | 显示全部楼层
谢谢你的努力。。我想你错过了什么。。我没有看到需要任何目标区域
 
奥利弗
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 00:00 , Processed in 0.938680 second(s), 87 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表