Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/21/2019 in all areas

  1. Probably AI , ET , Quantum computer , Google Maps or TomTom would be best for your need but found a few routines that may or may not help you. Have zero experience with this sort of stuf and none of the code is mine so in case of questions ask the authors... Don't think any of them offer one click and score but you could try to select one branch at the time and join them as you see fit. ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-polyline-across-multiple-center-points/m-p/8041066 (defun c:connect ( / ss i e plist p nextpt plist-sorted rtn pp ) (while (or (prompt "\nSelect blocks or circles...") (not (setq ss (ssget '((0 . "INSERT,CIRCLE")))))) (prompt "\nEmpty sel. set...") ) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i)))) (setq plist (cons (cdr (assoc 10 (entget e))) plist)) ) (setq p (getpoint "\nPick or specify start point - use osnap cen or ins : ")) (defun nextpt ( p plist / car-sort pp ) (defun car-sort ( l f / removenth r k ) (defun removenth ( l n / k ) (setq k -1) (vl-remove-if '(lambda ( x ) (= (setq k (1+ k)) n)) l) ) (setq k -1) (vl-some '(lambda ( a ) (setq k (1+ k)) (if (vl-every '(lambda ( x ) (apply f (list a x))) (removenth l k)) (setq r a))) l) r ) (setq plist (vl-remove-if '(lambda ( x ) (equal x p 1e-3)) plist)) (setq pp (car-sort plist '(lambda ( a b ) (<= (distance p a) (distance p b))))) (list pp plist) ) (if p (progn (while (cadr plist) (setq plist-sorted (cons p plist-sorted)) (setq rtn (nextpt p plist)) (setq pp (car rtn) plist (cadr rtn)) (setq p pp) ) (setq plist-sorted (cons (car plist) plist-sorted)) (setq plist-sorted (reverse plist-sorted)) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length plist-sorted)) (cons 70 (if (= 1 (getvar 'plinegen)) 128 0)) '(38 . 0.0) ) (mapcar '(lambda ( p ) (cons 10 p)) plist-sorted) (list '(210 0.0 0.0 1.0)) ) ) ) ) (princ) ) (defun c:CreateShortPath (/ GetMidPoints SortPointList CSP_Point CSP_Selection CSP_PointList) (defun GetMidPoints (GMP_Selection / GMP_Object GMP_Point1 GMP_Point2 GMP_Return) (if (and (= (type GMP_Selection) 'PICKSET) (> (sslength GMP_Selection) 0) ) (progn (foreach GMP_Object (vl-remove-if '(lambda (GMP_Item) (listp (cadr GMP_Item))) (ssnamex GMP_Selection)) (if (vlax-method-applicable-p (setq GMP_Object (vlax-ename->vla-object (cadr GMP_Object))) 'GetBoundingBox) (progn (vla-GetBoundingBox GMP_Object 'GMP_Point1 'GMP_Point2) (setq GMP_Return (cons (mapcar '(lambda (GMP_Value1 GMP_Value2) (/ (+ GMP_Value1 GMP_Value2) 2.0)) (vlax-safearray->list GMP_Point1) (vlax-safearray->list GMP_Point2)) GMP_Return ) ) ) ) ) ) ) GMP_Return ) (defun SortPointList (SPL_PointList / SPL_Point SPL_Return) (setq SPL_PointList (vl-sort SPL_PointList '(lambda (SPL_Item1 CSPCSP_Item2)(< (distance SPL_Item1 (car SPL_PointList))(distance CSPCSP_Item2 (car SPL_PointList)))))) (repeat (length SPL_PointList) (setq SPL_Return (cons (setq SPL_Point (car SPL_PointList)) SPL_Return)) (setq SPL_PointList (cdr SPL_PointList)) (setq SPL_PointList (vl-sort SPL_PointList '(lambda (SPL_Item1 CSPCSP_Item2)(< (distance SPL_Item1 SPL_Point)(distance CSPCSP_Item2 SPL_Point))))) ) (reverse SPL_Return) ) (if (and (setq CSP_Selection (ssget)) (setq CSP_Point (getpoint "\nIndicate startpoint: ")) ) (progn (setq CSP_PointList (SortPointList (cons CSP_Point (GetMidPoints CSP_Selection)))) (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length CSP_PointList)) (cons 70 (if (= 1 (getvar 'PLINEGEN)) 128 0)) '(38 . 0.0) ) (mapcar '(lambda (CSP_Item) (cons 10 CSP_Item)) CSP_PointList) (list '(210 0.0 0.0 1.0)) ) ) (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) ) ) (princ) ) (defun c:path (/ _daisychain a ll p pt s ur) ;; RJP - 6.1.2018 ;; Creates a path using the midpt of bounding box of blocks (defun _daisychain (pt l / tmp out dsort) (defun dsort (pt l / d1 d2) (vl-sort l (function (lambda (d1 d2) (< (distance pt d1) (distance pt d2))))) ) (setq tmp (dsort pt l)) (while (setq tmp (dsort (car tmp) tmp)) (setq out (cons (car tmp) out)) (setq tmp (cdr tmp))) (reverse out) ) (cond ((and (setq p (getpoint "\nPick point to sort from: ")) (setq s (ssget '((0 . "insert") (2 . "Poste_Concreto")))) (setq s (mapcar '(lambda (x) (vla-getboundingbox (vlax-ename->vla-object x) 'll 'ur) (mapcar '(lambda (a) (/ a 2.)) (apply 'mapcar (cons '+ (mapcar 'vlax-safearray->list (list ll ur)))) ) ;; If your block had an insertion point at the center of the circle then the line below would be enough ;; (vlax-get x 'insertionpoint) ) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) ) ) (setq s (_daisychain p s)) ) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(8 . "Netell-Aerial-Network_Authorized (Real-Built)") (cons 90 (length s)) '(38 . 0.0) ) (mapcar '(lambda (x) (cons 10 x)) s) (list '(210 0.0 0.0 1.0)) ) ) ) ) (princ) ) (vl-load-com)
    1 point
  2. I think you would be better doing the connecting up manually. There are a lot of RE coded points, but how would a programme know which side of the road they represent? and where to join up at a junction?
    1 point
×
×
  • Create New...