乐筑天下

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

[编程交流] JOIN vs (command "_join")

[复制链接]

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 19:53:39 | 显示全部楼层 |阅读模式
Hi all,
 
I have two lines (not polylines) that join at a point to make a "V" shape. I've assigned them to "line1" and "line2":
  1. (setq line1 (car (entsel)))(setq line2 (car (entsel)))
Now, if I were to enter "JOIN" at the AutoCAD command prompt, select line #1, select line #2, then hit [enter] to end the command, I would see the message "2 objects converted to 1 polyline", and as you'd expect the two lines are now a single polyline.
 
However, if I were to enter (command "_join" line1 line2 "") to mimic the same as above, I see the message "0 lines joined to source, 1 object discarded from the operation" and the two lines are still two lines (not a single polyline)
 
(1) can someone please confirm this happens for them too?
(2) does anyone know of a workaround, or a different way to join two lines into a single polyline in lisp?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 20:10:58 | 显示全部楼层
Need a bit more use pedit
  1. (setq l1 (entsel))(setq l2 (entsel))(command "pedit" l1 "Y" "J" l2 "" "")
回复

使用道具 举报

26

主题

210

帖子

184

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
130
发表于 2022-7-5 20:34:28 | 显示全部楼层
Try this.
  1. (defun c:test (/ SS) (setq ss (ssget '((0 . "LINE,ARC,LWPOLYLINE,SPLINE")))) (command   "_.pedit" "_multiple" ss "" "_join" "" "") (princ))
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 20:43:33 | 显示全部楼层
Thanks for the replies. Indeed, switching to PEDIT worked out best, and temporarily setting PEDITACCEPT=1 made it more robust (whether the user selects lines or polylines, the command (command "_PEDIT" ent1 "_J" ent2 "" "") works in both cases). I still dont understand why JOIN didn't work, and I'm daring enough to call it a bug.
 
Nice selection set suggestion too
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:59:17 | 显示全部楼层
 
AutoCAD commands change between versions; therefore, to enable backwards compatibility, invoking a command through AutoLISP will usually use the old version of the command so that there is less chance of a custom program breaking when a new version is released.
 
To force AutoLISP to use the newer version of a command, you can use the initcommandversion function, for example:
  1. (initcommandversion)(command "_.join" line1 line2 "")
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 00:48 , Processed in 0.610275 second(s), 62 queries .

© 2020-2025 乐筑天下

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