Regards @onlineoffers1988
True something similar to what you require @hak_vz , already did. In an automated way with just one selection. You just have to take your time to search.
For the moment edit your code to get something similar to what you require. Of course, it is just an idea that can be improved much more.
Please follow the selection procedure explained in the video.
;;https://www.cadtutor.net/forum/topic/21484-i-search-for-offset-with-same-value-and-opposite-direction/#comment-175406
(defun c:HomeRun ( / MyLineSS of MyBlockSS BlockSelected acount side offset myline mln mypoints)
;;Edit for Calderg1000, 20-11-22
;;Undo
(defun *error* ( msg )
(and undo (vla-EndUndomark doc))
(or
(wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
;;;-------------------------------------------------------------------------------------
;; Loop layers selection
;;Select Route
(princ "\nSelect Home Run Route ")
(setq MyLineSS (ssget "_+.:E:S" '((0 . "*LINE") ) ))
(command "_.fillet" "_polyline" (entlast));;----------------------------------nnn
;;Get Offset
;;(setq of 2.5) ; default offset, 2.5. Maybe work out as fraction of line length
(setq of (getdist "\nSpecify Distance between Lines: ")) ; User selects distance
;;Get blocks
;;Select Route
(princ "\nSelect one Block from every circuit ")
(setq MyBlockSS (ssget '((0 . "INSERT"))))
(setq BlockSelected (sslength MyBlockSS) )
;; Do Offset
(setq acount 1) ;; 1 so that it draws correct no of lines
(setq side 1)
(while (< acount (sslength MyBlockSS))
;;; (setq offset (* acount of side) )
(setq offset of)
(setq VlaOb (vlax-ename->vla-object (ssname MyLineSS ( - acount 1))))
(vla-offset VlaOb offset ) ;; offset line 1
(setq MyLineSS (ssadd (entlast) MyLineSS)) ;; add offset to selection set
(command "_.fillet" "_polyline" (entlast));;;------------------------------nnn
;;; (setq side (* side -1))
(setq side (* side 1))
(setq acount (+ acount 1))
) ; end while
;;; (setq MyLine (ssname MyLineSS 0))
(setq acount 0)
(setq MyPoints (list))
(while (< acount (sslength MyBlockSS))
(setq MyPoints (append MyPoints (list (cdr (assoc 10 (entget (ssname MyBlockSS acount))))) ))
(setq acount (+ 1 acount))
)
(repeat(setq i(sslength MylineSS))
(setq mln(ssname MylineSS (setq i(1- i))))
(setq myline(cons mln myline))
)
;;; (setq myline(reverse myline))
(perp2ent myline MyPoints)
;;Finish
(vla-EndUndoMark doc)
(princ)n
);;defun
;;;-------------------------------------------------------------------
(defun perp2ent (Myline MyPoints / acount pt lt ptp ang)
(setq acount 0)
(while (< acount (length MyPoints))
(setq pt (nth acount MyPoints))
(setq lt (nth acount Myline))
(setq ptp (vlax-curve-getClosestPointTo lt (trans pt 1 0)))
(setq ang (angle pt ptp))
(if
(or (= ang 0) (= ang (* 0.5 pi)) (= ang (* 1.5 pi)))
(progn
(entmake (list '(0 . "LINE")
(cons 10 (trans pt 1 0))
(cons 11 ptp)
) ;_ list
) ;_ entmake
;;;----------------------------------------
(command "_.break"
(ssadd lt)
(vlax-curve-getClosestPointTo lt (trans pt 1 0))
"@"
)
(command "erase" (entlast) "")
(setq acount (+ acount 1))
) ;progn1
;;;----------------------------------------
(progn
(entmake (list '(0 . "LINE")
(cons 10 (trans pt 1 0))
(cons 11 (list (car pt) (cadr ptp))) ;_ list
)
)
(entmake (list '(0 . "LINE")
(cons 10 (list (car pt) (cadr ptp)))
(cons 11 ptp)
) ;_ list
)
(command "_.break"
(ssadd lt)
(vlax-curve-getClosestPointTo lt (trans pt 1 0))
"@"
)
(command "erase" (entlast) "")
(setq acount (+ acount 1))
;;;---------------------------------------
) ;progn2
) ;if
) ;_ while
(princ)
)
Carlos Calderon G

>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.