PDA

View Full Version : HI.. GENTS .. I NEED HELP with lisp file



HENOKING
2018-04-15, 10:10 AM
I NEED HELP FROM AUTOLISP PROGRAMMER ..
I NEED LISP TO MAKE NUMBERING FROM POINTS GIVE LIKE FILE ATTACH ..
PLEASE FROM ALL .. THANKS

BIG-AL
2018-04-17, 11:07 AM
Have you searched for grid labeling its basicly the same. I dont have anything but its a case of using a double sort on the x y so can look at all common X 1st incrementing for Y and repeating for each X.

This is a start sorts the points on x & Y


(defun gridxy ( / ss lst lst2)
(setq ss (ssget "X" '(( 0 . "point"))))

(setq lst2 '())
(repeat (setq x (sslength ss))
(setq lst '())
(setq ent (entget (ssname ss (setq x (- x 1)))))
(setq lst (cons (caddr (assoc 10 ent)) lst))
(setq lst (cons (cadr (assoc 10 ent)) lst))
(setq lst2 (cons lst lst2))
)
(setq lst2 (reverse lst2))

; sorts on 1st two items
(setq lst2 (vl-sort lst2 '(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
))))
(princ)
)
(gridxy)



Your dwg
((462677.0 3.26445e+06) (462697.0 3.26445e+06) (462717.0 3.26445e+06) (462737.0 3.26445e+06) (462677.0 3.26447e+06) (462697.0 3.26447e+06) (462717.0 3.26447e+06) (462737.0 3.26447e+06))

BIG-AL
2018-04-17, 11:03 PM
Thinking a bit more its probably easier to just pick x spacing, pick y spacing, how many in x direction how many in Y direction, erase any not needed. Have to do real work right now.

BIG-AL
2018-04-18, 11:45 AM
All I have to do now is get this to work


(setq pt1 (getpoint "Pick 1st point cnr"))
(setq x1 (car pt1))
(setq y1 (cadr pt1))
(setq x 1)
(setq y 1)
(setq d1 (GETDIST PT1 "2nd point X"))
(setq d2 (getdist PT1 "2ND PT y"))
(SETQ Xmany (GETINT "How many in x direction"))
(setq ymany (getint "How many in Y direction"))
(setq ansx "A00")
(setq ansy "B00")

(repeat ( + ymany 1)
(repeat ( + xmany 1)
(setq pt (list x1 y1))
(command "text" pt "1" "" (strcat ansx (rtos x 2 0) ansy (rtos y 2 0)))
(setq x1 (+ x1 d1))
(setq x (+ x 1))
)
(setq x 1)
(setq x1(car pt1))
(setq y1 (+ y1 d2))
(setq Y (+ y 1))
)

HENOKING
2018-04-18, 06:21 PM
thank you for quick reply
but the lisp not work
i want number depend on base points ..
please help me

devitg.89838
2018-04-20, 12:54 AM
Do you mean , this way?

106361

HENOKING
2018-04-20, 05:21 AM
Yes.. I have 2 line with base points.. I want renumber like ur Pic with respect Y line as A00x and X line as B00x..
The result for number point.. A001B001
Thx

BIG-AL
2018-04-20, 08:51 AM
Just thought I would post this its a work in progress so dont expect to much it produces a result close to what is required. Unfortunatley ran out of time but will finish over the next few days. Devigt welcome to run with it.



(setq pt1 (getpoint "Pick 1st point cnr"))
(setq x1 (car pt1))
(setq y1 (cadr pt1))
(setq x 1)
(setq y 1)
(setq d1 (GETDIST PT1 "2nd point X"))
(setq d2 (getdist PT1 "2ND PT y"))
(SETQ Xmany (GETINT "How many in x direction"))
(setq ymany (getint "How many in Y direction"))
(setq ansx "A00")
(setq ansy "B00")

(repeat ( + ymany 1)
(repeat ( + xmany 1)
(setq pt (list x1 y1))
(command "text" pt "1" "" (strcat ansx (rtos x 2 0) ansy (rtos y 2 0)))
(setq x1 (+ x1 d1))
(setq x (+ x 1))
)
(setq x 1)
(setq x1(car pt1))
(setq y1 (+ y1 d2))
(setq Y (+ y 1))
)

HENOKING
2018-04-20, 04:32 PM
HI BIG-AL
THE LISP IS WORK .. LIKE THAT:
(defun c:XY ( / ss lst lst2)
(setq ss (ssget "X" '(( 0 . "point"))))


(setq pt1 (getpoint "Pick 1st point cnr"))

(setq x1 (car pt1))

(setq y1 (cadr pt1))

(setq x 1)

(setq y 1)

(setq d1 (GETDIST PT1 "2nd point X"))

(setq d2 (getdist PT1 "2ND PT y"))

(SETQ Xmany (GETINT "How many in x direction:"))

(setq ymany (getint "How many in Y direction:"))

(setq ansx "B00")

(setq ansy "A00")


(repeat ( + ymany 1)

(repeat ( + xmany 1)

(setq pt (list X1 Y1))

(command "text" pt "1" "" (strcat ansx (rtos x 2 0) ansy (rtos y 2 0)))

(setq x1 (+ x1 d1))

(setq x (+ x 1))
)

(setq x 1)

(setq x1(car pt1))

(setq y1 (+ y1 d2))

(setq Y (+ y 1))
)
(princ)
)

BUT I WANT CHANGE THE ARRANGEMENT ,, IT COME LIKE B001A001
I WANT BEGIN A001B001
THX