2andygs Posted February 2, 2018 Share Posted February 2, 2018 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.... Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 2, 2018 Share Posted February 2, 2018 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum, please post in the most relevant forum. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 2, 2018 Share Posted February 2, 2018 This sounds like a task for a dynamic block. Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 2, 2018 Share Posted February 2, 2018 Where should be located the base point? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 2, 2018 Share Posted February 2, 2018 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 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 3, 2018 Share Posted February 3, 2018 Have a look at my post here http://www.cadtutor.net/forum/showthread.php?84919-Draw-double-polyline/page3 May though just be easier to write from scratch. Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 5, 2018 Author Share Posted February 5, 2018 0,0 or anywhere it's not critical Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 5, 2018 Author Share Posted February 5, 2018 Where should be located the base point? 0,0 or anywhere it's not critical Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 5, 2018 Share Posted February 5, 2018 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 Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 9, 2018 Author Share Posted February 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 10, 2018 Share Posted February 10, 2018 (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 Edited February 10, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 26, 2018 Author Share Posted February 26, 2018 Thanks a lot... works Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 26, 2018 Author Share Posted February 26, 2018 Thanks again for the code... Need a minor change ... after pressing escape key still drawing the lines... can you please fix this Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 26, 2018 Author Share Posted February 26, 2018 one more thing... change to accept 6 numbers, i can only enter 4 number now (ex length to accept 1000.5) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2018 Share Posted February 27, 2018 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 Quote Link to comment Share on other sites More sharing options...
2andygs Posted February 27, 2018 Author Share Posted February 27, 2018 Why press esc do you want a cancel in DCL ? Can make Ok Cancel YES, PLEASE ADD CANCEL IN DCL Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 28, 2018 Share Posted February 28, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.