Jump to content

Recommended Posts

Posted

With where i work, quite often we will need a drawn line or circle at 2 certain points, with extra lines/circles between them at a maximum spacing. IE a roof plan will have a purlin on the edge of each side of the roof, and we will need purlins at a maximum of 1200mm spacing. So what we currently do is draw a line between the first and last prulin, divide by a certain number and hope we get close to 1200, and then copy the object to each point. IS there a lisp routine so if we have our two points, we click them, autocad asks what the maximum spacing is, asks what object we want at that spacing and then does all the work for us. EG: we draw a purlin at the top of the screen, draw a purlin at the bottom. Start lisp, it asks for max spacing, we type in 1200, it asks us what we want to copy, we select the purlin, and it puts purlins at all those points with the maximum 1200 spacing.

 

another lisp i would like is similar to this but not the same, is we normally xref in a floor plan, and draw reinforcement over the top of that. so in a new drawing we will xref in our floor plan. I would like a lisp where we select two vertical lines on the xref, (which in this example are 2400mm apart, and autocad puts in 4 vertical lines the same length, but spaced as - first line 300mm to the right of the left most line, then another line 600mm to the right, then another line 600mm to the right, and the same again. So we will have - xref vert line, 300mm spacing and a new line, 600mm spacing and a new line, 600mm spacing and a new line, another 600mm spacing and a new line, leaving 300mm to the next xref line. ultimately if autocad could ask us for the two vertical xref lines, ask us for the first offset (300) and then how many lines we want, then the last offset ( 300) and it would spread them out evenly. IE start lisp, click on first vert line, input spacing of 300, input i want 4 lines in total, input last ofset as 300) autocad would then work out if i have 300 = 300 offsets, it leaves 1800 mm, and with 3 spacings it knows they have to be 600mm. This probably sounds complicated, i will post up a pic if someone needs it explained better

 

thanks for any help

Posted

This is an old lisp I added prompt for distance. I still use it today.

;;; FUNCTION ObjectOffsetAverage.lsp
;;;  Variation of the Array command, user picks the direction and distance 
;;;  The objects are offset as near as <=24" oc as possiable to fill distance
;;;  with equally spacred objects
;;;  Offset direction angle is 0, 90, 180, or 270 deg only
;;; 
;;; ARGUMENTS 
;;; none 
;;; 
;;; USAGE 
;;;  ooa
;;; 
;;; PLATFORMS 
;;; 2000+ 
;;; 
;;; AUTHOR 
;;; Copyright© 2004 Charles Alan Butler 
;;; ab2draft@TampaBay.rr.com 
;;; 
;;; VERSION 
;;; 1.0 Oct. 01, 2004 
;;; 1.1 Dec. 14, 2008 
;;;
;;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL* 
;;; PURPOSES AND ONLY IF YOU RETAIN 
;;; THIS HEADER COMPLETE AND UNALTERED 
;;; you must contact me if you want to use it commercially 
;;;  

(DEFUN c:ooa (/ p1 p2 ss dist inc step MaxDist)
 (setq usercmd (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (setq useros (getvar "osmode"))
 (setvar "osmode" 175)
 (or OffDist (setq OffDist 24)) ; default offset distance
 (prompt "\nSelect objects to offset.")
 (if (setq ss (ssget))
   (progn    
     (if (and (setq p1 (getpoint "\n*-*  Pick Starting point  *-*"))
       (setq p2 (getpoint p1 "\n*-*  Pick End point  *-*"))
              (null (initget 6))
              (or (setq MaxDist (getdist (strcat "\nEnter Max Distance.<" (rtos OffDist)"> ")))
                  (setq MaxDist OffDist)
              )
         )
    (progn
             (setq OffDist MaxDist)
      (setq dist (distance p1 p2)
            ang  (angle p1 p2)
	    inc	 (fix (1+ (/ dist MaxDist)))
	    step (/ dist inc)
      )
      (cond 
        ((and (>= ang 0.785) (<= ang 2.36)); array up
         (command "_.array" ss "" "R" inc "" step)
        )
        ((and (> ang 2.36) (< ang 3.9)); array left
         (command "_.array" ss "" "R" "" inc (- step))
        )
        ((and (>= ang 3.9) (<= ang 5.5)); array down
         (command "_.array" ss "" "R" inc "" (- step))
        )
        (T  ; array right
         (command "_.array" ss "" "R" "" inc step)
        )
             ) ; end cond stmt
    ) ; end progn
     ) ; endif
   ) ; end progn
 ) ; endif
 ;;==========  Exit Sequence  ============ 
 (setvar "osmode" useros)
 (setvar "CMDECHO" usercmd)
 (princ)
) ; end defun
(prompt "\nOffset Object Average Loaded. Enter ooa to run.")
(princ)

Posted

another lisp i would like is similar to this but not the same, is we normally xref in a floor plan, and draw reinforcement over the top of that. so in a new drawing we will xref in our floor plan. I would like a lisp where we select two vertical lines on the xref, (which in this example are 2400mm apart, and autocad puts in 4 vertical lines the same length, but spaced as - first line 300mm to the right of the left most line, then another line 600mm to the right, then another line 600mm to the right, and the same again. So we will have - xref vert line, 300mm spacing and a new line, 600mm spacing and a new line, 600mm spacing and a new line, another 600mm spacing and a new line, leaving 300mm to the next xref line. ultimately if autocad could ask us for the two vertical xref lines, ask us for the first offset (300) and then how many lines we want, then the last offset ( 300) and it would spread them out evenly. IE start lisp, click on first vert line, input spacing of 300, input i want 4 lines in total, input last ofset as 300) autocad would then work out if i have 300 = 300 offsets, it leaves 1800 mm, and with 3 spacings it knows they have to be 600mm. This probably sounds complicated, i will post up a pic if someone needs it explained better

 

thanks for any help

This is not to difficult IF the xref is not scaled and the lines are vertical.

A picture or DWG with the before lines & then after lines.

Posted

Thanks alot for that code, works a treat :) the second one i want looking like the attached image. The two red lines (horizontal, but are sometimes vertical are the xref. I want a macro to add the cyan lines. The two red lines are 2400 apart, and the first cyan lines inboard are both 300 off the red line, with equally spaced lines between. Id like to be able to select the two red lines, and it automatically put in the 2 outer most lines 300mm off, and then ask for how many more lines we want, and equally space them. Thanks alot for your help

untitled.jpg

Posted

Sorry the photo doesn't have enough contrast or detail for me to see the lines clearly.

  • 5 months later...
Posted

Sorry to dig up this old thread but I have a question for CAB. Is there a way to have that routine include the endpoint? When I run it the spacings are correct but it does not copy anything to the endpoint. Thank you for your help.

Posted

Sure. :)

See new line 54.

;;; FUNCTION ObjectOffsetAverage.lsp
;;;  Variation of the Array command, user picks the direction and distance 
;;;  The objects are offset as near as <=24" oc as possiable to fill distance
;;;  with equally spacred objects
;;;  Offset direction angle is 0, 90, 180, or 270 deg only
;;; 
;;; ARGUMENTS 
;;; none 
;;; 
;;; USAGE 
;;;  ooa
;;; 
;;; PLATFORMS 
;;; 2000+ 
;;; 
;;; AUTHOR 
;;; Copyright© 2004 Charles Alan Butler 
;;; ab2draft@TampaBay.rr.com 
;;; 
;;; VERSION 
;;; 1.0 Oct. 01, 2004 
;;; 1.1 Dec. 14, 2008 
;;; 1.1a May 19, 2009 
;;;
;;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL* 
;;; PURPOSES AND ONLY IF YOU RETAIN 
;;; THIS HEADER COMPLETE AND UNALTERED 
;;; you must contact me if you want to use it commercially 
;;;  

(DEFUN c:ooa (/ p1 p2 ss dist inc step MaxDist)
 (setq usercmd (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (setq useros (getvar "osmode"))
 (setvar "osmode" 175)
 (or OffDist (setq OffDist 24)) ; default offset distance
 (prompt "\nSelect objects to offset.")
 (if (setq ss (ssget))
   (progn    
     (if (and (setq p1 (getpoint "\n*-*  Pick Starting point  *-*"))
       (setq p2 (getpoint p1 "\n*-*  Pick End point  *-*"))
              (null (initget 6))
              (or (setq MaxDist (getdist (strcat "\nEnter Max Distance.<" (rtos OffDist)"> ")))
                  (setq MaxDist OffDist)
              )
         )
    (progn
             (setq OffDist MaxDist)
      (setq dist (distance p1 p2)
            ang  (angle p1 p2)
	    inc	 (fix (1+ (/ dist MaxDist)))
	    step (/ dist inc)
      )
             (setq inc (1+ inc)) ; adds one object to the end of the array
      (cond 
        ((and (>= ang 0.785) (<= ang 2.36)); array up
         (command "_.array" ss "" "R" inc "" step)
        )
        ((and (> ang 2.36) (< ang 3.9)); array left
         (command "_.array" ss "" "R" "" inc (- step))
        )
        ((and (>= ang 3.9) (<= ang 5.5)); array down
         (command "_.array" ss "" "R" inc "" (- step))
        )
        (T  ; array right
         (command "_.array" ss "" "R" "" inc step)
        )
             ) ; end cond stmt
    ) ; end progn
     ) ; endif
   ) ; end progn
 ) ; endif
 ;;==========  Exit Sequence  ============ 
 (setvar "osmode" useros)
 (setvar "CMDECHO" usercmd)
 (princ)
) ; end defun
(prompt "\nOffset Object Average Loaded. Enter ooa to run.")
(princ)

Posted

I am doing an internship this summer and this command is very useful to me. Do you mind if I run this while at work or would that be considered "comercial use"?

 

Thank you.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...