tmo793 发表于 2022-7-5 19:53:39

JOIN vs (command "_join")

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":

(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 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?

BIGAL 发表于 2022-7-5 20:10:58

Need a bit more use pedit

(setq l1 (entsel))(setq l2 (entsel))(command "pedit" l1 "Y" "J" l2 "" "")

mostafa badran 发表于 2022-7-5 20:34:28

Try this.

(defun c:test (/ SS) (setq ss (ssget '((0 . "LINE,ARC,LWPOLYLINE,SPLINE")))) (command   "_.pedit" "_multiple" ss "" "_join" "" "") (princ))

tmo793 发表于 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

Lee Mac 发表于 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:

(initcommandversion)(command "_.join" line1 line2 "")
页: [1]
查看完整版本: JOIN vs (command "_join")