chavlji Posted February 19, 2009 Share Posted February 19, 2009 Hello Does anyone has lisp procedure for array where i should only select 1. number of itterations 2. start point 3. end point And it would distribute selected items from start point to end point with n/distance spacing. Autocad's default array only accepts number of itterations and spacing between them... Quote Link to comment Share on other sites More sharing options...
badien Posted February 19, 2009 Share Posted February 19, 2009 Hi, You can refer this following file: Hope this helps Cheer!! custom array.LSP Quote Link to comment Share on other sites More sharing options...
chavlji Posted February 19, 2009 Author Share Posted February 19, 2009 Following example SHOULD work, but has some strange error... If I select some random point (that is not OSNAPed) it works superb. But try select second point as INTERSECTION point of some 3rd line and OTRACK line, it does not work right. Every items are placed correct except last one. This one is always placed on the midpoint of the line!!! Why it that so? Please it is driving me crazy... ; Jan Spacing Tool (prompt "\n ca: Jan Spacing tool") (defun c:ST () (setvar "cmdecho" 0) (setq OBJ (ssget)) (if (or (= N nil) (< N 2)) (setq N 2)) (setq N (getint "\nItterations <2>:")) (setq T1 (getpoint "\nStart point ")) (setq T2 (getpoint "\nEnd point\n")) (setq X (car T1)) (setq Y (cadr T1)) (setq X2 (car T2)) (setq Y2 (cadr T2)) ;(PRINC (- Y2 Y)) ;(foreach msg (list "\n" X "," Y "") (princ msg)) ;(foreach msg (list "\n" X2 "," Y2 "") (princ msg)) (initget 1 "Div Mult") (setq Tip (getkword "\nDistance < Div, Mult > ")) (initget 1 "Middle Border") (setq Center (getkword "\nEnd point is < Middle, Border > ")) ;(PRINC (- Y2 Y)) (if (= Center "Border") (progn (setq TBorder (getpoint "\nIzberi robno tocko ")) (setq X2 (- X2 (- (car TBorder) X) ) ) (setq Y2 (- Y2 (- (cadr TBorder) Y) ) ) ) ) (PRINC (- Y2 Y)) (if (= Tip "Div") (progn (setq DX (/ (- X2 X) (- N 1) ) ) (setq DY (/ (- Y2 Y) (- N 1) ) ) ) (progn (setq DX (- X2 X) ) (setq DY (- Y2 Y) ) ) ) (command "_CopyBase" T1 OBJ "") (setq i 1) (while (< i N) (setq TI (list (+ X (* DX i)) (+ Y (* DY i)) ) ) (command "_PasteClip" TI) (PRINC (cadr TI)) (setq i (+ i 1)) ) (foreach msg (list "\nItterated " (- N 1 ) "x on distance DX=" DX ", DY=" DY) (princ msg)) ) Quote Link to comment Share on other sites More sharing options...
uddfl Posted February 19, 2009 Share Posted February 19, 2009 Try setting OSMODE to 0 before PASTECLIP Quote Link to comment Share on other sites More sharing options...
chavlji Posted February 19, 2009 Author Share Posted February 19, 2009 HURAAA!!! Yes setting OSMODE did the trick! Thank you both very much. Quote Link to comment Share on other sites More sharing options...
uddfl Posted February 19, 2009 Share Posted February 19, 2009 Then the only other thing I would advise is that you save the previous osmode setting before changing it to 0 and restore it when the program is terminated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 19, 2009 Share Posted February 19, 2009 Also, use an error handler, so that the sys vars aren't altered if the user hits Esc. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 19, 2009 Share Posted February 19, 2009 Something like this: (setq olderr *error* *error errtrap) (defun errtrap (msg) (if oldvars (mapcar 'setvar vlst oldvars)) (setq *error* olderr) (princ)) (setq vlst (list "CMDECHO" "CLAYER" "OSMODE" "DIMSCALE") ; list altered variables here. oldvars (mapcar 'getvar vlst)) Quote Link to comment Share on other sites More sharing options...
lpseifert Posted February 19, 2009 Share Posted February 19, 2009 Have a look here http://forums.augi.com/showthread.php?t=93251 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 19, 2009 Share Posted February 19, 2009 That is absolutely brilliant larry! Love it Quote Link to comment Share on other sites More sharing options...
uddfl Posted February 20, 2009 Share Posted February 20, 2009 Have a look herehttp://forums.augi.com/showthread.php?t=93251 I'm impressed. Niiiice. Quote Link to comment Share on other sites More sharing options...
badien Posted February 20, 2009 Share Posted February 20, 2009 wow.!! that's cool ! :shock: 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.