Jump to content
2andygs

Multiple lines with user input..

Recommended Posts

2andygs

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

Share this post


Link to post
Share on other sites
ronjonp

This sounds like a task for a dynamic block.

Share this post


Link to post
Share on other sites
Grrr

Where should be located the base point?

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
2andygs

0,0 or anywhere it's not critical

Share this post


Link to post
Share on other sites
2andygs
Where should be located the base point?

 

0,0 or anywhere it's not critical

Share this post


Link to post
Share on other sites
Grrr

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

Share this post


Link to post
Share on other sites
2andygs

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

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
2andygs

Thanks a lot... works

Share this post


Link to post
Share on other sites
2andygs

Thanks again for the code... Need a minor change ... after pressing escape key still drawing the lines... can you please fix this

Share this post


Link to post
Share on other sites
2andygs

one more thing... change to accept 6 numbers, i can only enter 4 number now (ex length to accept 1000.5)

Share this post


Link to post
Share on other sites
BIGAL

Why press esc do you want a cancel in DCL ? Can make Ok Cancel

 

Just change the dcl numbers "Total Length" 5 4 this is roughly display 5 input 4 so "Total Length" 10 9

Share this post


Link to post
Share on other sites
2andygs

Why press esc do you want a cancel in DCL ? Can make Ok Cancel

 

YES, PLEASE ADD CANCEL IN DCL

Share this post


Link to post
Share on other sites
BIGAL

Good time to learn about DCl just google "OK_Cancel_Help" I have to look it up myself, its in the help somewhere but I use an old reference book but its at home.

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

×