Jump to content

Recommended Posts

Posted

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

Posted

This sounds like a task for a dynamic block.

Posted

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

Posted
Where should be located the base point?

 

0,0 or anywhere it's not critical

Posted

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

Posted

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

Posted (edited)

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
  • 3 weeks later...
Posted

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

Posted

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

Posted

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

Posted

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

 

YES, PLEASE ADD CANCEL IN DCL

Posted

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.

  • 6 years later...
Posted
On 2/27/2018 at 1:06 AM, 2andygs said:

Thanks a lot... works

hi can u explain how to use above lisp file?

Posted

If your talking about my code just use appload or (load "multiline") or drag and drop from explorer the saved lisp file onto CAD. To do again after loading change.

(defun aH:mult 

to

(defun c:mult 
and change last line to
(c:mult)

to run again type Mult.

 

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