Author Topic: [help] centerline 2 doubleline, Automatic break ?  (Read 1738 times)

0 Members and 1 Guest are viewing this topic.

wll85

  • Guest
[help] centerline 2 doubleline, Automatic break ?
« on: July 24, 2010, 04:17:36 AM »
 :-)  thx .

Lee Mac

  • Seagull
  • Posts: 12292
  • London, England
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #1 on: July 24, 2010, 10:19:20 AM »
Post what code you have, and we can help you towards a solution.

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #2 on: July 24, 2010, 10:58:46 AM »
Didn't Luis do something like this?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

LE3

  • Guest
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #3 on: July 24, 2010, 11:03:23 AM »
Didn't Luis do something like this?
Yes, I think that guy did something similiar, but remember it was without the curves implementation, as far I recall.

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #4 on: July 24, 2010, 11:04:32 AM »
Didn't Luis do something like this?
Yes, I think that guy did something similiar, but remember it was without the curves implementation, as far I recall.
LoL
Your predecessor, LE?  :lmao:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

LE3

  • Guest
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #5 on: July 24, 2010, 11:05:49 AM »
Didn't Luis do something like this?
Yes, I think that guy did something similiar, but remember it was without the curves implementation, as far I recall.
LoL
Your predecessor, LE?  :lmao:
Yep, that's the one.... the routine it is named AutoWalls, btw :)

Lee Mac

  • Seagull
  • Posts: 12292
  • London, England
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #6 on: July 24, 2010, 01:52:15 PM »
I suppose you could cheat  :evil:


alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #7 on: July 24, 2010, 01:59:35 PM »
And it begins.... :lmao:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12292
  • London, England
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #8 on: July 24, 2010, 02:19:10 PM »

Lee Mac

  • Seagull
  • Posts: 12292
  • London, England
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #9 on: July 24, 2010, 02:54:04 PM »
I shan't tease...

Code: [Select]
(defun c:bound ( / *error* var old ss objs lst poly bbox )
  (vl-load-com)
  ;; Lee Mac 2010

  (defun *error* ( msg )
    (and old (mapcar 'setvar var old))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (setq var '("CMDECHO" "OSMODE") old (mapcar 'getvar var))
  (mapcar 'setvar var '(0 0))

  (if (and
        (ssget "_:L" '((0 . "~VIEWPORT,~*TEXT")))
        (setq *off*
          (cond
            (
              (getdist
                (strcat "\nSpecify Width <"
                  (rtos
                    (setq *off*
                      (cond ( *off* ) ( 1.0 ))
                    )
                  )
                  "> : "
                )
              )
            )
            ( *off* )
          )
        )
      )
    (progn
      (vlax-for o
        (setq ss
          (vla-get-ActiveSelectionSet
            (vla-get-ActiveDocument
              (vlax-get-acad-object)
            )
          )
        )
        (setq objs
          (cons
            (apply 'append
              (vl-remove-if 'vl-catch-all-error-p             
                (mapcar
                  (function
                    (lambda ( x )
                      (vl-catch-all-apply 'vlax-invoke (list o 'offset x))
                    )
                  )
                  (list *off* (- *off*))
                )
              )
            )
            objs
          )
        )
      )
      (vla-delete ss)
     
      (setq lst
        (apply 'append
          (mapcar
            (function
              (lambda ( os / s )
                (if (not (vlax-curve-isClosed (car os)))
                  (append
                    (list
                      (vlax-ename->vla-object
                        (entmakex
                          (list
                            (cons 0 "LINE")
                            (cons 10 (vlax-curve-getStartPoint (car os)))
                            (cons 11 (vlax-curve-getStartPoint (cadr os)))
                          )
                        )
                      )
                      (vlax-ename->vla-object
                        (entmakex
                          (list
                            (cons 0 "LINE")
                            (cons 10 (vlax-curve-getEndPoint (car os)))
                            (cons 11 (vlax-curve-getEndPoint (cadr os)))
                          )
                        )
                      )
                    )
                    os
                  )
                  os
                )
              )
            )
            (vl-remove nil objs)
          )
        )
      )
      (setq Poly
        (LWPoly
          (setq bbox
            (LM:BBox->List
              (apply '(lambda ( ll ur / d ) (setq d (* 0.1 (distance ll ur)))
                        (list (polar ll (angle ll ur) (- d))
                              (polar ur (angle ll ur)    d )
                        )
                      )
                (LM:GetBoundingBox lst)
              )
            )
          )
          1
        )
      )

      (
        (lambda ( s )
          (mapcar '(lambda ( x ) (ssadd x s)) (cons poly (mapcar 'vlax-vla-object->ename lst)))
        )
        (setq ss (ssadd))
      )
     
      (vl-cmdf "_.-boundary" "_A" "_I" "_Y" "_B" "_N" ss "" ""
        (polar (car bbox) (angle (car bbox) (caddr bbox)) (* 0.01 (distance (car bbox) (caddr bbox)))) ""
      )
      (mapcar 'vla-delete lst)
      (entdel poly)
      (if (setq tmp (car (nentselp (car bbox))))
        (entdel tmp)
      )
    )
  )

  (mapcar 'setvar var old)
  (princ)
)


(defun LM:GetBoundingBox ( lst / ent ll ur bBoxs )
  ;; Lee Mac 2010

  (setq bBoxs
    (apply 'append
      (mapcar
        (function
          (lambda ( x / ll ur )
            (vla-GetBoundingBox x 'll 'ur)

            (list (vlax-safearray->list ll) (vlax-safearray->list ur))
          )
        )
        lst
      )
    )
  )

  (mapcar
    (function
      (lambda ( operation )
        (apply (function mapcar) (cons operation bBoxs))
      )
    )
    '(min max)
  )
)


(defun LM:BBox->List ( bbox )
  ;; Lee Mac 2010
  (mapcar
    (function
      (lambda ( funcs )
        (mapcar
          (function
            (lambda ( func ) ((eval func) bbox))
          )         
          funcs
        )
      )
    )   
    '((caar  cadar)  (caadr cadar)
      (caadr cadadr) (caar  cadadr))
  )
)

(defun LWPoly ( lst cls )
  (entmakex
    (append
      (list
        (cons 0 "LWPOLYLINE")
        (cons 100 "AcDbEntity")
        (cons 100 "AcDbPolyline")
        (cons 90 (length lst))
        (cons 70 cls)
      )
      (mapcar '(lambda ( p ) (cons 10 p)) lst)
    )
  )
)

RGUS

  • Newt
  • Posts: 95
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #10 on: July 24, 2010, 04:06:38 PM »
Hehehehe.... trust you Lee to come up with something... that well... just works!

Lee Mac

  • Seagull
  • Posts: 12292
  • London, England
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #11 on: July 24, 2010, 07:05:43 PM »
Hehehehe.... trust you Lee to come up with something... that well... just works!

Thanks - I'm glad it works for you - it is a touch cheating using the boundary command, but without it the code would probably be a lot lot longer...  :|

LE3

  • Guest
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #12 on: July 24, 2010, 08:01:49 PM »
Hehehehe.... trust you Lee to come up with something... that well... just works!

Thanks - I'm glad it works for you - it is a touch cheating using the boundary command, but without it the code would probably be a lot lot longer...  :|

did this little mickey mouse vlisp, by drawing the same items as the first post, the only condition is to convert those to lwpolylines and join them before calling the routine,
see if works or if it is useful:

wll85

  • Guest
Re: [help] centerline 2 doubleline, Automatic break ?
« Reply #13 on: July 25, 2010, 08:02:57 PM »
Lee Mac ,thanks your "bound" idea!  :wink:

LE3 ,thanks for share your way to get it,it works.  :-)