Thanks! If I have a selection set, then join whatever entities can be joined, and I then want to get an updated selection set (including all the original entities that couldn't be joined, plus the newly made polylines), I'm thinking this would be the general process:
; get current or prompt for selection set
(setq ss1 (ssget '((0 . "LINE,ARC,*POLYLINE,CIRCLE"))))
;;; HERE
; get list of entities in selection set
; get 1 pt from each entity
(polylineJoin ss1)
; make new selection set using list of points
; remove duplicates (should return list of all entities to then offset)
Any suggestions or ideas for functions that might be helpful?
Note this is the version of your polylineJoin function I'm using (modified slightly):
(defun polylineJoin
(pjss / *error* doc svn svv nextent pjinit inc edata pjent)
; VARLIST
;; INPUTS
;;; pjss - input selection set, must be filered before inputting: '((0 . "LINE,ARC,*POLYLINE")) (PICKSET)
;; LOCAL VARS
;;; *error* - local error handling function (SYM)
;;; doc - AutoCAD active document, for purposes of end/start undo mark (VLA-OBJECT)
;;; svn - system variable names (LIST)
;;; svv - system variable values (LIST)
;;; nextent - entity used as starting point to check for new entities to join (ENAME)
;;; pjinit - initial number starting for loop (INT)
;;; inc - for loop incrementer (INT)
;;; edata - entity definition data, for purposes of removing invalid entities or fixing joined entities (ASSOC LIST)
;;; pjent - entity to be deleted from selection set if invalid shape (ENAME)
; general error handling
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
)
; reset system variables, end undo, exit quietly
(mapcar 'setvar svn svv)
(vla-endundomark doc)
(princ)
)
; if there is a valid selection set
(if pjss
(progn
; start undo mark
(vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
; get initial system vars and next joining entity reference
(setq
svn '(cmdecho peditaccept)
svv (mapcar 'getvar svn)
nextent (entlast)
)
; loop through selection set
(repeat (setq pjinit (sslength pjss) inc pjinit)
; remove any 2D "heavy", 3D polylines, or splined/fitted 2D lines from selection set
(if
(and
(=
(cdr (assoc 0 (setq edata (entget (setq pjent (ssname pjss (setq inc (1- inc))))))))
"POLYLINE" ; 2D "heavy" or 3D Polyline
)
(=
(= (cdr (assoc 100 (reverse edata))) "AcDb3dPolyline"); 3D
(member (boole 1 6 (cdr (assoc 70 edata))) '(2 4)); splined or fitted 2D
)
)
(ssdel pjent pjss)
)
)
; turn off command echo, turn on peditaccept
(mapcar 'setvar svn '(0 1))
; in case of older polylines (extreme edge case)
(setvar 'plinetype 2)
; if the remaining selection set is valid
(if pjss
; join entities based on different scenarios
(cond
( (= pjinit (sslength pjss) 1); selected only one, and it qualifies
(command "_.pedit" pjss "_join" "_all" "" ""); join everything possible to it
); single-selection condition
( (> (sslength pjss) 1); more than one qualifying object
(command "_.pedit" "_multiple" pjss "" "_join" "0.0" "")
); multiple qualifying condition
((prompt "\nSingle object not viable, or no more than 1 of multiple selection viable."))
)
; else
(prompt "\nNothing viable selected.")
)
; look through entities in selection set to set arcs/lines back to arcs/lines (may have gotten converted to plines)
(while (setq nextent (entnext nextent))
(setq edata (entget nextent))
(if
(and
(= (cdr (assoc 90 edata)) 2)
(not (vlax-curve-isClosed nextent))
)
(command "_.explode" nextent)
)
)
; reset system vars, end undo mark
(mapcar 'setvar svn svv)
(vla-endundomark doc)
)
(prompt "\nNo qualifying object(s) selected.")
)
(princ)
)