geo1595 发表于 2022-7-6 23:32:42

限制圆弧的AutoLISP命令

您好,我正在寻找一种限制圆弧长度的方法(使用AutoLISP),该圆弧沿x轴有一个设定的中心点和一个设定的半径?

BIGAL 发表于 2022-7-6 23:41:04

不知道你想要什么,需要一张照片。如果弧小于359.99999度,则弧不是圆

geo1595 发表于 2022-7-6 23:43:00

https://www.cadtutor.net/forum/attachment.php?attachmentid=55794&cid=1&stc=1
红线是要删除的部分,黄色弧的长度需要受到吹扫CM的限制,其中弧的半径为弧垂。
此外,出现的两条白线不会出现在最终脚本中。
我已经在下面发布了我的脚本。

;; Sets the initiating command to "TEST"

(defun C:TEST()

;; Sets the pre-defined values for blow-off

(setq d 0.0211)
(setq F 0.63)
(setq T 1878)

;; Sets the variables for blow-off

(setq Vw (getreal "\n Enter the Windspeed (m/s):"))
(setq L (getreal "\n Enter the Span-length (m):"))

;; Calculates the Blow-off in (m)

(setq multiply1 (* (* Vw Vw) (* L L)))
(setq multiply2 (* d F))
(setq BLOWOFFm1 (* multiply1 multiply2))
(setq BLOWOFFm (/ BLOWOFFm1 (* 8 T)))

;; Sets pre-defined values for sag

(setq V 7.159)
(setq t 1878)

;; Sets the variables for sag

(setq S (getreal "\n Enter the height at the start of the span (m):"))
(setq E (getreal "\n Enter the height at the end of the span (m):"))
(setq As L)

;; Calculates position of low point in span

(setq P (- (/ As 2) (* t (/ (- E S) (* V As)))))

;; Calculates the wire sag (m)

(setq sag1 (/ (* V (EXPT P 2.0)) (* 2 t)))

;; Converts wire sag into (cm)

(setq sag (* sag1 100))

;; Converts BLOWOFFm onto (cm)

(setq BLOWOFFcm (* BLOWOFFm 100))

;; Asks the user to select the original wire location

(setq originalwire (getpoint "\n Select the original wire location:"))

;; Sets temporary points for blow-off

(setq temp1 (polar originalwire 4.7123889803846898576939650749193 sag))

;; Draws clearance circle for originalwire

(command "_CIRCLE" originalwire (/ d 2))

;; Creates points for arc based on blowoff and sag

(setq arcpointmiddle (polar temp1 1.5707963267948966192313216916398 BLOWOFFcm))
(setq arcpointright (polar arcpointmiddle 0.0 BLOWOFFcm))
(setq arcpointleft (polar arcpointmiddle 3.1415926535897932384626433832795 BLOWOFFcm))

;; Linetype load

(defun ltype_set (ltname)
(if (not (tblsearch "LTYPE" ltname)) ;; Check to see if the linetype exists
(if (findfile "acad.lin")
(command "._LINETYPE" "._LOAD" ltname "acad.lin" "") ;; Load the linetype if it is found
(setq ltname "Continuous") ;; If not, set the linetype to Continuous
)
)
)

;; Creates a new layer for the clearnace to be placed on after checking if the layer already exists

(defun layer_set (lyr col ltname)
(if (tblsearch "LAYER" lyr) ;; Check to see if the layer exists
(command "._LAYER" "_THAW" lyr "_UNLOCK" lyr "_ON" lyr "_SET" lyr "") ;; If layer exists, set it current

;; If the layer doesn't exist, make this layer

(if (tblsearch "LTYPE" ltname) ;; If linetype doesn't exist
(command "._LAYER" "_MAKE" lyr "_COLOUR" col lyr "_LT" ltname lyr "")
(command "._LAYER" "_MAKE" lyr "_COLOUR" col lyr "_LT" "Continuous" lyr "")
)
)
)

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHDOT")
(command "._CIRCLE" originalwire sag)
;(command "._ARC" arcpointleft arcpointmiddle arcpointright)

;; Reset layer back to "0"

(layer_set "0" "7" "Continuous")

;; Draws clearance circles for left, right and middle arcpoints

(command "_CIRCLE" temp1 (/ d 2))
(command "_CIRCLE" arcpointleft (/ d 2))
(command "_CIRCLE" arcpointright (/ d 2))

;; Draws lines for trim

(setq line1 (polar arcpointleft 4.7123889803846898576939650749193 BLOWOFFcm))
(command "._LINE" arcpointleft line1 "")
(setq line2 (polar arcpointright 4.7123889803846898576939650749193 BLOWOFFcm))
(command "._LINE" arcpointright line2 "")

;; Creates a text box containing the BLOWOFFcm value

(setq text3 (getpoint "\n Pick the first point for the dimension box:"))
(setq text4 (getpoint "\n Pick the second point for the dimension box:"))
(command "_.MTEXT" text3 text4 "Blow-off (cm) =" BLOWOFFcm "")

;; Creates a text box containing the Sag value

(setq text5 (getpoint "\n Pick the first point for the dimension box:"))
(setq text6 (getpoint "\n Pick the second point for the dimension box:"))
(command "_.MTEXT" text5 text6 "Sag (cm) =" sag "")

;; Trims the excess circle

(command "._TRIM" "")

(princ)
)

 
此外,如何在黄色弧的每一端创建一个附加点?
 
谢谢你的帮助

tombu 发表于 2022-7-6 23:48:17

我试着让你口齿不清,但仍然不确定你想做什么。与其画一个圆并修剪它,为什么不画一个弧呢?由于弧垂²-吹扫cm²=dy²,吹扫cm/sag=½弧角的余弦,因此绘制弧和端点应该足够简单。

geo1595 发表于 2022-7-6 23:53:55

我曾尝试使用两点创建圆弧,但有一个问题,即没有弧垂作为半径。(我已经从代码中删除了它,因为它开始破坏它,我想使用一个圆并修剪它)

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHDOT")
(command "._CIRCLE" originalwire sag)
;(command "._ARC" arcpointleft arcpointmiddle arcpointright)

 
我真的不确定我该如何实施你的建议,因为你的等式让我有点困惑

tombu 发表于 2022-7-6 23:57:22

arcpointleft、arcpointmiddle和arcpointright点不构成弧。尝试使用
在图形中的这些点之间放置一条线,以查看它们是否构成一条直线。不能用三个点绘制一条直线。也没有一个是圆。如果正确计算这些点,Arc命令将起作用。因为BLOWOFFcm是端点的dx,我展示了如何得到端点的dy,首先你要做的是从原始导线的x值减去弧垂值,得到弧点中点。

geo1595 发表于 2022-7-7 00:02:27

这是有道理的。我现在就开始实施,看看进展如何。

geo1595 发表于 2022-7-7 00:05:34

谢谢tombu!
 
我如何使底弧与3个圆相切?我可以在中间圆圈的底部设置一个点,但两边的两个呢?
 
https://www.cadtutor.net/forum/attachment.php?attachmentid=55801&cid=1&stc=1
 
我是通过以下方式在图片中完成的:

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHED")
(command "._ARC" arcpointleft arcpointmiddle arcpointright "")

;; Sets another set of points for the clearance arc

(setq clearancearcmiddle (polar arcpointmiddle 4.7123889803846898576939650749193 66))
(setq clearancearcleft (polar arcpointleft 4.7123889803846898576939650749193 66))
(setq clearancearcright (polar arcpointright 4.7123889803846898576939650749193 66))



;; Draws clearance arc

(command "._ARC" clearancearcleft clearancearcmiddle clearancearcright)

tombu 发表于 2022-7-7 00:11:57

假设这三个圆的半径相同,只需将第一个圆弧偏移该量即可。我将使用entget实体列表数据生成另一条弧,该数据来自具有修改半径的第一条弧。查看圆弧图元的DXF组码。正如我所记得的,你需要做的是弧的中心点,半径,开始角度和结束角度。

BIGAL 发表于 2022-7-7 00:18:21

(setq Pi270(*1.5 pi))=4.171238898
页: [1] 2
查看完整版本: 限制圆弧的AutoLISP命令