(求助)请教一下大神,能否帮小弟实现,生成直线阵列后,能把直线变成矩形,谢谢大....
本帖最后由 999999 于 2024-2-4 09:14 编辑提前先祝各位论坛的大神版主及小白,新年快乐,健健康康,财源滚滚。小弟我希望论坛办的会越来越好
如果有大神,刚好有时间的话,看是否能帮小弟解决一下问题,谢谢各位啦
以下是问题的需求:(1-6的需求点插件,已经上传:名字叫,生成直线阵列)
1.输入命令
2.第一点
3.第二点
4.请输入直线长度:15(可输入数值也可鼠标点两点定数值)
5.请输入间距:3.6 (可输入数值也可鼠标点两点定数值)
6.数值都需要带记忆功能
以上需求,已经有论坛的大神帮忙解决了,大神名叫:xj6019
原贴地址:http://bbs.mjtd.com/thread-185537-1-1.html
现在需求就是,看有没有大神可以帮小弟结合一下,和下面的需求一起实现:
7.请输入直线双偏闭合的宽度:1.2(把生成的直线变成矩形并删除中线只保留矩形)
8.图层名为YB4
9.数值都需要带记忆功能
感谢各位大神的认真观看,小弟我希望有兴趣及时间的大神,可以帮忙练练手,谢谢大家啦
xj6019 发表于 2024-2-4 11:51
;生成直线阵列
(defun C:NM (/ p1 p1d p2 ps ps1 ps2 recp1 recp2)
(setq p1 (getpoint "\n第一点:")) ...大神私下最新改动,正是我想要的效果,谢谢大神
;生成直线阵列
(defun C:NM (/ang cishu lstp1 p1d p2 ps ps1 ps2 recp1 recp2 recp3 recp4 skuandu)
(setq p1 (getpoint "\n第一点:"))
(setq p2 (getpoint "\n第二点:" p1))
(or *dchangdu* (setq *dchangdu* 15))
(setq*dchangdu* (if (setq odchangdu(getdist(strcat "\r请输入直线长度<" (rtos *dchangdu*) ">:")))
odchangdu
*dchangdu*
)
)
(or *djianju* (setq *djianju* 3.6))
(setq*djianju* (if (setq odjianju(getdist(strcat "\r请输入间距<" (rtos *djianju*) ">:")))
odjianju
*djianju*
)
)
(or *pkuandu* (setq *pkuandu* 1.2))
(setq*pkuandu* (if (setq opkuandu(getdist(strcat "\r请输入偏移宽度<" (rtos *pkuandu*) ">:")))
opkuandu
*pkuandu*
)
)
(setq cishu(atoi(rtos(-(/(distance p1 p2)*djianju*)0.5)2 0)))
(setq p1d p1)
(setq ang(angle p1d p2))
(repeat cishu
(setq ps(polar p1 (angle p1d p2)*djianju*))
(setq ps1(polar ps (+ ang(* 0.5 pi))(* 0.5 *dchangdu*)))
(setq ps2(polar ps (+ ang(* 1.5 pi))(* 0.5 *dchangdu*)))
(setq skuandu(* 0.5 *pkuandu*))
(setq recp1(polar ps1(+(* 0.5 pi)(angle ps1 ps2)) skuandu))
(setq recp2(polar ps1(+(* 1.5 pi)(angle ps1 ps2)) skuandu))
(setq recp3(polar ps2(+(* 0.5 pi)(angle ps1 ps2)) skuandu))
(setq recp4(polar ps2(+(* 1.5 pi)(angle ps1 ps2)) skuandu))
(setq lst(list recp1 recp2 recp4 recp3 recp1))
(entmakex(append(list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")(cons 90 (length lst)))(mapcar '(lambda (p)(cons 10 p)) lst)))
(vla-put-layer (vlax-ename->vla-object (entlast)) "YB4")
(setq p1 ps)
)
(princ)
)
;生成直线阵列
(defun C:NM (/ p1 p1d p2 ps ps1 ps2 recp1 recp2)
(setq p1 (getpoint "\n第一点:"))
(setq p2 (getpoint "\n第二点:" p1))
(or *dchangdu* (setq *dchangdu* 15))
(setq*dchangdu* (if (setq odchangdu(getdist(strcat "\r请输入直线长度<" (rtos *dchangdu*) ">:")))
odchangdu
*dchangdu*
)
)
(or *djianju* (setq *djianju* 3.6))
(setq*djianju* (if (setq odjianju(getdist(strcat "\r请输入间距<" (rtos *djianju*) ">:")))
odjianju
*djianju*
)
)
(or *pkuandu* (setq *pkuandu* 1.2))
(setq*pkuandu* (if (setq opkuandu(getdist(strcat "\r请输入偏移宽度<" (rtos *pkuandu*) ">:")))
opkuandu
*pkuandu*
)
)
(setq cishu(atoi(rtos(-(/(distance p1 p2)*djianju*)0.5)2 0)))
(setq p1d p1)
(setq ang(angle p1d p2))
(repeat cishu
(setq ps(polar p1 (angle p1d p2)*djianju*))
(setq ps1(polar ps (+ ang(* 0.5 pi))(* 0.5 *dchangdu*)))
(setq ps2(polar ps (+ ang(* 1.5 pi))(* 0.5 *dchangdu*)))
;(setq entl(entmakeX (list '(0 . "LINE") (cons 10 ps1) (cons 11 ps2))))
(setq skuandu(* 0.5 *pkuandu*))
(setq recp1(polar ps1(+(* 0.5 pi)(angle ps1 ps2)) skuandu))
(setq recp2(polar ps2(+(* 1.5 pi)(angle ps1 ps2)) skuandu))
(command "_RECTANG""_non"recp1 "_non"recp2)
(vla-put-layer (vlax-ename->vla-object (entlast)) "YB4")
(setq p1 ps)
)
(princ)
)
写有点复杂,是不是选择直线,变成矩形? 自贡黄明儒 发表于 2024-2-4 09:16
写有点复杂,是不是选择直线,变成矩形?
大神您好,是的呢,之前的代码就是生成直线阵列,,现在就是需要把生成的直线,变成输入数值的矩形呢 看着像斑马线 rocking2008 发表于 2024-2-4 09:53
看着像斑马线
嘿嘿,好眼力,就是它 画这个不是有专业的交通软件吗?, ssyfeng 发表于 2024-2-4 13:06
画这个不是有专业的交通软件吗?,
自己不是专业的,也不知道有专用的软件呢
页:
[1]
2