乐筑天下

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

[编程交流] 为Pol创建3条中心曲线

[复制链接]

95

主题

477

帖子

383

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
475
发表于 2022-7-5 17:39:42 | 显示全部楼层
在这里,不是百分之百确定,但如果您想使用最小弧的圆角,请尝试以下方法:
 
李,我忍不住要修改。。。希望你不介意。。。
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 17:43:13 | 显示全部楼层
 
版本2
[code](定义c:3cc(/acn aof ard cen crd ecn eof erd int per sg1 sg2 tmp vc1 vc2)(同时(和(setq sg1(getsegment“\n选择进近线:”)(setq sg2(getsegment“\n选择相交线:”)(不(setq int(应用‘inters(附加sg1 sg2’(kkkkkk)))(原理“\n线不相交”)(cond((not(和sg1 sg2(vl every)(lambda(sym msg)(initget 6)(set sym(getdist msg)))'(ard crd erd aof eof)“”(“\n指定进近半径:”“\n指定中心半径:”“\n指定端点半径:”“\n指定进近偏移:”“\n指定连接偏移:”)((
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 17:45:16 | 显示全部楼层
我不想偷李的版本,但我只是想万一有人在随机UCS的3D工作中需要这个。。。我想,当我已经为我的内部目的修改了它,为什么不发布它。。。对不起,李,这只是为了更适用于用户可能遇到的各种情况。。。我的圆角版本已经是3D。。。如果有什么不对劲,请告诉我们。。。
 
[code](defun c:3cc(/sortfarthestfrom arc getsegment LM:顺时针-p LM:inters line circle quad vxv vxs vx1 acn aof ard cent crd ecn eof erd int per sg1 sg2 tmp vc1 vc2)(vl load com)(defun sortfarthestfrom(pnt lst)(vl sort lst)(λ(a b)(>(距离pnt a)(距离pnt b))))(defun arc(cent rad sta ena ocs)(entmake(list)(000.“arc”)(cons 010 cen)(cons 040 rad)(cons 050 sta)(cons 051 ena)(cons 210 ocs))(defun getsegment(msg/ent enx par rtn sel typ)(while(progn(setvar’errno 0)(setq sel(entsel msg))(cond(=7(getvar’errno))(princ“\n失败,再试一次。”)((null sel)nil)(=“LINE”(setq ent(car sel)enx(entget ent)typ(cdr(assoc 0 enx))))(setq rtn(list(trans(cdr(assoc 10 enx))0 1)(trans(cdr(assoc 11 enx))0 1)))nil((=“LWPOLYLINE”类型)(setq par(vlax curve getparamatpoint ent(vlax curve GetClosestPoint to ent(trans(cadr sel)1 0)))rtn(list(trans(vlax curve getpointatparam ent(fix par))0 1)(trans(vlax curve getpointatparam ent(1+(fix par)))0 1)))nil)((princ“\n请选择一条直线或二维多段线。”))rtn);;顺时针-p-李;;如果p1、p2、p3为顺时针方向(defun LM:顺时针-p(p1 p2 p3)(<(*((汽车p2)(汽车p1))(((cadr p3)(cadr p1)))(*((((cadr p2)(cadr p1))(((((cadr p2)(cadr p1))((汽车p3)(汽车p1)));;线-圆交点(矢量版本)-Lee Mac;;返回由定义的无限直线之间的交点;;点p、q和具有中心c和半径r的圆(defun LM:inters line circle(p q c r/v s)(setq v(mapcar'-q p)s(mapcar'-p c))(mapcar'(lambda(s)(mapcar'+p(vxs v s)))(quad(vxv v v v)(*2(vxv v s))(((vxv xv s s s)(*r)));;二次解-Lee-Mac;;Args:a,b,c-ax^2+bx+c=0的系数(defun quad(a b c/d r)(cond((等于0.0(setq d(-b b)(*4.0 a c)))1e-(list(/b(*-2.0 a))(<0 d)(setq r(sqrt d))(list(/(-r b)(*2.0 a))(/((-b)r)(*2.0 a)));;向量点积-Lee Mac;;Args:u,v-R^n中的向量(defun vxv(u v)(应用'+(mapcar'*u v));;向量x标量-Lee Mac;;Args:R^n中的v-向量,s-实标量(定义vxs(vs)(mapcar'(lambda(n)(*ns))v);;单位矢量-Lee Mac;;参数:v-R^2或R^3中的向量(defun vx1(v)((lambda(n)(if(等于0.0 n 1e-10)nil(mapcar’/v(list n n n n)))(距离(0.0 0.0 0 0.0)v))(而(和(setq sg1(getsegment“\n选择进近线:))(setq sg2(getsegment“\n选择相交线:)))(而不是(setq int(应用‘inters(append sg1 sg2’(”“)))))(原理“\n线不相交。”)(cond((not(和sg1 sg2(vl every)(lambda(sym msg)(initget 6)(set sym(getdist msg)))'(ard crd erd aof eof)“”(“\n指定进近半径:”“\n指定中心半径:”“\n指定端点半径:”“\n指定进近偏移:”“\n指定连接偏移:”)((
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:48:20 | 显示全部楼层
李,非常感谢你,这真是太棒了!Marko,我也测试了你的,看起来效果也不错。Marko,当我深入研究你的代码时,我试图理解其中的差异,这主要与你翻译这些点有关吗,所以它在任何UCS中都有效(我只使用dview,所以我不需要经常考虑这种翻译)?我很好奇,因为我正在努力提高我的编码技能,而看到这样的代码真的很有帮助!
175909y5oomnjm7290nm29.png
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 17:52:45 | 显示全部楼层
它主要与翻译功能有关。。。在大多数情况下,我们都在WCS中工作,但当您认为通常只有当例程适用于所有情况时,编码才完成。。。在这种特殊情况下,在大多数情况下,所有的工作都是在UCS中完成的,但当涉及到(entmake)时,您必须考虑各种类型的etype,以及如何通过DXF代码规范解释它们。。。这就是你对实体创造的理解发挥作用的地方。。。你必须考虑各种情况-这里弧类似于圆-而椭圆不同-当弧/圆是参考实体时,你应该考虑OCS(对象坐标系)。。。如果它是椭圆,那么它有点不同-你应该认为WCS和OCS的DXF 210代码。。。如果你仔细看看我的上一段代码,它和李的完全一样,只是(弧)函数不同,在需要时添加了ocs参数和最后一行
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
475
发表于 2022-7-5 17:56:13 | 显示全部楼层
Lee, thank you so much, this is working perfectly! Marko, I tested yours as well, and it seems to work great as well. Marko, as I am diving into your code, I am trying to understand the difference, does it primarily have to do with you translating the points, so it will work in any UCS (I only use dview, so I don't often have to think about this translation)? I'm curious because I am trying to improve my coding skills, and looking at codes like these have really helped!
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 17:59:16 | 显示全部楼层
It mostly has to do with translation function (trans)... In the most cases we all work in WCS, but when you think generally the coding is finished only when routine is applicable for all situations... In this particular case and in the most cases all the job is done in UCS, but when it comes to (entmake) you have to think for various etypes and how they are interpreted through DXF code specifications... This is where your understanding of creation of entities comes into role... You have to account for various situations - here ARC is similar to CIRCLE - while ELLIPSE differs - when ARC/CIRCLE is reference entity then you should think in terms of OCS (object coordinate system)... If it's ELLIPSE then it is little different - you should think WCS and OCS for DXF 210 code... If you look closer into my last code - it's totally the same as Lee's with only difference in (arc) function where is added ocs argument and last lines when it's needed to create ARCs in 3D in random UCS in 3D, appropriate transformations are predicted to make sure correct 3D arc entities are created in 3D... So weather you are working in 3D or 2D, routine is properly coded only when applicable for both situations and this means if it works for random UCS, it should work fine and for WCS which is the case with my replied codes...
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 07:59 , Processed in 0.568449 second(s), 66 queries .

© 2020-2025 乐筑天下

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