See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: automatically drawn centerlines

  1. #1
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default automatically drawn centerlines

    Is there a way to write a program so that it will find all of the 4-sided polylines on a particular layer, and draw a centerline parallel with the long sides of the polylines? there would potentially be hundreds of closed polylines to draw centerlines on.

    I have an example file I am trying to upload, but it keeps telling me it exceeds my limit. It's only 53kb, and I don't know how to delete the old files I've had in the forum from years ago.

    centerline.dwg

    EDIT: Example file attached.
    Last edited by james.126519; 2023-01-30 at 05:50 PM.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Create a new drawing, draw your example before and after, wblock that to a new drawing. You may need to place the new drawing into a compressed folder. You shouldn't but you might. Upload the zip file.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    When I go to upload, it says I am using 12.28MB of my 10MB limit. They are all old files from other threads, many years old. I just can not see any option to delete the old files and clear up some room.

    I tried compressing the file, and it still gives me the same message.

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Quote Originally Posted by james.126519 View Post
    When I go to upload, it says I am using 12.28MB of my 10MB limit. They are all old files from other threads, many years old. I just can not see any option to delete the old files and clear up some room.

    I tried compressing the file, and it still gives me the same message.
    You can go in and delete old attachments in the "Forum Actions""My Settings" tab above the page
    Attached Images Attached Images

  5. #5
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Quote Originally Posted by tedg View Post
    You can go in and delete old attachments in the "Forum Actions""My Settings" tab above the page
    Thank you! I updated the original post with the example file.

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Hi,
    You did not show the where you would like to locate the centerline on 4 sides polylines in your drawing. !
    Will it be on the two longest segments center point or in the center of rectangle ?

  7. #7
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Quote Originally Posted by Tharwat View Post
    Hi,
    You did not show the where you would like to locate the centerline on 4 sides polylines in your drawing. !
    Will it be on the two longest segments center point or in the center of rectangle ?
    The red lines on the layer EPCENTER are the lines I would want added to the drawing. The drawing would already have the yellow polylines created. The centerlines would have to be lines on the EPCENTER layer.

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: automatically drawn centerlines

    Hopefully this is the one you are after.

    Code:
    (defun c:Test (/ int sel ent pts pt1 pt2 pt3 pt4 sg1 sg2 1pt 2pt )
      ;;----------------------------------------------------;;
      ;;	Author : Tharwat Al Choufi			;;
      ;; website: https://autolispprograms.wordpress.com	;;
      ;;----------------------------------------------------;;
      (and (princ "\nSelect closed polylines to draw centerline on longest segment : ")
           (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
           (while (setq int (1+ int) ent (ssname sel int))
             (foreach itm (entget ent)
               (and (= (car itm) 10)
                    (setq pts (cons (cdr itm) pts))
                    )
               )
             (mapcar 'set '(pt1 pt2 pt3 pt4) pts)
             (and (equal (distance pt1 pt3) (distance pt2 pt4) 1e-2)
                  (or (and (> (setq sg1 (distance pt1 pt2)) (setq sg2 (distance pt2 pt3)))
                           (setq 1pt (polar pt2 (angle pt2 pt3) (/ sg2 2.0))
                                 2pt (polar pt1 (angle pt1 pt4) (/ sg2 2.0))
                                 )
                           )
                      (setq 1pt (polar pt1 (angle pt1 pt2) (/ sg1 2.0))
                            2pt (polar pt3 (angle pt3 pt4) (/ sg1 2.0))
                            )
                      )
                  (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0)
                                 '(8 . "EPCENTER") (cons 10 1pt) (cons 10 2pt))))
             (setq pts nil)
             )
           )
      (princ)
      )

  9. #9
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Quote Originally Posted by Tharwat View Post
    Hopefully this is the one you are after.

    Code:
    (defun c:Test (/ int sel ent pts pt1 pt2 pt3 pt4 sg1 sg2 1pt 2pt )
      ;;----------------------------------------------------;;
      ;;	Author : Tharwat Al Choufi			;;
      ;; website: https://autolispprograms.wordpress.com	;;
      ;;----------------------------------------------------;;
      (and (princ "\nSelect closed polylines to draw centerline on longest segment : ")
           (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
           (while (setq int (1+ int) ent (ssname sel int))
             (foreach itm (entget ent)
               (and (= (car itm) 10)
                    (setq pts (cons (cdr itm) pts))
                    )
               )
             (mapcar 'set '(pt1 pt2 pt3 pt4) pts)
             (and (equal (distance pt1 pt3) (distance pt2 pt4) 1e-2)
                  (or (and (> (setq sg1 (distance pt1 pt2)) (setq sg2 (distance pt2 pt3)))
                           (setq 1pt (polar pt2 (angle pt2 pt3) (/ sg2 2.0))
                                 2pt (polar pt1 (angle pt1 pt4) (/ sg2 2.0))
                                 )
                           )
                      (setq 1pt (polar pt1 (angle pt1 pt2) (/ sg1 2.0))
                            2pt (polar pt3 (angle pt3 pt4) (/ sg1 2.0))
                            )
                      )
                  (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0)
                                 '(8 . "EPCENTER") (cons 10 1pt) (cons 10 2pt))))
             (setq pts nil)
             )
           )
      (princ)
      )
    I don't know what you drink, but I owe you one!

  10. #10
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: automatically drawn centerlines

    Quote Originally Posted by james.126519 View Post
    I don't know what you drink, but I owe you one!

    Its my secret so you can donate me one from HERE if you like.

Page 1 of 2 12 LastLast

Similar Threads

  1. I want to relinquish things automatically just as I own things automatically
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 2
    Last Post: 2012-06-25, 06:44 PM
  2. Russian standart (GOST) want elbow centerlines made as centerlines
    By Wish List System in forum Inventor Wish List
    Replies: 0
    Last Post: 2012-01-13, 01:21 PM
  3. Replies: 0
    Last Post: 2009-05-01, 03:25 PM
  4. Replies: 4
    Last Post: 2008-04-30, 03:35 PM
  5. Window Centerlines
    By philipnoland in forum Revit Architecture - General
    Replies: 2
    Last Post: 2005-10-14, 11:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •