Jump to content

Multiple lines with user input..


2andygs

Recommended Posts

Hi Guys... can some one help me to develop a lisp...

I need to draw multiple lines with user input

 

Ex. Length, Number of lines, offset size

 

also need draw vertical lines both ends 1/16" inside...

 

I have attached Image as an example

 

Thanks in advance....

STRIPS.jpg

Link to comment
Share on other sites

I will try to find, did something like this previously using simple input of 50,4,-25

50 = length

4 is number required

-25 offset is +/- for right/left

 

I will keep looking found this same idea.

; copy multiple objects along x or y axis
; use 2x40 etc

Link to comment
Share on other sites

Here you go:

 

(defun C:test ( / p1 p2 off n a d f p )
 (and
   (cond 
     ( (and *MtpLines* (setq p1 (getpoint "\nSpecify base point <new line>: ")))
       (mapcar '(lambda (x) (set x (cdr (assoc x *MtpLines*)))) '(d a))
       (setq p2 (polar p1 (- a (* 0.5 PI)) d))
     )
     (
       (and
         (setq p1 (getpoint "\nSpecify line's length: "))
         (setq p2 (getpoint "\nSpecify line's length: " p1))
       )
     )
   ); cond
   (not (grdraw p1 p2 1 1))
   
   (setq off (cond ( (progn (initget 6) (getdist (strcat "\nSpecify offset " (if (setq off (cdr (assoc 'off *MtpLines*))) (strcat "<" (rtos off 2 15) ">") "") ": "))) ) ( off )))
   (setq n (cond ( (progn (initget 6) (getint (strcat "\nSpecify number of lines " (if (setq n (cdr (assoc 'n *MtpLines*))) (strcat "<" (itoa n) ">") "") ": "))) ) ( n )))
   
   (or a (setq a (+ (angle p1 p2) (* 0.5 PI))))
   (or d (setq d (distance p1 p2)))
   (setq f '((p a d) (entmakex (list '(0 . "LINE") (cons 10 p) (cons 11 (polar p a d))))))
   (setq p p1)
   (progn
     (redraw)
     (repeat n 
       (f p (angle p1 p2) d)
       (setq p (polar p a off))
     )
     (
       '(( / ed pt1 pt2 dst )
         (setq ed 6.)
         (setq pt1 (polar p1 a (- ed)))
         (setq pt2 (polar p2 a (- ed)))
         (setq dst (+ (- (distance p1 p) off) (* 2. ed)))
         (f (polar pt1 (angle p1 p2) ed) a dst )
         (f (polar pt2 (angle p1 p2) (- ed)) a dst )
       )
     )
     (setq *MtpLines* (mapcar '(lambda (x) (cons x (eval x))) '(d a off n)))
   ); progn
 ); and
 (princ)
); defun

Link to comment
Share on other sites

Thanks for code...it works some what but it's kind of confusing and does not work as i expected.. can you please change user input as follows and also Define start point to auto @ 0,0 and length going horizontally

 

1. Enter total Length of the strip (ex 100")

2. Enter Vertical offset length (both vertical line at each end) (ex 0.25")

3. Enter horizontal offset distance (ex 5")

4. Enter number of lines to offset (ex 10)

 

I have attached the example sketch with above values... hope this info is good enough

 

Thanks again

STRIPS.jpg

Link to comment
Share on other sites

This may be useful and includes the ability to have default values, this matches your input just press Ok. I think though it would be better like Grrr to pick the bottom left point its not hard to type 0,0

 

;Multi line with offsets
; by Alan H Feb 2018
(defun ah:mult ( / pt1 pt2 pt3 pt4 num voff len hor)
(if (not ah:getval4)(load "getvals4"))
(ah:getval4 "Total Length" 5 4 "100" "Vertical offset" 5 4 "10" "Horizontal offset" 5 4 "0.25" "Number of lines"5 4 "10")
(setq len (atof val1)
voff (atof val2)
hor (atof val3)
num (- (atoi val4) 1)
)

(SETQ ANGBASEE (GETVAR "ANGBASE"))
(SETQ ANGDIRR (GETVAR "ANGDIR"))
(SETQ AUNITSS (GETVAR "AUNITS"))
(setq oldsnap (getvar 'osmode))

(setvar 'osmode 0)
(SETVAR "ANGBASE" 0.0)
(SETVAR "ANGDIR" 0)
(SETVAR "AUNITS" 3)


(setq pt1 (list 0 0))
(setq pt2 (polar pt1 pi hor))
(setq pt3 (polar pt1 0.0 (+ len hor)))
(entmakex (list '(0 . "LINE") (cons 10 pt2) (cons 11 pt3)))

(Command "-array" "l" ""  "R" (+ 1 num) 1 voff)

(setq pt2 (list (car pt1) (- (cadr pt1) hor)))
(setq pt3 (list (car pt1)(+ (+ (cadr pt1) (* num voff)) hor)))
(entmakex (list '(0 . "LINE") (cons 10 pt2) (cons 11 pt3)))

(command "copy" "L" "" (list 0 0)(list len 0))

(SETVAR "ANGBASE" angbasee)
(SETVAR "ANGDIR" angdirr)
(SETVAR "AUNITS" aunitss)

)
(ah:mult)

Getvals4.lsp

ScreenShot110.jpg

Edited by BIGAL
Link to comment
Share on other sites

  • 3 weeks later...

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...