Jump to content
Dani_Nadir

Automatic layout LISP

Recommended Posts

Dani_Nadir

Hello,

 

I am interested in a LISP able to make overlapping sheets as layouts following a road alignment and overlap a fraction. Each sheet will have its own UCS or view orientation. You can see it from these videos:

 

 

 

anyone knows one?

 

Best regards,

Daniel

  • Thanks 1

Share this post


Link to post
Share on other sites
BIGAL

Did you ask this question over at Augi or Theswamp ?

Share this post


Link to post
Share on other sites
Emmanuel Delay
Posted (edited)

I've done similar work. Drawing fiber optics lines along railway tracks. We also made these overlapping viewports. I'll see if I can help

 

 

-----

EDIT

 

Here is a start. It draws the center lines of the viewports.

 

(defun Line (p1 p2)
 (entmakex (list (cons 0 "LINE")
                 (cons 10 p1)
                 (cons 11 p2))))

;; based on @see http://www.lee-mac.com/totallengthandarea.html
(defun totalLengthPolyline ( s / i)
     (setq l 0.0)
     (repeat (setq i (sslength s))
         (setq e (ssname s (setq i (1- i)))
               l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))
         )
     )
  l
)

;;BASED ON @see https://forums.autodesk.com/t5/autocad-forum/lisp-for-placing-a-point-on-polyline/td-p/3782300
;; Par GC - 09/2009 - Version 1.10

(defun PointAtDist2 (dist ss  / result point cnt1 cnt2)
 (vl-load-com)
 (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object))))
 (setq cnt1 0
       cnt2 0
 )
 (if ss
   (progn
     (setq space (vla-get-ModelSpace *acdoc*))
     (vla-StartUndoMark *acdoc*)
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *acdoc*))
       (setq cnt1 (1+ cnt1))
       (if (setq result (vlax-curve-getPointAtDist obj dist))
         (progn
           (setq point result)
           (setq cnt2 (1+ cnt2))
           (if point
             T ;; (vla-AddPoint space (vlax-3d-point result))
           )
         )
       )
     )
     (vla-delete ss)
     (vla-EndUndoMark *acdoc*)
   )
 )
 result   ;; returns the point
)


(defun c:ov2 ( / ss my_dist dist oldpoint newpoint newpoint2 overlap )  ;; ss dist result point cnt1 cnt2
(setq my_dist (getreal "\nViewport length: "))
(setq overlap (getreal "\nOverlap length: "))
;;(setq my_dist 100)
;;(setq overlap 15)
   
 (setq dist my_dist)

 ;; User selects a polyline
(setq ss (ssget (list '(-4 . "<OR") '(0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")
                           '(-4 . "<AND") '(0 . "POLYLINE") '(-4 . "<NOT") '(-4 . "&")
                           '(70 . 112) '(-4 . "NOT>") '(-4 . "AND>") '(-4 . "OR>"))
              )
 )
 (setq oldpoint (PointAtDist2 0 ss))
 (while 
   (and 
     (setq newpoint (PointAtDist2 dist ss))
     (setq newpoint2 (PointAtDist2 (+ dist overlap) ss))
   )
   (progn
     (setq dist (+ dist my_dist ))
     (princ newpoint)
     
     (Line oldpoint newpoint2)
     
     (setq oldpoint newpoint)
     ;;(getstring ".")
   )
 )
 ;; last point at the end
 (setq newpoint (PointAtDist2 (totalLengthPolyline ss) ss))
)

Edited by Emmanuel Delay

Share this post


Link to post
Share on other sites
Dani_Nadir

Hello,

I don't know what you mean.

Share this post


Link to post
Share on other sites
Dani_Nadir
I've done similar work. Drawing fiber optics lines along railway tracks. We also made these overlapping viewports. I'll see if I can help

 

 

-----

EDIT

 

Here is a start. It draws the center lines of the viewports.

 

(defun Line (p1 p2)
 (entmakex (list (cons 0 "LINE")
                 (cons 10 p1)
                 (cons 11 p2))))

;; based on @see http://www.lee-mac.com/totallengthandarea.html
(defun totalLengthPolyline ( s / i)
     (setq l 0.0)
     (repeat (setq i (sslength s))
         (setq e (ssname s (setq i (1- i)))
               l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))
         )
     )
  l
)

;;BASED ON @see https://forums.autodesk.com/t5/autocad-forum/lisp-for-placing-a-point-on-polyline/td-p/3782300
;; Par GC - 09/2009 - Version 1.10

(defun PointAtDist2 (dist ss  / result point cnt1 cnt2)
 (vl-load-com)
 (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object))))
 (setq cnt1 0
       cnt2 0
 )
 (if ss
   (progn
     (setq space (vla-get-ModelSpace *acdoc*))
     (vla-StartUndoMark *acdoc*)
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *acdoc*))
       (setq cnt1 (1+ cnt1))
       (if (setq result (vlax-curve-getPointAtDist obj dist))
         (progn
           (setq point result)
           (setq cnt2 (1+ cnt2))
           (if point
             T ;; (vla-AddPoint space (vlax-3d-point result))
           )
         )
       )
     )
     (vla-delete ss)
     (vla-EndUndoMark *acdoc*)
   )
 )
 result   ;; returns the point
)


(defun c:ov2 ( / ss my_dist dist oldpoint newpoint newpoint2 overlap )  ;; ss dist result point cnt1 cnt2
(setq my_dist (getreal "\nViewport length: "))
(setq overlap (getreal "\nOverlap length: "))
;;(setq my_dist 100)
;;(setq overlap 15)
   
 (setq dist my_dist)

 ;; User selects a polyline
(setq ss (ssget (list '(-4 . "<OR") '(0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")
                           '(-4 . "<AND") '(0 . "POLYLINE") '(-4 . "<NOT") '(-4 . "&")
                           '(70 . 112) '(-4 . "NOT>") '(-4 . "AND>") '(-4 . "OR>"))
              )
 )
 (setq oldpoint (PointAtDist2 0 ss))
 (while 
   (and 
     (setq newpoint (PointAtDist2 dist ss))
     (setq newpoint2 (PointAtDist2 (+ dist overlap) ss))
   )
   (progn
     (setq dist (+ dist my_dist ))
     (princ newpoint)
     
     (Line oldpoint newpoint2)
     
     (setq oldpoint newpoint)
     ;;(getstring ".")
   )
 )
 ;; last point at the end
 (setq newpoint (PointAtDist2 (totalLengthPolyline ss) ss))
)

 

 

Hello,

 

Thanks for replying. When I load the routine, autocad gives me an error: "error: no function definition: p1"

And I can't run the routine.

 

Best regards,

Daniel

Share this post


Link to post
Share on other sites
ramesh patel

how to load this autoviewport application

Share this post


Link to post
Share on other sites
maratovich
22 hours ago, ramesh patel said:

как загрузить это приложение autoviewport

What kind of application?
You mean it - AutoViewport - Automatic creation layouts and viewport
Just download from the site and click install

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×