Polyjoin Lisp help

I have a lisp routine to join lines, arcs and polylines together. The routine works fine in AutoCAD. I have tried using it in BCAD but it seems to have a problem. The routine will load, type PJ and it will start, but after selecting the entites it will return an error, and sometimes ends the session. I'm sure it probably just needs to be tweaked to run in BCAD.Any help would be appreciated.

PASTE CODE HERE

;;; POLYJOIN.LSP;;; Joins lines, arcs and polylines using a fuzz distance;;; If only one object is selected it tries to join to all objects that are possible(defun c:jf () (c:pj)) ; this line can be commented out if there is an existing command called jf(defun c:pj (/ ss1 entLine objType oldcmdecho oldpeditaccept fuzz okObjects) (setq oldcmdecho (getvar "cmdecho")) (setq oldpeditaccept (getvar "PEDITACCEPT")) (setvar "cmdecho" 0) (setq A2k4 (>= (substr (getvar "ACADVER") 1 2) "16")) (if A2k4 (setvar "PEDITACCEPT" 0)) (setq okObjects '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE"))) (princ "\nSelect object to join: ") (setq ss1 (ssget okObjects)) (setq fuzz (getdist "\nFuzz distance <0>: ")) (if (= fuzz nil) (setq fuzz 0)) (if (/= ss1 nil) (progn (setq objType (cdr (assoc 0 (entget (setq entLine (ssname ss1 0)))))) (if (= (sslength ss1) 1) (setq ss1 (ssget "X" okObjects))) (if (member objType '("LINE" "ARC")) (command ".pedit" "_M" ss1 "" "_Y" "_J" "_J" "_B" fuzz "") (command ".pedit" "_M" ss1 "" "_J" "_J" "_B" fuzz "") ) ) ) (setvar "cmdecho" oldcmdecho) (if A2k4 (setvar "PEDITACCEPT" oldpeditaccept)) (princ))(prompt "\npolyjoin.lsp...Loaded!")(prompt "\nType 'PJ' to RUN: ")(princ)

Comments

  • I'm no expert and a bit pushed for time, but just a quick look I see PEDITACCEPT doesn't seem to be in Bcad's list of vars.I have found V8 isn't very tolerant of some lisps with problems, and some good ones stop working occasionally until you start a new session.

  • You can try something like this. There is no fuzz factor so ….

    (DEFUN C:PJ ( / entline object objectname objtype okobjects oldcmdecho ss1) (SETQ OKOBJECTS '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE"))) (PRINC "\nSelect object to join: ") (SETQ OLDCMDECHO (GETVAR "CMDECHO")) (SETVAR "CMDECHO" 0) (SETQ SS1 (SSGET OKOBJECTS)) (IF (/= SS1 NIL) (PROGN (SETQ OBJECT (ENTGET (SETQ ENTLINE (SSNAME SS1 0)))) (SETQ OBJECTNAME (CDR (CAR (ENTGET (SETQ ENTLINE (SSNAME SS1 0)))))) (SETQ OBJTYPE (CDR (ASSOC 0 OBJECT))) (IF (= (SSLENGTH SS1) 1) (SETQ SS1 (SSGET "X" OKOBJECTS)) ) (IF (MEMBER OBJTYPE '("LINE" "ARC")) (COMMAND "_.pedit" OBJECTNAME "Y" "J" SS1 "" "") (COMMAND "_.pedit" OBJECTNAME "J" SS1 "" "") ) ) ) (SETVAR "CMDECHO" OLDCMDECHO) (PRINC))
  • I don't think there's a Multiple option for Pedit. You would have to pick an anchor entity and then select all the others. And I don't think it takes fuzz, and whatever that second J means.The filter-list doesn't look right, either -- I thought it's supposed to be a list of all the properties that each item has to have to get in the selection set. I'm surprised that works in Autocad.But here's something similar (minus the fuzz option) that works in Bricscad:

    ;; Join Into polyline - joins a set of contiguous lines, arcs, and/or polylines into a polyline(defun c:JI ()(princ "Join lines, arcs, polylines into a single polyline. ")(sssetfirst nil nil)(setq ent1 nil)(while (= ent1 nil) (setq ent1 (entsel "Pick first entity: ")) )(setq type1 (cdr (assoc 0 ent1) ))(setq ss1 (ssget '((-4 . ""))))(if (= type1 "LWPOLYLINE") (command "Pedit" ent1 "j" ss1 "" ))(if (/= type1 "LWPOLYLINE") (command "Pedit" ent1 "y" "j" ss1 "" ""))(sssetfirst nil (ssget "L")))
  • The code posted above is not complete. The Insert Code Tags feature deleted part of my code. I'll try it this way:;; Join Into polyline - joins a set of contiguous lines, arcs, and/or polylines into a polyline(defun c:JI ()(princ "Join lines, arcs, polylines into a single polyline. ")(sssetfirst nil nil)(setq ent1 nil)(while (= ent1 nil) (setq ent1 (entsel "Pick first entity: ")) )(setq type1 (cdr (assoc 0 ent1) ))(setq ss1 (ssget '((-4 . "<OR") (0 . "LINE") (0 . "ARC") (0 . "LWPOLYLINE") (-4 . "OR>"))))(if (= type1 "LWPOLYLINE") (command "Pedit" ent1 "j" ss1 "" ))(if (/= type1 "LWPOLYLINE") (command "Pedit" ent1 "y" "j" ss1 "" ""))(sssetfirst nil (ssget "L")))

  • That didn't work either.The problem is apparently that my lisp routine includes the word OR, immediately after the less-than symbol, and later on immediately before the greater-than symbol, and apparently everything between the two is being interpreted as some sort of HTML code and is being deleted from my post.I'll try to post it somewhere else and link to it.

  • Oops had extra parts : ) this works in 8.2.8 .. I didn’t try yours Anthony, but I am sure it works well

    (DEFUN C:PJ (/ OBJECT OBJECTNAME OBJTYPE OKOBJECTS OLDCMDECHO SS1) (SETQ OKOBJECTS '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE"))) (PRINC "\nSelect object to join: ") (SETQ OLDCMDECHO (GETVAR "CMDECHO") SS1 (SSGET OKOBJECTS) ) (SETVAR "CMDECHO" 0) (IF (/= SS1 NIL) (PROGN (SETQ OBJECT (ENTGET (SSNAME SS1 0)) OBJECTNAME (CDR (CAR OBJECT)) OBJTYPE (CDR (ASSOC 0 OBJECT)) ) (IF (= (SSLENGTH SS1) 1) (SETQ SS1 (SSGET "X" OKOBJECTS)) ) (IF (MEMBER OBJTYPE '("LINE" "ARC")) (COMMAND "_.pedit" OBJECTNAME "Y" "J" SS1 "" "") (COMMAND "_.pedit" OBJECTNAME "J" SS1 "" "") ) ) ) (SETVAR "CMDECHO" OLDCMDECHO) (PRINC))
  • Sorry. I was wrong about the filter-list. JK's list works and is a lot easier than what I've been doing. Plus it avoids that problem I had with posting code.

    ;; Join Into polyline - joins a set of contiguous lines, arcs, and/or polylines into a polyline.;; Selection window can include inappropriate entities, which are ignored.(defun c:JI ()(princ "Join lines, arcs, polylines into a single polyline. ")(sssetfirst nil nil)(setq ent1 nil)(while (= ent1 nil) (setq ent1 (entsel "Pick first entity: ")) )(setq type1 (cdr (assoc 0 ent1) ))(setq ss1 (ssget '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE"))))(if (= type1 "LWPOLYLINE") (command "Pedit" ent1 "j" ss1 "" ))(if (/= type1 "LWPOLYLINE") (command "Pedit" ent1 "y" "j" ss1 "" ""))(sssetfirst nil (ssget "L")))
  • WOW!! Both of these work fine. Daniel and Anthony, thank you.

This discussion has been closed.