乐筑天下

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

[编程交流] Label Co-ordintes

[复制链接]

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:45:34 | 显示全部楼层 |阅读模式
I'm using AutoCAD 2007.
 
I have the lsp below for labeling co-oredinates.
 
Unfortunately in one drawing I've recieved the points are lebelled in metres, but drawn in mm.
 
It would make my life much easier if the lsp below could be amended to take this into account. So rather than give co-ord of 949846.00,2474211.00, I would like it read as 949.846,2474.211.
 
Unfortunatly I not good enough to amend the lsp.
 
Are any of you abel to amend it?
 
Many thanks.
 
  1. (defun c:lblpt ()   (setq precis 2);;set decimal places here   (while     (setq pt (getpoint "\nSelect point to label: "))     (setq Xval (car pt) Yval (cadr pt))     (setq Xtxt (rtos Xval 2 precis))     (setq Ytxt (rtos Yval 2 precis))     (command "text" pt "" "0" Xtxt)     (command "text" "" ytxt)   );while (princ) )(prompt "\nType lblpt to run command.")(princ)
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 08:53:26 | 显示全部楼层
Divide coordinates to 1000.
  1. (defun c:lblpt () (setq precis 2);;set decimal places here (while (setq pt (getpoint "\nSelect point to label: ")) (setq Xval (/(car pt)1000) Yval (/(cadr pt)1000)) (setq Xtxt (rtos Xval 2 precis)) (setq Ytxt (rtos Yval 2 precis)) (command "text" pt "" "0" Xtxt) (command "text" "" ytxt) );while (princ) )(prompt"\nType lblpt to run command.")(princ)
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:57:00 | 显示全部楼层
If you want coordinates to three decimal places, don't forget to alter the "2" in the second line to "3"
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 09:00:06 | 显示全部楼层
May be standard DIMORDINATE with text override better... It can move after picking point
 
  1. (defun c:ordi(/ fPt oldEcho *error*)  (defun *error*(msg)      (setvar "CMDECHO" oldEcho)    (princ)    ); end of *error*   (setq oldEcho(getvar "CMDECHO"))  (setvar "CMDECHO" 0) (while t (if    (setq fPt(getpoint "\nSpecify point or Esc to Quit > "))    (progn      (command "_.dimordinate" fPt "_t"          (strcat       "X=" (rtos(car fPt)2(getvar "DIMDEC"))       "\\X"       "Y=" (rtos(cadr fPt)2(getvar "DIMDEC"))       ); end strcat          pause          ); end command      ); end progn    ); end if   ); end while   (setvar "CMDECHO" oldEcho)  (princ)  ); end of c:ordi
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:03:23 | 显示全部楼层
Nice way of combining the Ordinate dimensions.
 
Perhaps the DIMLFAC could be incorporated, giving the scaling factor required for the coordinates.
 
I think I can do that myself, but daiharv could probably do with a hand.
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 09:08:56 | 显示全部楼层
 
Yes, now DIMSCALE, DIMLFAC and DIMDEC are works.
 
  1. (defun c:ordi(/ fPt oldEcho dFlc dDec *error*)  (defun *error*(msg)      (setvar "CMDECHO" oldEcho)    (princ)    ); end of *error*  (princ(strcat "DIMSCALE="(rtos                     (getvar "DIMSCALE"))" "        "DIMLFAC="(rtos                    (setq dFlc                     (getvar "DIMLFAC")))" "        "DIMDEC="(rtos                   (setq dDec                    (getvar "DIMDEC")))" " ); end strcat); end princ         (setq oldEcho(getvar "CMDECHO"))  (setvar "CMDECHO" 0) (while t (if    (setq fPt(getpoint "\nSpecify point or Esc to Quit > "))    (progn      (command "_.dimordinate" fPt "_t"          (strcat       "X=" (rtos(* dFlc(car fPt))2 dDec)       "\\X"       "Y=" (rtos(* dFlc(cadr fPt))2 dDec)       ); end strcat          pause          ); end command      ); end progn    ); end if   ); end while   (setvar "CMDECHO" oldEcho)  (princ)  ); end of c:ordi
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:11:44 | 显示全部楼层
Thank you very much ASMI.
 
It is now a much more elegant solution to labelling coordinates using the dimensioning facilities of AutoCAD. I must add on a header where I got it from
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 09:18:49 | 显示全部楼层
>eldon
 
Thanks for kind words. It only my small hobby.
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 09:21:26 | 显示全部楼层
 
i cant make this work.  i appload the lsp then what   Write ordi to command or this overwriting DIMORDINATE  command.  Using Autocad 2008. And new to lisps....
 
There is similar lsp at different topic. i can make  it work by typing 31  thanks...
 
 
回复

使用道具 举报

6

主题

25

帖子

19

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 09:27:48 | 显示全部楼层
 
How do I incorporate this code with 3 decimel places??
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 07:57 , Processed in 0.391609 second(s), 72 queries .

© 2020-2025 乐筑天下

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