乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 81|回复: 13

[编程交流] LISP for creating text label (

[复制链接]

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:45:20 | 显示全部楼层 |阅读模式
Hello all,
I am new to AutoLISP, and I have an assignment to make a lisp which would calculate and write number of the sheet of cadastral map (which is defined by scale and coordinates). I'd like the sheet scale in which the number is calculated to be 1:1000 (more advanced option - to be able to choose). Numbering is defined on this link : http://listovi.dgu.hr/vezaizmedjupodjela.html
(I'm from Croatia)
Any help would be great, thanks.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:51:19 | 显示全部楼层
Simple maths if you pick a point you can work out the grid values as you know the starting base point of the grids. eg x=435,000 divide by start grid is 200,000 grid spacing is 25,000 =integer (435,000-200,000)/25,000) = grid number 9
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:56:04 | 显示全部楼层
hi welcome to cadtutor,
 
just a starting point..
  1. (defun c:test (/ l $) ; scale ,x-grid, y-grid  (setq        l '((250000 150000 100000)    (100000 60000 40000)    (50000 30000 20000)    (25000 15000 10000)    (10000 6000 4000)    (5000 3000 2000)    (2000 1200 800)    (1000 600 400)    (500 300 200)    )) ;_ end of setq (if (progn (initget "250k 100k 50k 25k 10k 5k 2k 1k 0.5k")     (setq $ (getkword "\nSelect Scale 1:? : "))     ) ;_ end of progn      [color="darkgreen"];what kind of labelling? elaborate more?[/color]  [color="darkgreen"] ;Here's the example only shows the grid factor if correct[/color]   (alert   (apply 'strcat   (mapcar ' ' ((a b)(strcat a (itoa b))) '("Scale= " " | X-Grid= " " | Y-Grid= ")    (assoc (* (atoi (vl-string-left-trim "k" $)) 1000) l)))   )[color="darkgreen"];if you wanna label the grid coordinates?;the easiest way without lisp coding is creating Mtext with FIELD xy-coordinates, then array with it's xy-grid factor[/color]      (princ "\oops!")   ) ;_ end of if (princ) ) ;_ end of defun
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:00:00 | 显示全部楼层
Thanks for the responses, the hierarchy behind labeling is in the .dwg's attached. As I'm completely new to this, I'm just catching up with the basics of lisp programming, my professor told me to use math on this, but I'm still struggling on how to combine the mathematic solution with programming. I don't need to label the grid coordinates, I just want to get a text which contains the label of the grid area (rectangle) depending on the picked point coordinates and scale, eg. "1-2-55-105-9", in which 105-9 stands for 105th (101st being the 1st; 100 is added not to mix rows and columns) row and 9th column in the scale of 1:50000; 55 stands for 55th area (or sheet - i'm not sure which terminology to use) in the scale of 1:2000 (50k rectangle is divided into 625 2k rectangles); and 1-2 stands for the area in the scale of 1:1000 (number 1 presenting that this is a numbering in the scale of 1:1000 (1k), and number 2 presenting a second area in the scale of 1:1000; 2k rectangle is divide into 4 1k rectangles). This is better explained in .dwg's. Sorry for the long read.
50k (25k-5k, 10k, 2k-1k-0.5k).dwg
100k.dwg
250k.dwg
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 17:08:11 | 显示全部楼层
 
hi, try this function
 
  1. [color="darkgreen"];|function - [b]MAP-SHEET[/b]argument - Type          ------------------------   n        - scale, number    mX      - max X, number    mY        - max Y, number    $        - suffix, string   -------------------------  Return value:                   A string                   ---------------------------example        :                   (MAP-SHEET 10000 30000 20000 "105-9")n, 10000 = scale 1:10000                mX, 30000 = maximum X range of sheet        mY, 20000 = maximum Y range of sheet        $, "105-9" = suffix of upper level sheetreturns: suffix of newly selected sheet|;[/color](defun [color="blue"][b]MAP-SHEET[/b][/color] (n mX mY $ / ls % d l p p1 p2 k)[color="green"];hanhphuc 12.12.2016[/color]  (if (setq ls '((250000 150000 100000)         (100000 60000 40000)         (50000 30000 20000)         (25000 15000 10000)         (10000 6000 4000)         (5000 3000 2000)         (2000 1200 800)         (1000 600 400)         (500 300 200)         )    l  (assoc n ls)    p1 (getpoint (strcat "\nPick upper left corner of sheet - [M 1:" (itoa n) "] "))    )   (progn (princ "\nHover the mouse over & pick a box.. \n")   (while (and p1 (setq p (grread t 1 0)) (= 5 (car p)) (setq p2 (cadr p)))     (princ (strcat "\rSHEET " (cond (%)(""))"          "))     (setq d  (mapcar '- p2 p1)           ls (reverse (mapcar '+ '(1 -101) (mapcar ''((x y) (fix (/ x y))) d (cdr l))))           k  (mapcar '+ '(1 -1) (mapcar ''((x y) (fix (/ x y))) d (cdr l)))            k  (- (* (1+ (cadr k)) (/ mY (caddr l))) (car k))             %  (if                        ;(vl-some ''((x) (or (minusp x) (> (abs x) 600000))) (list (car d) (- (cadr d)))); for Square only                (or (> (abs (car d)) mX) (> (abs (cadr d)) mY) (minusp (car d)) (minusp (- (cadr d))))                 "\rOut of range!!           "                 (cond ($ (apply 'strcat (append (mapcar 'itoa (list (/ (car l) 1000) k)) (list "-" $))))                       ((vl-string-right-trim                          "-"                          (apply 'strcat                                 (mapcar ''((x) (strcat (itoa x) "-")) (cons (/ (car l) 1000) (mapcar 'abs ls)))                                 )                          )                        )                       )                 )           )     )   )   ) (if (and % (/= % "\rOut of range!!           "))   (substr % (+ 2 (vl-string-search "-" %)))   ""   ) )
 
Example call

[code][color="red"]([color="blue"]MAP-SHEET [color="darkgreen"]10000 30000 20000 [color="magenta"]"105-9"[color="red"])Pick upper left corner of sheet - [M 1:10000]Hover the mouse over & pick a box..SHEET 10-7-105-9  [color="red"];
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 17:11:44 | 显示全部楼层
Thank you...sir hanh phuc
This is not my problem ... but in view of the requirements of the first I was not obvious (english not enough to present my ideas) but also I am a surveyor should be able to understand all lisp for creating text label (numbering) of the sheet of cadastral map need to map 1/5000, 1/2000, 1/1000, and 1/500-specific
if so wrong ... please forgive
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 17:14:44 | 显示全部楼层
 
i'm not sure does this thread help you?
 
In fact i'm not familiar about the mapping labeling (it looks weird to me).
my understanding as OP quoted:
i'm also learning something new from OP's info. my concept is based on what his requirement just with dynamic output. In fact you can try entmake'ing TEXT with minor tweak
 
For automated labeling, suggestion: defun your new function eg: vuong-sheet, remove grread thing in code, add extra arguments pt bp
  1. ;example:  (vuong-sheet [color="red"]pt bp[/color] n mX mY $ ) ;where pt= supplied any point, bp= is top left known coordinates of selected map, then you can iterate in a loop etc..
 
good luck
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 17:18:00 | 显示全部楼层
sorry sir hanh phuc!
I'm busy too few today...
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:22:56 | 显示全部楼层
Dear hahnphuc, your program is great, but I think BIGAL's post explains the method which should be used in programming. The base points of the grid are X = 200000.00     Y = 5170000.00 - north-west, and X = 800000.00     Y = 4570000.00 - south-east. I'd like the program to do the following: when I pick a coordinate, eg (X = 409354.53     Y = 4937853.78), the program calculates the values of the grid (meaning the row and column), eg. for X coordinate - (409354-200000)/150000=2 -> the column is number 2, for Y coordinate (5170000-4937853)/10000=3 -> the row is number 3 (from north to south); so the label which the program should write would be "250-103-2". I hope this explains it, rgds
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:29:27 | 显示全部楼层
A grid would normally start at whole numbers rather than a random point, here is an example of repeated text at a spacing.
 
  1. (setq x 0.0)(setq y 0.0)(setq inc (Getreal "Enter spacing say 1000"))(repeat (getint "Enter how many grids")(command "text" (list x y) "" "" (rtos x 2 0))(setq x (+ x inc)))
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 13:58 , Processed in 0.372451 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表